Which side of a line segment is a point on?

BlitzMax Forums/BlitzMax Programming/Which side of a line segment is a point on?

zoqfotpik(Posted 2012) [#1]
Is there a canned function for telling what side of a line segment a given point is on, and the distance from the segment?


col(Posted 2012) [#2]
Look up 'dot product'. It will give you closest distance to the line, and which 'side'. Plus if you learn the theory of it, it will be best math friend!

Last edited 2012


matibee(Posted 2012) [#3]
I agree with col. Learn some of this stuff, it's really not that bad, and you'll find it really useful.

Anyway, just to give you a head start here's some of my point/line related base code...


you'll be interested in "pointDistanceToLineSegment2d".

A line segment has a start and an end point, the closest point to a line segment could be the start-point, the end-point or any point between the two.

To use the code above you'll also need my 2d vector type..


As you'll see it uses doubles not floats, but it's laid out in such a way that you can find/replace "Double" with "Float" (and vice versa) to switch from one to the other.


zoqfotpik(Posted 2012) [#4]
I actually knew trig very well at one point, I just can't remember any of it. One of these days I want to spend four hours a day on math for a couple of years.

Thanks for the assistance.

Last edited 2012