POV-Ray : Newsgroups : povray.general : camera "angle" Server Time: 23 Mar 2019 06:36:09 GMT
  camera "angle" (Message 1 to 8 of 8)  
From: dick balaska
Subject: camera "angle"
Date: 9 Apr 2018 19:28:21
Message: <5acbbed5$1@news.povray.org>
Ahoy,

Re:
http://wiki.povray.org/content/Reference:Camera

I'm trying to zoom in on my SpaceLoco as he flies away.  The angle 
option to the camera does exactly what I want.  I say "angle 20" and it 
is beautifully zoomed.  But I don't know why I'm saying angle 20.
I want to know what the "default" angle is.  I'm stuck trying to solve 
for angle.  Doc says:

direction_length = 0.5 * right_length / tan(angle / 2)

So:
1 = 0.5 * right_length / tan(angle/2)
1 = 0.5 * 1.69 / tan(angle/2)
1 = 0.845 / tan(angle/2)
tan(angle/2) = 0.845

and then I'm stuck. I don't know how to extract that /2 so that I can 
take the arctan.

The answer I'm looking for is 82ish. :)

I looked at screen.inc.  It allows me to Set_Camera_Angle() using the 
direction vector (which the doc says is the old/hard way) but there is 
no Get_Camera_Angle().


-- 
dik
Rendered 328976 of 330000 (99%)


Post a reply to this message

From: Bald Eagle
Subject: Re: camera "angle"
Date: 9 Apr 2018 19:55:00
Message: <web.5acbc4bd9fefb05ac437ac910@news.povray.org>
dick balaska <dic### [at] buckosoftcom> wrote:

> I want to know what the "default" angle is.  I'm stuck trying to solve
> for angle.  Doc says:
>
> direction_length = 0.5 * right_length / tan(angle / 2)
>
> So:
> 1 = 0.5 * right_length / tan(angle/2)
> 1 = 0.5 * 1.69 / tan(angle/2)
> 1 = 0.845 / tan(angle/2)
> tan(angle/2) = 0.845

Have a look at:
http://news.povray.org/povray.binaries.images/thread/%3Cweb.587ce3fc782d1af2c437ac910%40news.povray.org%3E/?mtop=415328
&moff=8

If that doesn't help you out, maybe I'll have a chance to give you my snippet of
code for the view frustum.


Post a reply to this message

From: Bald Eagle
Subject: Re: camera "angle"
Date: 9 Apr 2018 20:10:01
Message: <web.5acbc7b99fefb05ac437ac910@news.povray.org>
You are in luck - I had a copy on my other computer.  :)

#declare Angle = 2*atan2d (0.5*CamR.x*Camera_Aspect_Ratio, CamD.z*Camera_Zoom);
// this appears to be close to correct

See if that works for you.


Post a reply to this message

From: dick balaska
Subject: Re: camera "angle"
Date: 9 Apr 2018 21:31:10
Message: <5acbdb9e$1@news.povray.org>
On 04/09/2018 04:06 PM, Bald Eagle wrote:
> You are in luck - I had a copy on my other computer.  :)
> 
> #declare Angle = 2*atan2d (0.5*CamR.x*Camera_Aspect_Ratio, CamD.z*Camera_Zoom);
> // this appears to be close to correct
> 
> See if that works for you.
> 
> 

Thanks.  I assume CamR is camera->right, but how is that 
different/related to Camera_Aspect_Ratio?  I thought aspect ratio *is* 
the right vector.

-- 
dik
Rendered 328976 of 330000 (99%)


Post a reply to this message

From: Bald Eagle
Subject: Re: camera "angle"
Date: 9 Apr 2018 23:25:00
Message: <web.5acbf5699fefb05a5cafe28e0@news.povray.org>
dick balaska <dic### [at] buckosoftcom> wrote:

> Thanks.  I assume CamR is camera->right, but how is that
> different/related to Camera_Aspect_Ratio?  I thought aspect ratio *is*
> the right vector.

I was using screen.inc in that scene, and so those are the variables straight
out of the Update_Camera() macro.
AFAIK, "right" is technically the direction to the right, which would usually be
the unit vector x, or <1, 0, 0>.  But I think most of us use the
image_width/image_height ratio to automatically correct for the aspect ratio of
the usual displays...

.... or I'm completely wrong   ;)

