## change lens_angle while keeping relative size on screen equal

Aug 12, 2006 at 4:39pm

# change lens_angle while keeping relative size on screen equal

Hello,

I want to change the lens_angle in a 3d scene, but with the objects
staying the same size, relative to the screen…
There has to be a simple formula for that, but I can’t seem to figure
out the relation between object size and lens_angle.
any clues?

brecht.

#27134
Aug 22, 2006 at 2:00am

If you want to change the lens angle but keep the relative size on the screen the same, you must move the object closer or farther away.

Using trigonometry, it should be simple to calculate the ratios.

sin(LensAngle) = ( WidthOfObject/2.0 ) / DistanceFromCamera

sin(LensAngle) * DistanceFromCamera = ( WidthOfObject/2.0 )

sin(LensAngleOld) * DistanceFromCameraOld= ( WidthOfObjectOld/2.0 )

sin(LensAngleNew)*DistanceFromCameraNew = ( WidthOfObjectNew/2.0 )

since we want the object to stay the same size :
WidthOfObjectNew = WidthOfObjectOld

sin(LensAngleOld) * DistanceFromCameraOld
=
sin(LensAngleNew)*DistanceFromCameraNew

Now we solve for DistanceFromCameraNew or LensAngleNew. Since the lensangle and distance from camera are related. We must solve for one or the other.

LensAngleNew= arcsin(sin(LensAngleOld) * DistanceFromCameraOld/DistanceFromCameraNew )

DistanceFromCameraNew = DistanceFromCameraOld * sin
(LensAngleOld)/sin(LensAngleNew)

For example. If your object is 3 units away from the camera, and your old camera angle was 45.

Now lets say you want a new camera angle of 90.
you must move the object to

3*sin(45)/sin(90)
the actual new distance is 2.121

The easist way of thinking of this is

The relative distance is sin(oldLensAngle)/sin(NewLensAngle)

You should double check my math…

#81834
Aug 23, 2006 at 11:18pm

Hm, that doesn’t seem to work… implemented the little example you
gave at the bottom, and the results are different…
The first numberbox is the distance, 2nd and 3rd the initial and
changed lens angle.

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 260 302 76 196617 unpack 0. 0. 0.;
#P newex 260 282 61 196617 pak 0. 0. 0.;
#P flonum 332 258 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 296 258 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 260 258 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 260 347 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 260 323 140 196617 expr \$f1* sin(\$f2)/sin(\$f3);
#P fasten 6 2 0 2 331 321 395 321;
#P fasten 6 1 0 1 298 321 330 321;
#P connect 6 0 0 0;
#P connect 0 0 1 0;
#P fasten 4 0 5 2 337 277 315 277;
#P fasten 3 0 5 1 301 277 290 277;
#P connect 5 0 6 0;
#P connect 2 0 5 0;
#P window clipboard copycount 7;

On Aug 22, 2006, at 4:00 AM, Jason Schmitt wrote:
>
> If you want to change the lens angle but keep the relative size on
> the screen the same, you must move the object closer or farther away.
>
> Using trigonometry, it should be simple to calculate the ratios.
>
>
>
> sin(LensAngle) = ( WidthOfObject/2.0 ) / DistanceFromCamera
>
> sin(LensAngle) * DistanceFromCamera = ( WidthOfObject/2.0 )
>
>
> sin(LensAngleOld) * DistanceFromCameraOld= ( WidthOfObjectOld/2.0 )
>
> sin(LensAngleNew)*DistanceFromCameraNew = ( WidthOfObjectNew/2.0 )
>
>
> since we want the object to stay the same size :
> WidthOfObjectNew = WidthOfObjectOld
>
>
>
>
> sin(LensAngleOld) * DistanceFromCameraOld
> =
> sin(LensAngleNew)*DistanceFromCameraNew
>
>
> Now we solve for DistanceFromCameraNew or LensAngleNew. Since the
> lensangle and distance from camera are related. We must solve for
> one or the other.
>
>
>
> LensAngleNew= arcsin(sin(LensAngleOld) * DistanceFromCameraOld/
> DistanceFromCameraNew )
>
> DistanceFromCameraNew = DistanceFromCameraOld * sin
> (LensAngleOld)/sin(LensAngleNew)
>
>
> For example. If your object is 3 units away from the camera, and
> your old camera angle was 45.
>
> Now lets say you want a new camera angle of 90.
> you must move the object to
>
> 3*sin(45)/sin(90)
> the actual new distance is 2.121
>
>
> The easist way of thinking of this is
>
>
> The relative distance is sin(oldLensAngle)/sin(NewLensAngle)
>
>
> You should double check my math…
>
>

