Original Post
This is probably a simple problem, but my math skills aren't that sharp. What I have is a line segment from (x1,z1) to (x2,z2) and a value z. z represents a horizontal, one-dimensional line. I've gotten to the point where I can tell if z is between the segment's points. Now I'm stuck though, I have no idea how to get the intersection point. Point consists of two variables: X and Z Anyone have any ideas? I thought about getting the slope, but what do I do after that?
public static Point LinePlaneIntersection( Point A, Point B, short Z )
{
if( A.Z == Z )
{
return A;
}
if( B.Z == Z )
{
return B;
}
if( A.Z < B.Z )
{
if( ( Z < A.Z ) || ( Z > B.Z ) )
{
return null;
}
}
else
{
if( ( Z < B.Z ) || ( Z > A.Z ) )
{
return null;
}
}
// intersection test should go here
return null;
}