Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

swx

Intersection of two line segments

This topic is 5759 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
Guest Anonymous Poster
I don''t know if this will work, I''m still sorta new to 3d game programming but in my head this seems like it would work
with a vector class that contains a Position Struct named Pos.
Try this

FindIntersection(Vector1, Vector2)
{
While(Vector1.Pos != Vector2.Pos)
{
Vector1.Move();
}
Return X,Y,Z;
}

The "Move()" function would be an algorhythm that would trace along the path of the vector. This might be what you are having trouble with.. it may be simillar to an AI function for moving a monster closer to a player, e.g.
if(Vector1.X < Vector2.X)
//Change observing position..

do the same for .Y and .Z

I hope it helps

Kris
ForceFedDrummer

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
A line in 3 space is defined can be defined by parametic equations.

x = x0 + at
y = y0 + bt
z = z0 + ct

where the point (x0, y0, z0) is on the line
and the vector <a, b, c> is parallel to the line.
If you find the equations for two lines then just set the x
and y equations equal to each other and solve for t. Plug the value of t into the z equations and see if they are equal. If the z equations do not match then the lines do not intersect.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
just thought I should point out- don''t do what Kris said, the algebraic solution is infinitely superiour.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!