Hey guys,

My problem is somewhat unique and I'm not really sure how to solve it in a non-iterative fashion:

1 - Given a starting point, ending point, and one control point for a bezier curve in 2D space, I need to find a point on the curve that is exactly at a given distance from the starting point of the curve.

2 - If there are multiple candidates (I believe there can be 2 at the most), I need to figure out which one comes first when walking through the path.

**0**

# Find point on quadratic bezier at given distance

Started by Frongo, Oct 28 2011 04:17 PM

3 replies to this topic

###
#2
Members - Reputation: **109**

Posted 29 October 2011 - 01:00 AM

Let the Bezier control points be (x0, y0), (x1, y1), (x2, y2). We wish to find the intersection of points that are a distance r from (x0, y0). In other words, the intersection of the circle (x - x0)^2 + (y - y0)^2 = r^2 with the curve ((1 - t)^2 * x0 + 2(1 - t)t * x1 + t^2 * x2, (1 - t)^2 * y0 + 2(1 - t)t * y1 + t^2 * y2), 0 <= t <= 1.

Substituting this in,

((1 - t)^2 * x0 + 2(1 - t)t * x1 + t^2 * x2 - x0)^2 + ((1 - t)^2 * y0 + 2(1 - t)t * y1 + t^2 * y2 - y0)^2 = r^2

Solving for t will give you a quartic, (The 0 <= t <= 1 constraint actually means there are at most three valid solutions I believe, although I'm not sure if there is an easier way to solve such a special case) -- you can solve the quartic exactly although this is probably not a great idea. Much easier would be to apply newtons method etc.

Substituting this in,

((1 - t)^2 * x0 + 2(1 - t)t * x1 + t^2 * x2 - x0)^2 + ((1 - t)^2 * y0 + 2(1 - t)t * y1 + t^2 * y2 - y0)^2 = r^2

Solving for t will give you a quartic, (The 0 <= t <= 1 constraint actually means there are at most three valid solutions I believe, although I'm not sure if there is an easier way to solve such a special case) -- you can solve the quartic exactly although this is probably not a great idea. Much easier would be to apply newtons method etc.

###
#3
Members - Reputation: **126**

Posted 31 October 2011 - 09:07 AM

Ahh, I was hoping to avoid that quartic but I guess this is the only way to do it. Unfortunately that would be too expensive to implement in our particular project so I've come up with another (less math intensive) solution for the greater problem.

I now know where to come for my math questions/problems.

Thanks

I now know where to come for my math questions/problems.

Thanks

###
#4
Crossbones+ - Reputation: **2782**

Posted 04 November 2011 - 12:36 PM

You could do a brute force method. Bezier subdivision is faster than using quartic equations and fairly easy to code. You would have to test the distance for each new point, but the Manhattan distance should get you a close enough candidate to do further testing.