Hello,
I am drawing a bezier curve using:
Handles.DrawBezier(startPos, endPos, tan01, tan02, color, null, width)
I need to know if a given shape intersects this bezier. The shape could be a rectangle or circle… depends on what is simpler to implement for the intersection logic. The width value can be ignored for the intersection.
I am searching for something like this:
bool BezierIntersects(startPos, endPos, tan01, tan02, Rect area, int subdivisions)
where subdivisions would be the accuracy of the algorithm. (I guess this is needed)
An alternative would be something like this:
Vector2 BezierGetPosition(startPos, endPos, tan01, tan02, float time)
where time is a value between 0 and 1 for the length in the bezier path.
With the second solution I could loop through the curve and get line segments of it. I could check this line segments with a simple line-rectangle intersection algorithm.
I always wonder why there is no static class in Unity that offers intersection methods for almost every case. Or did I just missed it?
Anyway thank you for the help.