Skip to main content
gamedev.net
🔒 Locked

closest segment.

Started by chakik Jan 22, 2008 at 1:21 AM 0 replies 1k views
Original Post
chakik
chakik
Hello, I would like to ask how to calculate the closest/nearest segment to another segment. If we suppose that we have 3 segments, A1-B1, A2-B2, A3-B3. I need to get the closest segment to A1-B1. Is it simply the segment having the minimun distance to A1-B1 where distance= distance(A1,Ai)+distance(B1, Bi) for i=2,3 ? Thanks a lot, -Fadi
alvaro
alvaro
Probably not. The distance between two segments is not as easy to compute as the sum of distances between some of the ends. The distance is the minimum distance between any point of the first segment and any point of the second. Often this will be one of the distances between ends, but it can also be achieved between one end and some non-end point in the other segment. That non-end point would be the orthogonal projection of the point onto the line that contains the other segment.

So, write a function to compute the distance between two segments and then call it twice, once for segments 1 and 2 and then for 1 and 3.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.