Skip to content

Instantly share code, notes, and snippets.

@steveruizok
Created April 12, 2022 12:33
Show Gist options
  • Save steveruizok/ec13a67a61af0c31a9733e25c8b770dc to your computer and use it in GitHub Desktop.
Save steveruizok/ec13a67a61af0c31a9733e25c8b770dc to your computer and use it in GitHub Desktop.
Find the control points for a quadratic bezier curve segment from point a to point c passing through point b.
/**
* Find the control points for a quadratic segment from point a to point c passing through point b.
* @param a The segments's first point
* @param b The point to curve through
* @param c The segment's end point
*/
export function getQuadraticControlPoints(
a: { x: number; y: number },
b: { x: number; y: number },
c: { x: number; y: number }
) {
return {
a,
c1: {
x: b.x + (b.x - (a.x + c.x) * 0.5),
y: b.y + (b.y - (a.y + c.y) * 0.5)
},
c
};
}
@steveruizok
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment