camera focus and zoom explanation

253 views
Skip to first unread message

Pier

unread,
Jun 25, 2008, 7:33:22 AM6/25/08
to away3d.dev
Hello everyone :)

I'm developping a panorama class for projecting images on spheres and
cylinders, and I'm having some trouble on configuring the camera for
the cylindrical projection. I can get it right after some tweaking,
but I don't understand the camera focus/zoom values and
relationships...

The focus value seems to be related to the focal length of real
lenses. That is: less focal length = less zoom more angle of vision,
more focal length = less angle of vision and more zoom.

But... how does fit the zoom value in relation to the focus value? Is
it simply a scale multiplier of what you're seeing?

Is there a formula that I could use for working with focal length
values instead of focus/zoom ratios?

In photography and video production you work with focal length, and
know how to get the results you want using one lens or another. It
makes much more sense for me with a background in photography to work
with a focal length.

My last question is... how do I have to set up the camera so that can
I display a 200 x 200 pixels at 200 x 200 pixels with no distortion,
or aliasing?

TIA

Makc

unread,
Jun 25, 2008, 7:44:58 AM6/25/08
to away3...@googlegroups.com

Pier

unread,
Jun 25, 2008, 8:55:10 AM6/25/08
to away3d.dev
Hey thanks for the link but I can't see the relationship between fov
and focal length...

From that post:
var fov:Number = 45;
var fov2:Number = (fov/2) * (Math.PI/180);
var tan:Number = Math.tan(fov2);
camera.zoom = width/(2*tan*camera.focus);

This formula would work if I wanted to match the optic size of a 3d
plane with it's texture, changing focus or zoom parameters.

But what if you already had those set (focus and zoom) and only wanted
to move the camera to view a 3d object in it's real size in pixels?

I supose being able to do this would mean having a focus value with no
distortion (50?) and a default "transparent" zoom value... ?

I'm sorry if this is really obvious...

Regards

Pier

Peter Kapelyan

unread,
Jun 25, 2008, 9:45:43 AM6/25/08
to away3...@googlegroups.com
Hi Pier,
 
For 100% pixels try default zoom+focus, then move the camera away 900 distance. Like

view.camera.moveTo(myObject.position)
view.camera.moveBackward(900);

For double pixels, I think distance is 400. Any other values you need to use that calculation Rob has written.

I hope it helps

-Pete

--
___________________

Actionscript 3.0 Flash 3D Graphics Engine

HTTP://AWAY3D.COM

Peter Kapelyan

unread,
Jun 25, 2008, 10:02:50 AM6/25/08
to away3...@googlegroups.com
This is the formula Rob has posted to calculate the zoom and focus needed for a certain scale:

scale = zoom/(1 + z/focus)
 
However I haven't tried it, I've only ever needed 100%, which would be 900 away from object at default cam settings.

Best
-Pete

Rob Bateman

unread,
Jun 25, 2008, 11:20:03 AM6/25/08
to away3...@googlegroups.com
Yes basically the above formula is used for calculating how you can get 1/1 pixel mapping with a 3d plane

you can rearrange to the slightly more useful:

z = focus*(zoom - 1)

assuming that scale is set at 1 (the value you want)

so for a default camera (with zoom set a 10 and focua at 100) the distance for a 1/1 pixel mapping between texture and view is 900.

when doing this, be sure the dimensions of your plane are the same as the dimensions of your texture! I've been caught out a few times with that

atb

Rob
--
Rob Bateman
Flash Development & Consultancy

rob.b...@gmail.com
www.infiniteturtles.co.uk
www.away3d.com

Pier

unread,
Jun 25, 2008, 1:24:50 PM6/25/08
to away3d.dev
Thanks everyone for the repplies.

I got the 1:1 thing pixel solved with my panorama class. I project the
bitmap on a cylinder and the formula I use to get the focus is:

visor.camera.focus = cylinder_radius / (visor.camera.zoom - 1);

Of course if it's not a plane you don't get exact pixels on all
pixels, but that is the closest I can get to 1:1 with a cylinder or a
sphere.

I'm still investigating the focal length thing...

On Jun 25, 5:20 pm, "Rob Bateman" <rob.bate...@gmail.com> wrote:
> Yes basically the above formula is used for calculating how you can get 1/1
> pixel mapping with a 3d plane
>
> you can rearrange to the slightly more useful:
>
> z = focus*(zoom - 1)
>
> assuming that scale is set at 1 (the value you want)
>
> so for a default camera (with zoom set a 10 and focua at 100) the distance
> for a 1/1 pixel mapping between texture and view is 900.
>
> when doing this, be sure the dimensions of your plane are the same as the
> dimensions of your texture! I've been caught out a few times with that
>
> atb
>
> Rob
>
>
>
> On Wed, Jun 25, 2008 at 3:02 PM, Peter Kapelyan <flashn...@gmail.com> wrote:
> > This is the formula Rob has posted to calculate the zoom and focus needed
> > for a certain scale:
>
> > scale = zoom/(1 + z/focus)
>
> > However I haven't tried it, I've only ever needed 100%, which would be 900
> > away from object at default cam settings.
>
> > Best
> > -Pete
>
> > On Wed, Jun 25, 2008 at 9:45 AM, Peter Kapelyan <flashn...@gmail.com>
> > wrote:
>
> >> Hi Pier,
>
> >> For 100% pixels try default zoom+focus, then move the camera away 900
> >> distance. Like
>
> >> view.camera.moveTo(myObject.position)
> >> view.camera.moveBackward(900);
>
> >> For double pixels, I think distance is 400. Any other values you need to
> >> use that calculation Rob has written.
>
> >> I hope it helps
>
> >> -Pete
>
> >> HTTP://AWAY3D.COM <http://away3d.com/>
>
> > --
> > ___________________
>
> > Actionscript 3.0 Flash 3D Graphics Engine
>
> > HTTP://AWAY3D.COM
>
> --
> Rob Bateman
> Flash Development & Consultancy
>
> rob.bate...@gmail.comwww.infiniteturtles.co.ukwww.away3d.com

Pier

unread,
Jun 25, 2008, 2:42:42 PM6/25/08
to away3d.dev
I think I got it!!!

After a bit if research I found out the relationship between the focus
parameter of the away3d camera and the equivalence in real lens focal
length in mm.

Maybe I'm wrong but here's what I've found out:

100 camera.focus = focal length 111.555 mm

So if you want ot use a 50 mm lens you need to put camera.focus =
44.82;



If you're interested how I got to this conclusion:

I used this formula: Focal Length = (length)/(angle)* (180)/pi
from this website: http://www.bobatkins.com/photography/technical/measuring_focal_length.html

So knowing that to get 1:1 pixel size in away3d you need the camera to
be at 900 pixels away from the object with default focus 100 and zoom
10, you get that the focal legnth in pixels for focus 100 is equal to
446.22 in pixels not millimeters.

So to get the measure in mm I needed to know the pixel/mm ratio. I
measured 20 px in my screen and I got 5mm, so the ratio is 4. Then I
divided 446.22 px/ 4 and I got 111.55 mm. Which is really logical
because when the camera is on the default settings it behaves as a
tele lens IMO. You need to be a bit far away from the object to view
it... it's the same sensation you get when working with a real tele
lens.

A 50mm lens in photography is the regular distortion free lens with no
magnification factor. A bit less than that it's a wide angle lens with
distortion, and bit more it's a tele lens with magnification.

Makc

unread,
Jun 26, 2008, 10:34:45 AM6/26/08
to away3...@googlegroups.com
note that this kind of formula will work in very specific photo
dpi/resolutions; simply selecting diffeent resolution in your camera
settings would break it.

Pier

unread,
Jun 30, 2008, 9:25:36 AM6/30/08
to away3d.dev
Yeah this only works on screen 72 dpi...

If anyone knows of a better way of calculating the focal length...
please tell me!!!! :)

Makc

unread,
Jun 30, 2008, 1:15:38 PM6/30/08
to away3...@googlegroups.com
you would probably have to read exif to determine texture dpi

quick google search gives you few codes available:
http://code.shichiseki.jp/as3/ExifInfo/
http://code.google.com/p/exif-as3/
http://blog.kevinhoyt.org/2005/11/01/actionscript-3-meets-exif-21/

Reply all
Reply to author
Forward
0 new messages