POV-Ray : Newsgroups : povray.advanced-users : Embarrasing Trig Question Server Time
26 Nov 2024 01:35:08 EST (-0500)
  Embarrasing Trig Question (Message 1 to 7 of 7)  
From: deanz
Subject: Embarrasing Trig Question
Date: 28 Jun 2001 15:24:41
Message: <3B3B847B.36941B5E@torgo.net>
Can anyone help a trig simpleton bisect an angle in POVRay?

If I have three points in space (A, B & C), how can I

1) Find the angle of ABC

2) Find the point (D) which lies at a point bisecting an arc AC so that
line DB equals line AB equals line CB ?

I'd like this to work for any three arbitrary points, so I can create a
rounded mesh "box" macro for "boxes" that aren't necessarily regular.
Any help would be appreciated.

TIA,

DeanZ


Post a reply to this message

From: Ron Parker
Subject: Re: Embarrasing Trig Question
Date: 28 Jun 2001 15:56:57
Message: <slrn9jn30b.563.ron.parker@fwi.com>
On Thu, 28 Jun 2001 14:24:43 -0500, deanz wrote:
>Can anyone help a trig simpleton bisect an angle in POVRay?
>
>If I have three points in space (A, B & C), how can I
>
>1) Find the angle of ABC

There's stuff you can do with the cross product and the dot product to
do this, but you don't really need it if all you want to do is bisect
the angle.  In case you do need it for some other reason, though, 

atan2(vdot(A-B,C-B),vlength(vcross(A-B,C-B))) 

should give you an answer for non-pathological cases (i.e. those where 
A, B, and C are distinct points.)

>2) Find the point (D) which lies at a point bisecting an arc AC so that
>line DB equals line AB equals line CB ?

B+vlength(C-B)*vnormalize(A/2+C/2-B);

