POV-Ray : Newsgroups : povray.binaries.images : Visualizing camera view frustum Server Time
20 Apr 2024 07:06:13 EDT (-0400)
  Visualizing camera view frustum (Message 9 to 18 of 18)  
<<< Previous 8 Messages Goto Initial 10 Messages
From: Bald Eagle
Subject: Re: Visualizing camera view frustum
Date: 17 Apr 2017 07:50:00
Message: <web.58f4ab361652a4dcc437ac910@news.povray.org>
I was trying to work out a few things, and was using my code and that in
screen.inc as a guide, but of course nothing ever works out the way it's
supposed to.

Excel gives me wildly different results from what POV-Ray returns for the camera
view angle formula.

#declare Angle = 2*atan2d (0.5*CamR.x*Camera_Aspect_Ratio, CamD.z*Camera_Zoom);

I was hoping someone could run a quick check and confirm.

This certainly wouldn't be the first time Excel was just plain wrong.


Post a reply to this message


Attachments:
Download 'excel - angle.jpg' (24 KB)

Preview of image 'excel - angle.jpg'
excel - angle.jpg


 

From: Mike Horvath
Subject: Re: Visualizing camera view frustum
Date: 17 Apr 2017 13:02:13
Message: <58f4f515$1@news.povray.org>
On 4/17/2017 7:47 AM, Bald Eagle wrote:
>
> I was trying to work out a few things, and was using my code and that in
> screen.inc as a guide, but of course nothing ever works out the way it's
> supposed to.
>
> Excel gives me wildly different results from what POV-Ray returns for the camera
> view angle formula.
>
> #declare Angle = 2*atan2d (0.5*CamR.x*Camera_Aspect_Ratio, CamD.z*Camera_Zoom);
>
> I was hoping someone could run a quick check and confirm.
>
> This certainly wouldn't be the first time Excel was just plain wrong.
>

Make sure you are using radians and degrees properly. You may have to 
convert between the two.


Mike


Post a reply to this message

From: Bald Eagle
Subject: Re: Visualizing camera view frustum
Date: 17 Apr 2017 15:10:01
Message: <web.58f511fa1652a4dcc437ac910@news.povray.org>
Mike Horvath <mik### [at] gmailcom> wrote:

> Make sure you are using radians and degrees properly. You may have to
> convert between the two.

Well, the thing is, when I do it all in SDL, it works out fine.

I send the value of angle out to the debug stream, and it's the expected 68.3
degrees or whatever.

Then I work it all out step by step in Excel, and it's just looking WAY off.
See my rows labeled radians and degrees.
I'm using degrees = (radians /pi)*180, and it gives me the same result as
Excel's degrees() function.   So I'm wondering if the atan2 function is flawed.


Post a reply to this message

From: Mike Horvath
Subject: Re: Visualizing camera view frustum
Date: 17 Apr 2017 15:55:29
Message: <58f51db1$1@news.povray.org>
On 4/17/2017 3:05 PM, Bald Eagle wrote:
> I send the value of angle out to the debug stream, and it's the expected 68.3
> degrees or whatever.

Do you know for sure this is the correct answer?


Mike


Post a reply to this message

From: Mike Horvath
Subject: Re: Visualizing camera view frustum
Date: 17 Apr 2017 16:16:02
Message: <58f52282$1@news.povray.org>
On 4/17/2017 7:47 AM, Bald Eagle wrote:
>
> I was trying to work out a few things, and was using my code and that in
> screen.inc as a guide, but of course nothing ever works out the way it's
> supposed to.
>
> Excel gives me wildly different results from what POV-Ray returns for the camera
> view angle formula.
>
> #declare Angle = 2*atan2d (0.5*CamR.x*Camera_Aspect_Ratio, CamD.z*Camera_Zoom);
>
> I was hoping someone could run a quick check and confirm.
>
> This certainly wouldn't be the first time Excel was just plain wrong.
>


What input values are you using?


Mike


Post a reply to this message

