0
$\begingroup$

I've been stuck on this for 2 weeks and have not had much luck asking else where either.

I have a curve, which is an arc, at each end of the arc there is tangent vector which is sloped in some direction on the Y axis, these tangents are unit vectors that just point in some direction at the end points of the arc, a visual of what I am trying to create here:

enter image description here

The arc is from a circle so its a perfect arc when projected flat, I am slicing this arc into a series of smaller bezier curves < 90 degrees each as an approximation to keep it accurate.

The problem is I can't figure out the control points for the Bézier curves to match the slope along this arc for the arc's tangent.

This is my current attempt:

enter image description here

I can find the horizontal displacement for the bezier curve of the arc quite easily, as you can see it winds around the arc perfectly but the vertical component of the control points I cannot figure out.

The Bézier curve is calculated like this:

// convert a slice of the full curve to bezier
// origin, radius, from, to, angleBetween from and to

    c = tan(angle / 4) * 4 / 3f * radius
    pt1 = from
    ctrlPt1 = from + Perpendicular(from - origin).normalized * c
    ctrlPt2 = to + Perpendicular(to - origin).normalized * c
    pt2 = to

// need to now adjust ctrlPt1 and ctrlPt2 to give them correct slope, not sure how to calculate

Using this function, you can see it just finds "flat" control points and gives a wonky curve that levels off at each end of the Bézier curve:

enter image description here

This is how it was suppose to look (drawn in white.. poorly with the mouse): enter image description here

How do you calculate the correct control point positions to match the desired end tangents of the full arc for each sliced Bézier curve? I can't figure out the math at all.

$\endgroup$
0
$\begingroup$

There are an infinite number of curves whose projections give the circular arc. You found one such curve by using horizontal tangent vectors.

Perhaps the most reasonable choice is a helix. Let’s assume that the vertical direction is the $z$-axis of your coordinate system. The helix will have a constant value for $dz/d\theta$ (the pitch of the helix), which you can adjust to get the heights you want at the start and end of the curve. Use the tangent vectors of this helix to help define the control points of your Bézier curves.

| cite | improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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