POV-Ray : Newsgroups : povray.advanced-users : Vector Math Problem : Re: Vector Math Problem Server Time
29 Jul 2024 04:16:38 EDT (-0400)
  Re: Vector Math Problem  
From: Christopher James Huff
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

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