|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
3.2.1.3.4 Functions
"atan2(A,B): Arc-tangent of (A/B). Returns the angle, measured in
radians, whose tangent is (A/B). Returns appropriate value even if B is
zero. Use atan2(A,1) to compute usual atan(A) function."
Um... yeah, OK... so why does atan2(0, 0) give we a fatal parse error?
(POV-Ray v3.6, Windows.)
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Orchid XP v2 wrote:
> 3.2.1.3.4 Functions
>
> "atan2(A,B): Arc-tangent of (A/B). Returns the angle, measured in
> radians, whose tangent is (A/B). Returns appropriate value even if B is
> zero. Use atan2(A,1) to compute usual atan(A) function."
>
>
> Um... yeah, OK... so why does atan2(0, 0) give we a fatal parse error?
>
> (POV-Ray v3.6, Windows.)
The arguments to atan2 are the rise (A) and run (B) of a tangent line for
which you want to know the angle. If the line runs (B != 0) but does not
rise (A = 0), you have a horizontal line. If the line rises (A != 0) but
does not run (B = 0), you have a vertical line. But if the line does not
rise (A = 0) or run (B = 0), what do you have? The line does not go
anywhere, so the angle is undefined.
I haven't looked at the pov code, but I expect this is the reason for the
parse error - there's no correct way to evaluate the expression.
Ken
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
>>Um... yeah, OK... so why does atan2(0, 0) give we a fatal parse error?
>
> The arguments to atan2 are the rise (A) and run (B) of a tangent line for
> which you want to know the angle. If the line runs (B != 0) but does not
> rise (A = 0), you have a horizontal line. If the line rises (A != 0) but
> does not run (B = 0), you have a vertical line. But if the line does not
> rise (A = 0) or run (B = 0), what do you have? The line does not go
> anywhere, so the angle is undefined.
The angle is definitely undefined - but I would be quite happy for POV
to return *any* angle to me... Now I have to figure out how to get round
this parse error. :-/
(The number that results is being fed into a rotate statement, so in the
case of both numbers being zero, whatever rotation ends up happening
won't make any difference to the final image...)
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> The angle is definitely undefined - but I would be quite happy for POV
> to return *any* angle to me... Now I have to figure out how to get round
> this parse error. :-/
#declare A = ...;
#declare B = ...;
#if (A != 0 | B != 0)
#declare angle = atan2(A,B);
#else
#declare angle = 0;
#end
- Slime
[ http://www.slimeland.com/ ]
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Orchid XP v2 <voi### [at] devnull> wrote:
> "atan2(A,B): Arc-tangent of (A/B). Returns the angle, measured in
> radians, whose tangent is (A/B). Returns appropriate value even if B is
> zero. Use atan2(A,1) to compute usual atan(A) function."
> Um... yeah, OK... so why does atan2(0, 0) give we a fatal parse error?
Because the result is not defined. You are basically asking the
direction of a zero vector, which has none.
--
- Warp
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
>>"atan2(A,B): Arc-tangent of (A/B). Returns the angle, measured in
>>radians, whose tangent is (A/B). Returns appropriate value even if B is
>>zero. Use atan2(A,1) to compute usual atan(A) function."
>
>
>>Um... yeah, OK... so why does atan2(0, 0) give we a fatal parse error?
>
>
> Because the result is not defined. You are basically asking the
> direction of a zero vector, which has none.
I just thought the whole point of using atan2 was to _avoid_ divide by
zero errors.
Sure, if the vector has a length of zero it has no defined direction.
OTOH, I would imagine in most cases it just wouldn't *matter* what
number the function returns in this case - just so long as it returns
something, rather than an error...
Oh well.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Orchid XP v2" <voi### [at] devnull> wrote in message
news:441ea0bb@news.povray.org...
>>>"atan2(A,B): Arc-tangent of (A/B). Returns the angle, measured in
>>>radians, whose tangent is (A/B). Returns appropriate value even if B is
>>>zero. Use atan2(A,1) to compute usual atan(A) function."
>>
>>
>>>Um... yeah, OK... so why does atan2(0, 0) give we a fatal parse error?
>>
>>
>> Because the result is not defined. You are basically asking the
>> direction of a zero vector, which has none.
>
> I just thought the whole point of using atan2 was to _avoid_ divide by
> zero errors.
>
> Sure, if the vector has a length of zero it has no defined direction.
> OTOH, I would imagine in most cases it just wouldn't *matter* what number
> the function returns in this case - just so long as it returns something,
> rather than an error...
>
> Oh well.
Hi,
The easy workaround would be to put Slime's solution into your own macro
e.g. Orchidatan2(A,B) returning the angle.
Then, if you've got a lot of atan2 calls you can just do a global replace.
Regard,
Chris B.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Orchid XP v2 <voi### [at] devnull> wrote:
> >>"atan2(A,B): Arc-tangent of (A/B). Returns the angle, measured in
> >>radians, whose tangent is (A/B). Returns appropriate value even if B is
> >>zero. Use atan2(A,1) to compute usual atan(A) function."
> >
> I just thought the whole point of using atan2 was to _avoid_ divide by
> zero errors.
>
> Oh well.
Yes, but not when A and B are BOTH zero. Then the function is undefined.
You could simply do some error checking before trying to calculate the
function, and skip it altogether when A = B = 0.
Mike
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
news:441ea0bb@news.povray.org...
> >>"atan2(A,B): Arc-tangent of (A/B). Returns the angle, measured in
> >>radians, whose tangent is (A/B). Returns appropriate value even if B is
> >>zero. Use atan2(A,1) to compute usual atan(A) function."
> >
> >
> >>Um... yeah, OK... so why does atan2(0, 0) give we a fatal parse error?
> >
> >
> > Because the result is not defined. You are basically asking the
> > direction of a zero vector, which has none.
>
> I just thought the whole point of using atan2 was to _avoid_ divide by
> zero errors.
>
> Sure, if the vector has a length of zero it has no defined direction.
> OTOH, I would imagine in most cases it just wouldn't *matter* what
> number the function returns in this case - just so long as it returns
> something, rather than an error...
>
> Oh well.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|