1
$\begingroup$

I need to programatically generate two-dimensional circles of various dimensions, knowing only their radius and position. The circles will be drawn by employing 4 cubic Bezier curves. How should I calculate the Cartesian coordinates of the two intermediary control points of each arc?

$\endgroup$
2
$\begingroup$

Wikipedia has it all worked out.

The control points between $(1,0)$ and $(0,1)$ are at $(1,k)$ and $(k,1)$ with $k=\frac43(\sqrt2-1)$.

$\endgroup$
4
  • $\begingroup$ Thank you, joriki. For some reason missed the article Bezier Splines. I can see it now linked at the bottom of the Bezier Curves article where this very matter is being discussed. $\endgroup$
    – A Dwarf
    Oct 25 '12 at 22:59
  • $\begingroup$ @ADwarf: You're welcome! $\endgroup$
    – joriki
    Oct 25 '12 at 23:01
  • $\begingroup$ @joriki I've been working on this for three days, wrestling binomial coefficients, Bernstein Basis Polynomials and Catmull-Rom splines, but for a programmer like me the math talk is just too dense. I know that k is something like 0.55. Now (1,k) and (k,1) appear to be coordinates in this answer, but they're actually closed intervals, right? So how do I calculate control points p1 and p2, given begin and end coordinates p0(50,50) and p3(250,50)? $\endgroup$ Jul 9 '16 at 9:47
  • $\begingroup$ @ElisevanLooij: No, they're coordinates. Your $p_0$ and $p_3$ don't define a unique arc; even if I assume that you want a quarter-circle, there are two different quarter-circles with those two endpoints. Find a linear transformation that maps the quarter-circle about the origin through $(1,0)$ and $(0,1)$ to the quarter-circle you want, then apply that transformation to $(1,k)$ and $(k,1)$ to get the control points. $\endgroup$
    – joriki
    Jul 9 '16 at 10:38

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.