From: Bald Eagle
Subject: Re: Visualizing camera view frustum
Date: 18 Apr 2017 07:55:00
Message: <web.58f5fdbb1652a4dcc437ac910@news.povray.org>
Mike Horvath <mik### [at] gmailcom> wrote:

> > #declare Angle = 2*atan2d (0.5*CamR.x*Camera_Aspect_Ratio, CamD.z*Camera_Zoom);

> What input values are you using?
>
>
> Mike

It's just the standard default camera.
So, CamR.x = 1
Aspect ratio = 1.33333333333.......
CamD.z = 1
and Camera zoom = 1

so the calculation basically works out to be 2 * atan2 (0.666666666666666.....)
  converted to degrees
which ought to be very close to 67.38

It works just fine in POV-Ray, I'm just wondering what's getting buggered up in
Excel, or if I'm having an extended "senior moment"


Post a reply to this message

From: scott
Subject: Re: Visualizing camera view frustum
Date: 18 Apr 2017 08:59:10
Message: <58f60d9e$1@news.povray.org>
> so the calculation basically works out to be 2 * atan2 (0.666666666666666.....)

atan2 takes 2 parameters, this is important and likely where you've gone 
wrong. Make sure you've got the parameters the right way round - Excel 
takes (x,y) not (y,x).

If you've already pre-calculated the y/x gradient (eg 0.66666) then for 
atan2 to give the correct result in Excel you need to use 
atan2(1,0.666666). If you do it the other way round atan2(0.66666,1) 
then you're going to get the wrong answer.

>   converted to degrees
> which ought to be very close to 67.38

2*degrees(atan2(1,0.666666)) gives 67.38 degrees in Excel.


Post a reply to this message

From: clipka
Subject: Re: Visualizing camera view frustum
Date: 18 Apr 2017 09:11:33
Message: <58f61085@news.povray.org>
Am 18.04.2017 um 13:51 schrieb Bald Eagle:

> It works just fine in POV-Ray, I'm just wondering what's getting buggered up in
> Excel, or if I'm having an extended "senior moment"

As Scott just pointed out, Excel has `ATAN2(X;Y)`, while virtually all
proper programming languages have `atan2(y,x)`.


Post a reply to this message

From: Bald Eagle
Subject: Re: Visualizing camera view frustum
Date: 18 Apr 2017 10:10:01
Message: <web.58f61de31652a4dcc437ac910@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Am 18.04.2017 um 13:51 schrieb Bald Eagle:
>
> > It works just fine in POV-Ray, I'm just wondering what's getting buggered up in
> > Excel, or if I'm having an extended "senior moment"
>
> As Scott just pointed out, Excel has `ATAN2(X;Y)`, while virtually all
> proper programming languages have `atan2(y,x)`.

Ah yes.
Apparently I was having a "Microsoft Moment".

Thanks for restoring my sanity (such as it is)  ;)


Post a reply to this message

From: Le Forgeron
Subject: Re: Visualizing camera view frustum
Date: 18 Apr 2017 11:54:21
Message: <58f636ad$1@news.povray.org>
Le 17/04/2017 à 21:05, Bald Eagle a écrit :
> Mike Horvath <mik### [at] gmailcom> wrote:
> 
>> Make sure you are using radians and degrees properly. You may have to
>> convert between the two.
> 
> Well, the thing is, when I do it all in SDL, it works out fine.
> 
> I send the value of angle out to the debug stream, and it's the expected 68.3
> degrees or whatever.
> 
> Then I work it all out step by step in Excel, and it's just looking WAY off.
> See my rows labeled radians and degrees.
> I'm using degrees = (radians /pi)*180, and it gives me the same result as
> Excel's degrees() function.   So I'm wondering if the atan2 function is flawed.
> 
> 
> 
> 

Beware, atan2 is not always taking parameters in same order.
In Povray SDL, atan2(A,B) gives the angle in radians of tangent (A/B).

In C (man page), atan2(y,x) gives the angle in radians of tangent (y/x)

In Excel, atan2(x_num,y_num) ... yes, they swapped the parameters !


Post a reply to this message

<<< Previous 8 Messages Goto Initial 10 Messages

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