[ODE] Maths Stuff
Nate W
coding at natew.com
Fri Apr 25 10:19:01 2003
On Fri, 25 Apr 2003, Ander Taylor wrote:
> I want to, given a vector and a plane that intersect, get the length of the
> segments on either side of the plane.
If the line intersects the plane, this function will get you the point of
intersection:
VectorXYZ Generic::vecIntersectionOfLineAndPlane (
const VectorXYZ &vecLineOrigin,
const VectorXYZ &vecLineDirection,
const VectorXYZ &vecPlaneNormal,
const VectorXYZ &vecPointOnPlane)
{
real D = DotProduct (vecPlaneNormal, vecPointOnPlane);
real t_Numerator = (DotProduct (vecPlaneNormal, vecLineOrigin) - D);
real t_Denominator = DotProduct (vecPlaneNormal, vecLineDirection);
real t = - (t_Numerator / t_Denominator);
VectorXYZ vecResult = vecLineOrigin + (vecLineDirection * t);
return vecResult;
}
Given the point of intersection, it's straightforward to find the distance
between that point and the line's endpoints.
--
Nate Waddoups
Redmond WA USA
http://www.natew.com