Jump to content
  • Advertisement
Sign in to follow this  
Vanderry

3D segment intersection point

This topic is 3082 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

Hello people !

I have these two 3D line segments both defined by a start and end point. What I would like to do is find a point on segment A which if segment B was adjusted along the Y-axis, the two would then intersect. In other words I don't care if they actually have an intersection point in 3D space as long as there is one when they are projected onto the Y-plane. If this point was then somehow projected back onto one of the segments in 3D space, that's the point I'm interested in.

I have a method to find an intersection point for a pair of 2D segments which I figured I could use with these 3D segments simply by ignoring their Y-components. This gives me a resulting 2D-vector if they do, and so I wonder if I can use this information to find out the remaining Y-component for one of these segments (or of course if there is a better way)?

Many thanks in advance !

- Dave

Share this post


Link to post
Share on other sites
Advertisement
This doesn't really have anything to do with DirectX - did you mean to post it somewhere else? (Maybe Math & Physics?)

If I understand your question correctly, given a point on the xz plane, you want to find the 'y' value of the corresponding point on a specified line (by 'corresponding', I mean 'the point that projects orthogonally onto the xz plane at the specified coordinates').

We'll start by expressing the line in the parametric form, P(t) = O+t*D, where:
O = line_start_point
D = line_end_point - line_start_point
Given a coordinate, such as x, we can then compute the corresponding value of t:
x = Ox+t*Dx
t*Dx = x - Ox
t = (x - Ox) / Dx
And similarly for y:
t = (y - Oy) / Dy
For numerical stability, I'd recommend using the former equation if |Dx| > |Dy|, and using the latter equation otherwise. (If the line is more or less parallel to the y axis, the problem either has no answer, or doesn't have a unique answer.)

Once you've computed t, you can compute the desired y value as y = Oy + t * Dy.

(I think all of the above is right, but no guarantee of correctness.)

Share this post


Link to post
Share on other sites
Yes, I realized after making the post that it turned out quite generically mathematical so I probably should have someone move it to that section.

This solution seems to work nicely, thank you for taking the time to help this clueless fellow :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!