Given the 4 points describing 2 line segments, how do you calculate if line A is towards or away from line B?
The 2 lines have a fixed length, and can be measured as distance from x1/y1 to x2/y2.
We don't really want to know whether it's left or right; all we want is to make sure they're the same direction or the opposite direction, that's why we multiply the two values.
The following pseudocode should therefore work:
I am afraid I need some time to write a proper solution for the Bezier curve. Is the following situation towards or away?
Assuming start point is the green circle, and end point is the red arrow
Compute the distance between the start point as DS and the black segment, and do the same for the end point (red arrow) as DE. If DS>DE, then the segment is pointing toward. if DE>DS, it is pointing away. If both are equal, the two are parallels.
You can find how to compute the distance from a point to a segment here, and to a quadratic bezier curve here. However, depending of the shape of the bezier curve, it might return weird results (the curve can be crossing itself)