Just like in geometry class: first bisect the line connecting A and C, 
then project that out to the circle.  Note that this assumes that A and
C are the same distance from B.  If they aren't, there's no such solution
(because AB won't equal CB as specified.)

I haven't tested either equation, so there are probably embarrassing 
errors in them.

-- 
#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: deanz
Subject: Re: Embarrasing Trig Question
Date: 28 Jun 2001 16:43:49
Message: <3B3B9707.FD723F20@torgo.net>
Thanks-- that helps a lot, especially since geometry class is a distant memory.

-DZ

(nice signature line by the way)



Ron Parker wrote:

> On Thu, 28 Jun 2001 14:24:43 -0500, deanz wrote:
> >Can anyone help a trig simpleton bisect an angle in POVRay?
> >
> >If I have three points in space (A, B & C), how can I
> >
> >1) Find the angle of ABC
>
> There's stuff you can do with the cross product and the dot product to
> do this, but you don't really need it if all you want to do is bisect
> the angle.  In case you do need it for some other reason, though,
>
> atan2(vdot(A-B,C-B),vlength(vcross(A-B,C-B)))
>
> should give you an answer for non-pathological cases (i.e. those where
> A, B, and C are distinct points.)
>
> >2) Find the point (D) which lies at a point bisecting an arc AC so that
> >line DB equals line AB equals line CB ?
>
> B+vlength(C-B)*vnormalize(A/2+C/2-B);
>
> Just like in geometry class: first bisect the line connecting A and C,
> then project that out to the circle.  Note that this assumes that A and
> C are the same distance from B.  If they aren't, there's no such solution
> (because AB won't equal CB as specified.)
>
> I haven't tested either equation, so there are probably embarrassing
> errors in them.
>
> --
> #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: Ron Parker
Subject: Re: Embarrasing Trig Question
Date: 29 Jun 2001 09:21:03
Message: <slrn9jp061.5mq.ron.parker@fwi.com>
On 28 Jun 2001 15:56:57 -0400, Ron Parker wrote:
>atan2(vdot(A-B,C-B),vlength(vcross(A-B,C-B))) 

...

>I haven't tested either equation, so there are probably embarrassing 
>errors in them.

Well, at least one embarrassing error is that I got those backwards.  You
want atan2(vlength(vcross(A-B,C-B)),vdot(A-B,C-B)).

-- 
plane{-z,-3normal{crackle scale.2#local a=5;#while(a)warp{repeat x flip x}rotate
z*60#local a=a-1;#end translate-9*x}pigment{rgb 1}}light_source{-9red 1rotate 60
*z}light_source{-9rgb y rotate-z*60}light_source{9-z*18rgb z}text{ttf"arial.ttf"
"RP".01,0translate-<.6,.4,.02>pigment{bozo}}light_source{-z*3rgb-.2}//Ron Parker


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Embarrasing Trig Question
Date: 1 Jul 2001 19:55:19
Message: <3B3FB78C.DF0C73F1@hotmail.com>
Ron Parker wrote:
>...
> You want atan2(vlength(vcross(A-B,C-B)),vdot(A-B,C-B)).

Yes, that's one way of doing it.


He could also try this:
acos(vdot(vnormalize(A-B),vnormalize(C-B)))

or even:
asin(vlength(vcross(vnormalize(A-B),vnormalize(C-B))))

But I would suspect POV to parse your expression faster.
Is this true Ron ?


-- 
Best regards,

Tor Olav

mailto:tor### [at] hotmailcom
http://hjem.sol.no/t-o-k
http://www.crosswinds.net/~tok


Post a reply to this message

From: Ron Parker
Subject: Re: Embarrasing Trig Question
Date: 2 Jul 2001 08:46:42
Message: <slrn9k0r9i.7lp.ron.parker@fwi.com>
On Mon, 02 Jul 2001 01:51:41 +0200, Tor Olav Kristensen wrote:
>
>Ron Parker wrote:
>>...
>> You want atan2(vlength(vcross(A-B,C-B)),vdot(A-B,C-B)).
>
>Yes, that's one way of doing it.
>
>
>He could also try this:
>acos(vdot(vnormalize(A-B),vnormalize(C-B)))
>
>or even:
>asin(vlength(vcross(vnormalize(A-B),vnormalize(C-B))))
>
>But I would suspect POV to parse your expression faster.
>Is this true Ron ?

I suspect they're all about the same in parsing time.  I chose atan2 because
it automatically handles angles beyond pi/2, but that might not be an issue
in this case if you use acos.  asin would have a problem.

-- 
#macro R(L P)sphere{L F}cylinder{L P F}#end#macro P(V)union{R(z+a z)R(-z a-z)R(a
-z*3a+z)torus{1F clipped_by{plane{a 0}}}translate z+V}#end#macro S(g)9-(D-g)*(D-
g)#end#macro Z(D a T F)union{P(a)P(-a)R(y-z-1a)translate.1*D-y*8pigment{rgb<S(7)
S(5)S(3)>}}#if(D)Z(D-.2a,T F)#end#end Z(10x*-2x.2)camera{rotate x*90}


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Embarrasing Trig Question
Date: 3 Jul 2001 12:29:47
Message: <3B41F328.815FC204@hotmail.com>
Ron Parker wrote:
> 
> On Mon, 02 Jul 2001 01:51:41 +0200, Tor Olav Kristensen wrote:
> >
> >Ron Parker wrote:
> >>...
> >> You want atan2(vlength(vcross(A-B,C-B)),vdot(A-B,C-B)).
> >
> >Yes, that's one way of doing it.
> >
> >
> >He could also try this:
> >acos(vdot(vnormalize(A-B),vnormalize(C-B)))
> >
> >or even:
> >asin(vlength(vcross(vnormalize(A-B),vnormalize(C-B))))
> >
> >But I would suspect POV to parse your expression faster.
> >Is this true Ron ?
> 
> I suspect they're all about the same in parsing time.  I chose atan2 because
> it automatically handles angles beyond pi/2, but that might not be an issue
> in this case if you use acos.  asin would have a problem.

I see.

I'm so used to doing it the acos way 
that I didn't give the input ranges 
any thoughts when I posted my last 
message.

Of course; The asin wouldn't be able
to discriminate between vectors having
an angle Theta between them and vectors
having an angle pi-Theta between them.


-- 
Tor Olav Kristensen
mailto:tor### [at] hotmailcom
http://hjem.sol.no/t-o-k
http://www.crosswinds.net/~tok


Post a reply to this message

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