Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

A particular Stack Overflow question asks how to construct a specific cubic Bézier path of constant length. I have experimentally determined the ideal distances of the control points from the nearest on-path handle and plotted them as seen here:

Graph showing actual points compared to ellipse

The graph in blue is the equation I am after. (The $y$ intercept appears to be at $\cos(30°)$.) The graph in red is an ellipse (not the right equation).

Does anyone have either a guess or (better yet) a derivation of what the actual formula ought to be that predicts the distance of a control point oriented $90°$ to the path end points to achieve a constant-length path?

Edit: Here's a diagram showing the constraints on the path:

S Curve showing four points in a 'stair-step' arrangement

  1. The arrangement of the control points $P_1$ and $P_2$ is always orthogonal to the line connecting the end points $P_0$ and $P_3$.

  2. The distance $h$ of each control point from the associated end point is the same for both control points. $|P_1-P_0| = |P_3-P_2|$

  3. The two control points are always on opposite sides of line connecting the end points (they're always in a stair-step, producing a curve looking like an 's').

  4. The goal is to find an equation for $h$ in terms of $d$ (the distance between the two end points).

Edit 2: I can simplify these parametric equations for cubic Bézier curves for my constraints and arrive at:

$$\begin{align*} x(t) &= -6ht^3 + 9ht^2 -3ht\\ y(t)& = -2dt^3 + 3dt^2 \end{align*}$$

How do I integrate from $t=0\ldots1$ to get the length of the curve and then express $h$ in terms of $d$?

share|improve this question
    
So if I understand correctly: given two points and a length, you want to find a Bezier curve made of three control points, with the prescribed endpoints and arc length? –  user7530 Nov 23 '11 at 20:13
    
@user7530 Yes, with the added constraint that the control points are always at right angles to the line connecting the two end points. I'll edit the question with a diagram for clarity. –  Phrogz Nov 23 '11 at 21:04
    
The particularly nasty thing about your problem is that one requires the services of elliptic integrals to express the arclength of a cubic Bézier curve (see this for instance). Inverting that elliptic integral is an even hairier deal. –  J. M. Nov 24 '11 at 8:44
    
See also this demonstration. –  J. M. Nov 24 '11 at 8:52
    
@J.M. Thanks for the details. That's unfortunate; I had hoped that the constraints on the points would sufficiently restrict the solution to something with a simple closed form. –  Phrogz Nov 24 '11 at 16:27
show 2 more comments

1 Answer

It's (probably) impossible to obtain a formula that gives h as a function of d. But, as you can see from the graph you drew, the function is nicely-behaved, so it should be easy to approximate it by some simple function.

If you're interested in a practical approximation, rather than a theoretically correct closed-form solution, let us know, and the details of some approximation can be elaborated.

This might help: http://steve.hollasch.net/cgindex/curves/cbezarclen.html

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.