POV-Ray : Newsgroups : povray.advanced-users : Vector Math Problem Server Time
29 Jul 2024 06:19:44 EDT (-0400)
  Vector Math Problem (Message 1 to 10 of 18)  
Goto Latest 10 Messages Next 8 Messages >>>
From: Kevin Loney
Subject: Vector Math Problem
Date: 5 Jan 2003 21:52:23
Message: <3e18ef67@news.povray.org>
How would I go about finding a point on a ray the is equa-distant from to
other points?

--
Kevin
http://www.geocities.com/qsquared_1999/
#macro _(r)#if(r<12)#local i=asc(substr("oqshil
acefg",r,1))-97;disc{<mod(i,7)-3,div(i,7)-1,6>,z,.4
pigment{rgb 10}}_(r+1)#end#end _(1)//KL


Post a reply to this message

From: Christopher James Huff
Subject: Re: Vector Math Problem
Date: 5 Jan 2003 22:07:46
Message: <cjameshuff-037E3F.21574505012003@netplex.aussie.org>
In article <3e18ef67@news.povray.org>, "Kevin Loney" <klo### [at] pt2mcom> 
wrote:

> How would I go about finding a point on a ray the is equa-distant from to
> other points?

Your message is a little garbled. You want to find a point on a ray, the 
point being equidistant to two other points? This is not always 
possible, not without having the point shoot off to infinity.

The point will be in a plane perpendicular to a line between the two 
known points and passing through the midpoint. You can easily calculate 
this plane and find the intersection of the ray with it (with trace() or 
by using the plane equation), but as I mentioned, with a line it can go 
off to infinity, and with a ray there is sometimes no solution.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

From: Francois Labreque
Subject: Re: Vector Math Problem
Date: 5 Jan 2003 22:09:42
Message: <3E18F39C.8070000@videotron.ca>
Program ended abnormally on 1/5/03 9:50 PM, Due to a catastrophic Kevin
Loney error:
> How would I go about finding a point on a ray the is equa-distant from to
> other points?

If you have two points,

Pa = < Xa, Ya, Za >
Pb = < Xb, Yb, Zb >

then the point (M) that is in the middle will be:

M = < (Xa+Xb)/2, (Ya+Yb)/2, (Za+Zb)/2 >

Of course, in POV, you can simply use:

M = (Pa+Pb)/2

-- 
/*Francois Labreque*/#local a=x+y;#local b=x+a;#local c=a+b;#macro P(F//
/*    flabreque    */L)polygon{5,F,F+z,L+z,L,F pigment{rgb 9}}#end union
/*        @        */{P(0,a)P(a,b)P(b,c)P(2*a,2*b)P(2*b,b+c)P(b+c,<2,3>)
/*   videotron.ca  */}camera{orthographic location<6,1.25,-6>look_at a }


Post a reply to this message

From: Kevin Loney
Subject: Re: Vector Math Problem
Date: 5 Jan 2003 22:14:37
Message: <3e18f49d@news.povray.org>
I'll post a diagram in p.b.i in a minute it should give you a better idea of
what I'm trying to find

--
Kevin
http://www.geocities.com/qsquared_1999/
#macro _(r)#if(r<12)#local i=asc(substr("oqshil
acefg",r,1))-97;disc{<mod(i,7)-3,div(i,7)-1,6>,z,.4
pigment{rgb 10}}_(r+1)#end#end _(1)//KL


Post a reply to this message

From: Christopher James Huff
Subject: Re: Vector Math Problem
Date: 5 Jan 2003 22:21:56
Message: <cjameshuff-95E1F9.22115405012003@netplex.aussie.org>
In article <cja### [at] netplexaussieorg>,
 Christopher James Huff <cja### [at] earthlinknet> wrote:

> The point will be in a plane perpendicular to a line between the two 
> known points and passing through the midpoint. You can easily calculate 
> this plane and find the intersection of the ray with it (with trace() or 
> by using the plane equation), but as I mentioned, with a line it can go 
> off to infinity, and with a ray there is sometimes no solution.

#macro CompPoint(pA, pB, rayStart, rayDir)
// The midpoint and plane normal.
    #local midPt = (pA + pB)/2;
    #local Norm = vnormalize(pB - pA);

