POV-Ray : Newsgroups : povray.general : A little vector problem Server Time
20 Nov 2024 10:20:26 EST (-0500)
  A little vector problem (Message 1 to 4 of 4)  
From: Micha Riser
Subject: A little vector problem
Date: 30 Aug 2001 14:35:38
Message: <3b8e877a$1@news.povray.org>
What is the easiest (fastest) way to check in pov whether the angle between 
two normalized vectors is >90 degrees? I am currently testing if
vlength(A-B)>sqrt(2)

And what is the easiest way to check if two colinear vectors point in the 
same direction?

- Micha


Post a reply to this message

From: Ron Parker
Subject: Re: A little vector problem
Date: 30 Aug 2001 15:00:30
Message: <slrn9ot3ag.3p7.ron.parker@fwi.com>
On Thu, 30 Aug 2001 20:31:11 +0200, Micha Riser wrote:
>What is the easiest (fastest) way to check in pov whether the angle between 
>two normalized vectors is >90 degrees? I am currently testing if
>vlength(A-B)>sqrt(2)
>
>And what is the easiest way to check if two colinear vectors point in the 
>same direction?

The answer to both questions is vdot.  For the first question, the angle is
obtuse if the dot product is negative.  For the second, they point in the same
direction if the dot product is positive.

-- 
#local R=rgb 99;#local P=R-R;#local F=pigment{gradient x}box{0,1pigment{gradient
y pigment_map{[.5F pigment_map{[.3R][.3F color_map{[.15red 99][.15P]}rotate z*45
translate x]}]#local H=pigment{gradient y color_map{[.5P][.5R]}scale 1/3}[.5F
pigment_map{[.3R][.3H][.7H][.7R]}]}}}camera{location.5-3*z}//only my opinions


Post a reply to this message

From: Chris Jeppesen
Subject: Re: A little vector problem
Date: 30 Aug 2001 15:18:28
Message: <3b8e9184$1@news.povray.org>
1) vdot()

given normalized vectors A and B, vdot(A,B) is 1 if they are parallel/equal,
0 if perpendicular, -1 if pointing in opposite directions, and in general,
cos(angle between). So the condition you are looking for is vdot(A,B)<0.

Given general normalized or un-normalized vectors,vdot(A,B)>0 means angle
less than 90, vdot(A,B)=0 are perpendicular, and vdot(A,B)<0 means angle
more than 90.

2) vdot(vnormal(A),vnormal(B))=1 for any two parallel vectors

Chris

"Micha Riser" <mri### [at] gmxnet> wrote in message
news:3b8e877a$1@news.povray.org...
> What is the easiest (fastest) way to check in pov whether the angle
between
> two normalized vectors is >90 degrees? I am currently testing if
> vlength(A-B)>sqrt(2)
>
> And what is the easiest way to check if two colinear vectors point in the
> same direction?
>
> - Micha


Post a reply to this message

From: Micha Riser
Subject: Re: A little vector problem
Date: 31 Aug 2001 12:18:00
Message: <3b8fb8b8@news.povray.org>
Thank you for your answers. I just knew that there had to be a quick and 
simple solution... actually I used vdot already to calculate angles between 
vectors, but I thought it would be too complicated to do this for this 
problem. That is why I came away from vdot.


Post a reply to this message

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