When drawing an Arc in 2D, using a Bezier Curve approximation, how does one calculate the two control points given that you have a center point of a circle, a start and end angle and a radius?
When drawing an Arc in 2D, using a Bezier Curve approximation, how does one calculate the two control points given that you have a center point of a circle, a start and end angle and a radius?
This isn't easily explained in a StackOverflow post, particularly since proving it to you will involve a number of detailed steps. However, what you're describing is a common question and there's a number of thorough explanations. See here and here; I like #2 very much and have used it before.
There's Mathematica code at Wolfram MathWorld: Bézier Curve Approximation of an Arc, which should get you started.
See also:
Swift solution based on @k88lawrence answer
Works for arcs <= PI / 2
func controls(center: CGPoint, start: CGPoint, end: CGPoint) -> (CGPoint, CGPoint) {
let ax = start.x - center.x
let ay = start.y - center.y
let bx = end.x - center.x
let by = end.y - center.y
let q1 = (ax * ax) + (ay * ay)
let q2 = q1 + (ax * bx) + (ay * by)
let k2 = 4 / 3 * (sqrt(2 * q1 * q2) - q2) / ((ax * by) - (ay * bx))
let control1 = CGPoint(x: center.x + ax - (k2 * ay), y: center.y + ay + (k2 * ax))
let control2 = CGPoint(x: center.x + bx + (k2 * by), y: center.y + by - (k2 * bx))
return (control1, control2)
}