#macro Update_Camera()

   #ifndef (Camera_Aspect_Ratio)
      #declare Camera_Aspect_Ratio = image_width/image_height;
   #end
   #ifndef (Camera_Location) #declare Camera_Location = <0,0,0>; #end
   #ifndef (Camera_Look_At)  #declare Camera_Look_At = z;        #end
   #ifndef (Camera_Sky)      #declare Camera_Sky = y;            #end
   #ifndef (Camera_Zoom)     #declare Camera_Zoom = 1;           #end


   #declare CamL=Camera_Location;                     // wherever you're putting
it
   #declare CamD=vnormalize(Camera_Look_At-CamL);     // direction of camera
view
   #declare CamR=vnormalize(vcross(Camera_Sky,CamD)); // to the right
   #declare CamU=vnormalize(vcross(CamD,CamR));       // camera up
   #declare Camera_Transform =
   transform {
      matrix <
         CamR.x, CamR.y, CamR.z,
         CamU.x, CamU.y, CamU.z,
         CamD.x, CamD.y, CamD.z,
         CamL.x, CamL.y, CamL.z
      >
   }

   camera {
     direction CamD*Camera_Zoom
     right CamR*Camera_Aspect_Ratio
     up CamU
     sky Camera_Sky
     location CamL
   }

#end


Post a reply to this message

From: clipka
Subject: Re: camera "angle"
Date: 10 Apr 2018 05:35:30
Message: <5acc4d22$1@news.povray.org>
Am 09.04.2018 um 21:28 schrieb dick balaska:

> I'm trying to zoom in on my SpaceLoco as he flies away.  The angle
> option to the camera does exactly what I want.  I say "angle 20" and it
> is beautifully zoomed.  But I don't know why I'm saying angle 20.
> I want to know what the "default" angle is.  I'm stuck trying to solve
> for angle.  Doc says:
> 
> direction_length = 0.5 * right_length / tan(angle / 2)
> 
> So:
> 1 = 0.5 * right_length / tan(angle/2)
> 1 = 0.5 * 1.69 / tan(angle/2)
> 1 = 0.845 / tan(angle/2)
> tan(angle/2) = 0.845
>
> and then I'm stuck. I don't know how to extract that /2 so that I can
> take the arctan.

As both sides are equal, their /arcus tangens/ (written as arctan, atan
or tan^-1) should also be equal:

atan(tan(angle/2)) = atan(0.845)

Since the /arcus tangens/ is the inverse of the tangens (tan), the two
cancel out on the left side:

angle/2 = atan(0.845)
angle = atan(0.845)*2

I leave the rest up to you and a good pocket calculator ;)


Post a reply to this message

From: clipka
Subject: Re: camera "angle"
Date: 10 Apr 2018 05:57:34
Message: <5acc524e$1@news.povray.org>
Am 09.04.2018 um 23:31 schrieb dick balaska:

> Thanks.  I assume CamR is camera->right, but how is that
> different/related to Camera_Aspect_Ratio?  I thought aspect ratio *is*
> the right vector.

More precisely, the camera aspect ratio is the ratio between the lengths
of the right and up vectors.

But from Bald Eagle's reply I gather that CamR is not the camera `right`
vector, but only its /normalized/ direction (and only after re-orienting
the camera according to `location` and `look_at`).

Which means that his formula for the angle breaks down if `location` and
`look_at` have identical y or z coordinates.

A simple fix would be to use vlength(CamR) and vlength(CamD) instead of
CamR.x and CamD.z. Note however that by definition these are unit length
vectors, i.e. both have length 1. So what you end up with is:

    #declare Angle = 2*atan2d(0.5*Camera_Aspect_Ratio, Camera_Zoom);


Post a reply to this message

From: dick balaska
Subject: Re: camera "angle"
Date: 11 Apr 2018 00:12:26
Message: <5acd52ea$1@news.povray.org>
On 04/10/2018 01:35 AM, clipka wrote:
> 
> atan(tan(angle/2)) = atan(0.845)
> 

Yes. Thanks.  I see it now.  I got hung up on the non-communitive aspect of
tan(45) + tan(45) != tan(90)
and didn't consider that the tan was actually on the outside of the 
equation.

-- 
dik
Rendered 328976 of 330000 (99%)


Post a reply to this message

Copyright 2003-2008 Persistence of Vision Raytracer Pty. Ltd.