#81835
Aug 24, 2006 at 5:27am

are you going for the look a ‘dolly zoom’ or ‘trombone effect’? :)

http://en.wikipedia.org/wiki/Dolly_zoom

best,
dan

On 8/23/06, Brecht Debackere wrote:
> Hm, that doesn’t seem to work… implemented the little example you
> gave at the bottom, and the results are different…
> The first numberbox is the distance, 2nd and 3rd the initial and
> changed lens angle.
>
> #P window setfont “Sans Serif” 9.;
> #P window linecount 1;
> #P newex 260 302 76 196617 unpack 0. 0. 0.;
> #P newex 260 282 61 196617 pak 0. 0. 0.;
> #P flonum 332 258 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P flonum 296 258 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P flonum 260 258 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P flonum 260 347 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P newex 260 323 140 196617 expr \$f1* sin(\$f2)/sin(\$f3);
> #P fasten 6 2 0 2 331 321 395 321;
> #P fasten 6 1 0 1 298 321 330 321;
> #P connect 6 0 0 0;
> #P connect 0 0 1 0;
> #P fasten 4 0 5 2 337 277 315 277;
> #P fasten 3 0 5 1 301 277 290 277;
> #P connect 5 0 6 0;
> #P connect 2 0 5 0;
> #P window clipboard copycount 7;
>
> On Aug 22, 2006, at 4:00 AM, Jason Schmitt wrote:
> >
> > If you want to change the lens angle but keep the relative size on
> > the screen the same, you must move the object closer or farther away.
> >
> > Using trigonometry, it should be simple to calculate the ratios.
> >
> >
> >
> > sin(LensAngle) = ( WidthOfObject/2.0 ) / DistanceFromCamera
> >
> > sin(LensAngle) * DistanceFromCamera = ( WidthOfObject/2.0 )
> >
> >
> > sin(LensAngleOld) * DistanceFromCameraOld= ( WidthOfObjectOld/2.0 )
> >
> > sin(LensAngleNew)*DistanceFromCameraNew = ( WidthOfObjectNew/2.0 )
> >
> >
> > since we want the object to stay the same size :
> > WidthOfObjectNew = WidthOfObjectOld
> >
> >
> >
> >
> > sin(LensAngleOld) * DistanceFromCameraOld
> > =
> > sin(LensAngleNew)*DistanceFromCameraNew
> >
> >
> > Now we solve for DistanceFromCameraNew or LensAngleNew. Since the
> > lensangle and distance from camera are related. We must solve for
> > one or the other.
> >
> >
> >
> > LensAngleNew= arcsin(sin(LensAngleOld) * DistanceFromCameraOld/
> > DistanceFromCameraNew )
> >
> > DistanceFromCameraNew = DistanceFromCameraOld * sin
> > (LensAngleOld)/sin(LensAngleNew)
> >
> >
> > For example. If your object is 3 units away from the camera, and
> > your old camera angle was 45.
> >
> > Now lets say you want a new camera angle of 90.
> > you must move the object to
> >
> > 3*sin(45)/sin(90)
> > the actual new distance is 2.121
> >
> >
> > The easist way of thinking of this is
> >
> >
> > The relative distance is sin(oldLensAngle)/sin(NewLensAngle)
> >
> >
> > You should double check my math…
> >
> >
>
>

http://idmi.poly.edu

#81836
Aug 24, 2006 at 5:20pm

Yep. that’s exactly it.

On Aug 24, 2006, at 7:27 AM, Dan Winckler wrote:

