Skip to content

Instantly share code, notes, and snippets.

@rizo
Last active December 13, 2015 23:08
Show Gist options
  • Save rizo/4988949 to your computer and use it in GitHub Desktop.
Save rizo/4988949 to your computer and use it in GitHub Desktop.
CGPoint OGCubicBezierTangent(CGFloat t, CGPoint P[static 4])
{
CGFloat a = -3 * (1 - t) * (1 - t),
b = 3 * (t - 1) * (3 * t - 1),
c = 3 * t * (2 - 3t),
d = 3 * t * t;
return (CGPoint) {
(a * P[0].x) + (b * P[1].x) + (c * P[2].x) + (d * P[3].x),
(a * P[0].y) + (b * P[1].y) + (c * P[2].y) + (d * P[3].y)
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment