sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Horisontal AOV?

    Scheduled Pinned Locked Moved Developers' Forum
    37 Posts 6 Posters 2.0k Views 6 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M Offline
      matteo
      last edited by

      the fov of a real camera is a function of the film frame dimensions. It is commonly related to a standard film with frames of 3624 mm - a 50 mm lens over a 3624 mm film frame is not the some of a 50 mm lens over a 60*60 mm film frame.

      i know, it's a bit confusing. all the new digital cameras have show an equivalent fov: that's because it would be too tricky to figure out the real angle of view, since there are somany formats. for more informations give a look to this on wikipedia: http://en.wikipedia.org/wiki/Image_sensor_format

      talking about the aov, it is not so difficult to find the horizontal angle when you have the vertical angle values and the aspect ratio.

      if you look at the first image, I extract half horizontal aov (1/2 Haov by now) + half vertical aov (1/2 Vaov by now) and unfold them.

      we have now quite a simple trigonometric problem. both triangles, blue and yellow, share the some radius: then 1/2 Haov tangent is equal to half screen length - and 1/2 Vaov is equal to 1/2 screen heigth. see figure two.

      now the formula is quite simple to obtain

      1/2 Haov = arctan [tan(1/2 Vaov)*(length/heigth)]

      let's suppose that you have a Vaov of 60° and a screen aspect ratio of 3/2, the Haov is equal to:

      Haov = 2* arctan [tan(60°/2)(3/2)] = 2 arctan [tan(30)1,5] = 2 arctan (0,577351,5) = 2 arctan (0,866025) = 2* 40,89339° =

      81,786789°

      i hope this can help you thom
      note: all angles are measured in degrees and not radiants or else.

      /matteo bignozzi


      aov aspect ratio.jpg


      aov aspect ratio 2.jpg

      hire me: http://www.nonsolo3d.it/ !

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        It worked!
        The true test to if I understood this will be when I try to make functions that calculate between all directions of Vaov, Haov and Daov. At least I can go to bed now. 😄 👍

        Thomas Thomassen — SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

        1 Reply Last reply Reply Quote 0
        • Chris FullmerC Offline
          Chris Fullmer
          last edited by

          Oh good. have you got it all worked out then in Ruby Thom?

          Chris

          Lately you've been tan, suspicious for the winter.
          All my Plugins I've written

          1 Reply Last reply Reply Quote 0
          • thomthomT Offline
            thomthom
            last edited by

            
            def self.haov_from_vaov(vaov, ratio)
                return (2 * Math.atan( Math.tan(vaov.degrees / 2) * ratio )).radians 
            end
            
            

            When (if) I get the other conversions worked out I'll post them back here in case anyone else should need them. (Plus, people with better math skills than me can verify if I did it right... 😳 )

            Thomas Thomassen — SketchUp Monkey & Coding addict
            List of my plugins and link to the CookieWare fund

            1 Reply Last reply Reply Quote 0
            • TIGT Offline
              TIG Moderator
              last edited by

              @thomthom said:

              Camera.fov returns the vertical AOV. But how do I get the horizontal or diagonal AOV?
              From Wiki I find this forumla: http://en.wikipedia.org/wiki/Angle_of_view

              http://upload.wikimedia.org/math/a/1/7/a172c67e0c1191e57fdc3e958f596628.png

              ( Math.atan == arctan, right?)
              Problem is, that assumes a film width and height... Which I don't have for the SU camera. So, how do you go about calculating the various AOV?

              After a year or so...
              I needed it - so here it is...

              
              ### acc is the active camera
              ### width is the screen width
              ### height is the screen height
                  fol=acc.focal_length
                  fovV=acc.fov
              ### fovV if the vertical fov in degrees
                  wid=width.to_f
                  hei=height.to_f
                  if acc.image_width != 0
                    wid=acc.image_width
                    if acc.aspect_ratio != 0
                      aro=acc.aspect_ratio
                    else
                      aro=wid/hei
                    end#if
                    hei=wid/aro
                  end#if
                  h=2*fol*Math;;tan(fovV.degrees/2)
                  w=h*wid/hei
                  fovH=(2*Math;;atan(w/(2*fol))).radians
              ### fovH is the horizontal fov in degrees
              
              

              TIG

              1 Reply Last reply Reply Quote 0
              • thomthomT Offline
                thomthom
                last edited by

                Ah! I'd forgotten about this! (yet another project in limbo. 😒 )

                Thanks TIG - I'll play around with this when I get VE over with. 👍

                Thomas Thomassen — SketchUp Monkey & Coding addict
                List of my plugins and link to the CookieWare fund

                1 Reply Last reply Reply Quote 0
                • Chris FullmerC Offline
                  Chris Fullmer
                  last edited by

                  Very odd, I also had to re-visit this to make similar code recently....are we all working on the same project?

                  Chris

                  Lately you've been tan, suspicious for the winter.
                  All my Plugins I've written

                  1 Reply Last reply Reply Quote 0
                  • thomthomT Offline
                    thomthom
                    last edited by

                    I can't even remember exactly what it was any more.

                    I think it was in regard to making camera objects. But due to observers begin naughty it down-prioritised.

                    Thomas Thomassen — SketchUp Monkey & Coding addict
                    List of my plugins and link to the CookieWare fund

                    1 Reply Last reply Reply Quote 0
                    • DavidBoulderD Offline
                      DavidBoulder
                      last edited by

                      I did a quick little diagram, but its been a while since I have had to use any trig to write a formula.aov triangles.png

                      --

                      David Goldwasser
                      OpenStudio Developer
                      National Renewable Energy Laboratory

                      1 Reply Last reply Reply Quote 0
                      • TIGT Offline
                        TIG Moderator
                        last edited by

                        My seemingly convoluted code does return the correct horizontal fovH in degrees from the current fov [i.e. vertical] in degrees...
                        It uses the focal_length of the current camera to get this...
                        The results matches what appears [on a PC] with the code snippet Sketchup.send_action(10624) for the fovH value... so I am confident in its efficacy. 🤓

                        TIG

                        1 Reply Last reply Reply Quote 0
                        • Dan RathbunD Offline
                          Dan Rathbun
                          last edited by

                          On this subject.. FOV a registry question.

                          I noticed a setting in the registry Tools/FovDisplayMode
                          my setting is 0

                          What is this ?

                          I'm not here much anymore.

                          1 Reply Last reply Reply Quote 0
                          • Chris FullmerC Offline
                            Chris Fullmer
                            last edited by

                            You can switch between horizontal and vertical in the dialog window that pops up with:

                            Sketchup.send_action(10624)

                            I wonder if that registry setting controls that? That would be nice to be able to switch the user back and forth from horizontal and vertical as needed maybe?

                            Otherwise, if its not that, I am out of ideas (for now).

                            Chris

                            Lately you've been tan, suspicious for the winter.
                            All my Plugins I've written

                            1 Reply Last reply Reply Quote 0
                            • Chris FullmerC Offline
                              Chris Fullmer
                              last edited by

                              Though FOV being horizontal or vertical seems to be associated with the model, not as an SU global setting. So it is probably not that then?

                              Chris

                              Lately you've been tan, suspicious for the winter.
                              All my Plugins I've written

                              1 Reply Last reply Reply Quote 0
                              • thomthomT Offline
                                thomthom
                                last edited by

                                The global default?

                                Thomas Thomassen — SketchUp Monkey & Coding addict
                                List of my plugins and link to the CookieWare fund

                                1 Reply Last reply Reply Quote 0
                                • Chris FullmerC Offline
                                  Chris Fullmer
                                  last edited by

                                  I suppose it could be, but if it is, the template file is overwriting it.

                                  Lately you've been tan, suspicious for the winter.
                                  All my Plugins I've written

                                  1 Reply Last reply Reply Quote 0
                                  • Dan RathbunD Offline
                                    Dan Rathbun
                                    last edited by

                                    @chris fullmer said:

                                    You can switch between horizontal and vertical in the dialog window that pops up with:
                                    Sketchup.send_action(10624)
                                    I wonder if that registry setting controls that? That would be nice to be able to switch the user back and forth from horizontal and vertical as needed maybe?

                                    I changed the setting to 1, and see no difference, in the model or in any of the settings in that Camera dialog.
                                    Could be an orphan setting left over from some earlier version.

                                    Why is there no menu choice or constant string to bring up that dialog?? Is this a WIN only feature?

                                    I'm not here much anymore.

                                    1 Reply Last reply Reply Quote 0
                                    • Chris FullmerC Offline
                                      Chris Fullmer
                                      last edited by

                                      Yes, it seems to be Win only.

                                      Lately you've been tan, suspicious for the winter.
                                      All my Plugins I've written

                                      1 Reply Last reply Reply Quote 0
                                      • thomthomT Offline
                                        thomthom
                                        last edited by

                                        Think it's a debug dialoge.

                                        But I do wonder why one can set vertical or horisontal AOV from the UI. And why camera.aspect_ratio isn't exposed in the UI.

                                        Thomas Thomassen — SketchUp Monkey & Coding addict
                                        List of my plugins and link to the CookieWare fund

                                        1 Reply Last reply Reply Quote 0
                                        • TIGT Offline
                                          TIG Moderator
                                          last edited by

                                          camera.fov always returns the 'vertical' fov. Many 3rd party apps you export to need the 'horizontal' fov - so fov = 30 degrees fovV >> ~52 degrees fovH...
                                          My method does return fovH in degrees correctly: it's worked out from the only available bits via the API - i.e. camera.fov [vertical, in degrees] & camera.focal_length & the screen's width [ view.vpwith] or the camera.image_width, if that's set [it's >0 if you are using a specific 'camera type']... which can then be combined to get it... 🤓
                                          You can get the camera.aspect_ratio as it's the ratio of the two fov's ??

                                          TIG

                                          1 Reply Last reply Reply Quote 0
                                          • thomthomT Offline
                                            thomthom
                                            last edited by

                                            @tig said:

                                            You can get the camera.aspect_ratio as it's the ratio of the two fov's ??

                                            ?

                                            You do get camera.aspect_ratio via the ruby API. But I was wondering why it is not part of the Sketchup UI to control.

                                            Thomas Thomassen — SketchUp Monkey & Coding addict
                                            List of my plugins and link to the CookieWare fund

                                            1 Reply Last reply Reply Quote 0
                                            • 1
                                            • 2
                                            • 1 / 2
                                            • First post
                                              Last post
                                            Buy SketchPlus
                                            Buy SUbD
                                            Buy WrapR
                                            Buy eBook
                                            Buy Modelur
                                            Buy Vertex Tools
                                            Buy SketchCuisine
                                            Buy FormFonts

                                            Advertisement