# 3D segment intersection point

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

## 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)?

- Dave

##### Share on other sites
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_pointD = line_end_point - line_start_point
Given a coordinate, such as x, we can then compute the corresponding value of t:
x = Ox+t*Dxt*Dx = x - Oxt = (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 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 :)

1. 1
2. 2
Rutin
21
3. 3
4. 4
frob
17
5. 5

• 9
• 12
• 9
• 33
• 13
• ### Forum Statistics

• Total Topics
632591
• Total Posts
3007250

×

## Important Information

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!