JOIN
 Select a Forum     Round Tables New Member Discussions News Discussions Algorithm Matches Marathon Matches NASA Tournament Lab TopCoder Cookbook High School Matches Sponsor Discussions Development Forums Design Forums Search | Watch Thread  |  My Post History  |  My Watches  |  User Settings View: Flat  | Threaded  | Tree Previous Thread  |  Next Thread Forums Tutorial Discussions Geometry Concepts Basic Concept: I don't get the logic behind the distance between a line segment and a point.
 Basic Concept: I don't get the logic behind the distance between a line segment and a point. | Reply From what I understand from the tutorial, to find the distance between a line segment and a point, you need to consider the case where C (the point) lies outside of the line segment AB. In order to determine whether this special case occurs, you use the sign of the dot product of the vectors formed by the three points, A, B and C.The tutorial says..."First, check to see if the nearest point on the line AB is beyond B (as in the example above) by taking AB Ã¢ÂÂ BC. If this value is greater than 0, it means that the angle between AB and BC is between -90 and 90, exclusive, and therefore the nearest point on the segment AB will be B"But how come it isn't..."If this value is greater than 0, it means that the angle between AB and BC is between -90 and 90, exclusive, and therefore the nearest point to C is within segment AB (it may or may not be A or B, the endpoints)"So what I'm thinking is, if the angle between AB and BC, theta, is between 0 and 90, then cos(theta) is positive, then the nearest point to C should lie within the segment AB. In this case, we can drop a perpendicular from C to AB and calculate its length with dot_product(AC, AB) / abs(AB). Otherwise, if theta is greater than 90 degrees (but less than 270) then cos(theta) is negative and so C lies beyond line segment AB, therefore, the closest point must be one of the endpoints A or B and the distance we're looking for the length of line segment AC or BC.I'm unfamiliar with vector arithmetic but I know high school trigonometry. Does anyone know what the right answer here is :c?
 Subject Author Date Basic Concept: I don't get the logic behind the distance between a line segment and a point. Illuminad Aug 18, 2016 at 9:17 PM EDT Re: Basic Concept: I don't get the logic behind the distance between a line segment and a point. gorbunov Aug 23, 2016 at 1:59 AM EDT
 Forums Tutorial Discussions Geometry Concepts Basic Concept: I don't get the logic behind the distance between a line segment and a point. Previous Thread  |  Next Thread