POV-Ray : Newsgroups : povray.advanced-users : Why the min() step in angle between two vectors? Server Time
29 Jul 2024 14:11:41 EDT (-0400)
  Why the min() step in angle between two vectors? (Message 1 to 4 of 4)  
From: Shay
Subject: Why the min() step in angle between two vectors?
Date: 26 Mar 2002 11:40:24
Message: <3ca0a478$1@news.povray.org>
As far as I know, the angle between two vectors can be found by dividing the
dot product by the lengths and taking the arccosine. If the lengths are both
one, then the arccosine of the dot product should be equal to the angle.

Povray finds the angle between two vectors like this like this: acos(min(1,
vdot(vnormalize(V1), vnormalize(V2))))
What is the purpose of the min()? I guess that this is for some special
case, but I can't figure out what it is. Just curious, but I would really
appreciate some enlightenment. My math is limited, but I'm working on it.

 -Shay


Post a reply to this message

From:
Subject: Re: Why the min() step in angle between two vectors?
Date: 26 Mar 2002 11:49:01
Message: <fa91au456a2b9o4nksr7vrvi9b0onrsh1h@4ax.com>
On Tue, 26 Mar 2002 10:40:41 -0600, "Shay" <sah### [at] simcopartscom> wrote:
> Povray finds the angle between two vectors like this like this: acos(min(1,
> vdot(vnormalize(V1), vnormalize(V2))))
> What is the purpose of the min()?

perhaps to prevent strange floating point accuracy problem ?

ABX


Post a reply to this message

From: Peter Popov
Subject: Re: Why the min() step in angle between two vectors?
Date: 26 Mar 2002 12:33:47
Message: <tkb1aucncrofl902c215md067i22ighvbr@4ax.com>
On Tue, 26 Mar 2002 10:40:41 -0600, "Shay" <sah### [at] simcopartscom> wrote:

>Povray finds the angle between two vectors like this like this: acos(min(1,
>vdot(vnormalize(V1), vnormalize(V2)))) What is the purpose of the min()?

acos is defined over [-1; 1] because no angle has a cosine greater
than 1. However, with computers, it is perfectly normal to have as a
result something like 1.0000000098345352 when you need 1, which, in
this case, will trigger a floating point exception. Hence the min.


Peter Popov ICQ : 15002700
Personal e-mail : pet### [at] vipbg
TAG      e-mail : pet### [at] tagpovrayorg


Post a reply to this message

From: Shay
Subject: A very strange result
Date: 26 Mar 2002 13:29:26
Message: <3ca0be06$1@news.povray.org>
Shay <sah### [at] simcopartscom> wrote in message
news:3ca0a478$1@news.povray.org...

Thanks, guys. I figured it was something like that.

 -Shay


Post a reply to this message

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