// Compensate for the plane not passing through the origin.
    #local lRayStart = rayStart - midPt;

// Solve for intersection distance with line.
    #local T = (vdot(Norm, lRayStart)/vdot(Norm, rayDir))

// If T is > 0, there is a ray intersection at rayStart + rayDir*T.
// Otherwise, no intersection. You'll need to fill in the blank.
#end

Untested, I may have made an error, or trace() might be a better idea, 
it would certainly be simpler.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

From: Warp
Subject: Re: Vector Math Problem
Date: 5 Jan 2003 22:44:02
Message: <3e18fb82@news.povray.org>
Francois Labreque <fla### [at] videotronca> wrote:
> M = (Pa+Pb)/2

  Just for the sake of curiosity: This is also called average. :)

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

From: Kevin Loney
Subject: Re: Vector Math Problem
Date: 5 Jan 2003 23:28:46
Message: <3e1905fe@news.povray.org>
that solved my problem quite nicely

thank you

--
Kevin
http://www.geocities.com/qsquared_1999/
#macro _(r)#if(r<12)#local i=asc(substr("oqshil
acefg",r,1))-97;disc{<mod(i,7)-3,div(i,7)-1,6>,z,.4
pigment{rgb 10}}_(r+1)#end#end _(1)//KL


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Vector Math Problem
Date: 5 Jan 2003 23:30:05
Message: <web.3e1905318bb9cc14b417814a0@news.povray.org>
Christopher James Huff wrote:
>In article <cja### [at] netplexaussieorg>,
> Christopher James Huff <cja### [at] earthlinknet> wrote:
>
>> The point will be in a plane perpendicular to a line between the two
>> known points and passing through the midpoint. You can easily calculate
>> this plane and find the intersection of the ray with it (with trace() or
>> by using the plane equation), but as I mentioned, with a line it can go
>> off to infinity, and with a ray there is sometimes no solution.
>
>#macro CompPoint(pA, pB, rayStart, rayDir)
>// The midpoint and plane normal.
>    #local midPt = (pA + pB)/2;
>    #local Norm = vnormalize(pB - pA);
>
>// Compensate for the plane not passing through the origin.
>    #local lRayStart = rayStart - midPt;
>
>// Solve for intersection distance with line.
>    #local T = (vdot(Norm, lRayStart)/vdot(Norm, rayDir))
>
>// If T is > 0, there is a ray intersection at rayStart + rayDir*T.
>// Otherwise, no intersection. You'll need to fill in the blank.
>#end
>
>Untested, I may have made an error, or trace() might be a better idea,
>it would certainly be simpler.


I think this line;
#local lRayStart = rayStart - midPt;

- should have been:
#local lRayStart = midPt - rayStart;


And there should be no need to normalize
the normal vector.

Here's how I would have written that macro:


#macro CompPoint(pA, pB, pRayStart, vRayDir)

    #local pMid = (pA + pB)/2;
    #local vNorm = pB - pA;

    #local T =
      vdot(pMid - pRayStart, vNorm)/vdot(vRayDir, vNorm);

    (pRayStart + T*vRayDir)

#end // CompPoint


And here's how I would test the ray:

#declare pHit = CompPoint(p0, p1, pRay, vRay);

#if (vdot(pHit - pRay, vRay) < 0)
  #debug "There is no point on the ray that has"
  #debug "equal distances to both points."
#end


But I have not tested my code either,
so I too could be wrong.

Tor Olav


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Vector Math Problem
Date: 5 Jan 2003 23:35:02
Message: <web.3e19064d8bb9cc14b417814a0@news.povray.org>
Warp wrote:
>Francois Labreque <fla### [at] videotronca> wrote:
>> M = (Pa+Pb)/2
>
>  Just for the sake of curiosity: This is also called average. :)

Warp, I'm a little curious too:
Can you explain how it makes sense to
calculate the average of two points ?

;)

Tor Olav


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Vector Math Problem
Date: 5 Jan 2003 23:35:03
Message: <web.3e19072d8bb9cc14b417814a0@news.povray.org>
Warp wrote:
....
>#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
>-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -

What happened to the end ?

Tor Olav


Post a reply to this message

Goto Latest 10 Messages Next 8 Messages >>>

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