> are you going for the look a ‘dolly zoom’ or ‘trombone effect’? :)
>
> http://en.wikipedia.org/wiki/Dolly_zoom
>
> best,
> dan
>
>
> On 8/23/06, Brecht Debackere wrote:
>> Hm, that doesn’t seem to work… implemented the little example you
>> gave at the bottom, and the results are different…
>> The first numberbox is the distance, 2nd and 3rd the initial and
>> changed lens angle.
>>
>> #P window setfont “Sans Serif” 9.;
>> #P window linecount 1;
>> #P newex 260 302 76 196617 unpack 0. 0. 0.;
>> #P newex 260 282 61 196617 pak 0. 0. 0.;
>> #P flonum 332 258 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
>> #P flonum 296 258 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
>> #P flonum 260 258 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
>> #P flonum 260 347 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
>> #P newex 260 323 140 196617 expr \$f1* sin(\$f2)/sin(\$f3);
>> #P fasten 6 2 0 2 331 321 395 321;
>> #P fasten 6 1 0 1 298 321 330 321;
>> #P connect 6 0 0 0;
>> #P connect 0 0 1 0;
>> #P fasten 4 0 5 2 337 277 315 277;
>> #P fasten 3 0 5 1 301 277 290 277;
>> #P connect 5 0 6 0;
>> #P connect 2 0 5 0;
>> #P window clipboard copycount 7;
>>
>> On Aug 22, 2006, at 4:00 AM, Jason Schmitt wrote:
>> >
>> > If you want to change the lens angle but keep the relative size on
>> > the screen the same, you must move the object closer or farther
>> away.
>> >
>> > Using trigonometry, it should be simple to calculate the ratios.
>> >
>> >
>> >
>> > sin(LensAngle) = ( WidthOfObject/2.0 ) / DistanceFromCamera
>> >
>> > sin(LensAngle) * DistanceFromCamera = ( WidthOfObject/2.0 )
>> >
>> >
>> > sin(LensAngleOld) * DistanceFromCameraOld= ( WidthOfObjectOld/2.0 )
>> >
>> > sin(LensAngleNew)*DistanceFromCameraNew = ( WidthOfObjectNew/2.0 )
>> >
>> >
>> > since we want the object to stay the same size :
>> > WidthOfObjectNew = WidthOfObjectOld
>> >
>> >
>> >
>> >
>> > sin(LensAngleOld) * DistanceFromCameraOld
>> > =
>> > sin(LensAngleNew)*DistanceFromCameraNew
>> >
>> >
>> > Now we solve for DistanceFromCameraNew or LensAngleNew. Since the
>> > lensangle and distance from camera are related. We must solve for
>> > one or the other.
>> >
>> >
>> >
>> > LensAngleNew= arcsin(sin(LensAngleOld) * DistanceFromCameraOld/
>> > DistanceFromCameraNew )
>> >
>> > DistanceFromCameraNew = DistanceFromCameraOld * sin
>> > (LensAngleOld)/sin(LensAngleNew)
>> >
>> >
>> > For example. If your object is 3 units away from the camera, and
>> > your old camera angle was 45.
>> >
>> > Now lets say you want a new camera angle of 90.
>> > you must move the object to
>> >
>> > 3*sin(45)/sin(90)
>> > the actual new distance is 2.121
>> >
>> >
>> > The easist way of thinking of this is
>> >
>> >
>> > The relative distance is sin(oldLensAngle)/sin(NewLensAngle)
>> >
>> >
>> > You should double check my math…
>> >
>> >
>>
>>
>
>
> —
> ***
> http://danwinckler.com
> http://share.dj
> http://idmi.poly.edu
>
>

#81837
Aug 26, 2006 at 7:54pm

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P comment 320 162 100 9109513 Old Distance;
#P comment 348 184 132 9109513 Old Camera Angle Degrees;
#P comment 299 390 100 9109513 New Distance;
#P comment 459 231 100 9109513 Degress to radians;
#P comment 396 268 100 9109513 Radians;
#P flonum 335 203 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 311 184 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 301 229 76 9109513 * 0.017453;
#P newex 379 228 76 9109513 * 0.017453;
#P newex 267 309 76 9109513 unpack 0. 0. 0.;
#P newex 267 289 61 9109513 pak 0. 0. 0.;
#P flonum 339 265 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 303 265 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 277 163 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 249 391 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 233 350 140 9109513 expr \$f1* sin(\$f2)/sin(\$f3);
#P comment 371 203 136 9109513 New Camera Angle Degrees;
#P connect 11 0 8 0;
#P connect 10 0 9 0;
#P connect 8 0 5 0;
#P connect 9 0 4 0;
#P connect 3 0 6 0;
#P connect 6 0 7 0;
#P fasten 4 0 6 1 308 284 297 284;
#P fasten 5 0 6 2 344 284 322 284;
#P connect 1 0 2 0;
#P connect 7 0 1 0;
#P fasten 7 1 1 1 305 328 303 328;
#P fasten 7 2 1 2 338 328 368 328;
#P window clipboard copycount 17;

#81838

You must be logged in to reply to this topic.