Hi, Given a starting point, a heading, a distance, and a line segment, find the first point along this heading that is the specified distance away from this line segment.
I covered two cases, but I haven't been able to cover the last one. First case: heading away from the line. Ignore it even if the starting point is within the specified distance.
Second case: It intersects the line. I solved it using trig and triangles. Initially didn't consider the next case.
Third case: It is heading towards the line, but it does not intersect it. I think this will solve the second case as well if it's done correctly. Three sub cases: 3.1 The minimum line distance is greater than the specified distance. Ignore it. 3.2 The minimum line distance is equal to the specified distance. Found the points already. 3.3 The minimum line distance is less than the specified distance. This means there is a perpendicular line from the along the heading to an end point of the line segment that is less than the Distance needed. This also means on either side of this perpendicular line will be two lines of the Distance needed. One is perpendicular to the heading, while the other is closest to the same end point and not perpendicular to the heading. Just a matter of finding those points and seeing which one is closer to the start point.
This is where I am stuck today. Drawing it up was easy, but doing the vector calc or whatever turned out tricky. Thanks for any help.
Possible to rephrase as: At what time(s) is P(t) = P0 + t*v at a distance D from the line segment L((x1,y1), (x2,y2))? v=(sin(heading), -cos(heading)) in my case.