Created
September 14, 2013 02:38
-
-
Save choppingblock/6558389 to your computer and use it in GitHub Desktop.
Have a quadratic bezier curve, need to figure out an angle along the way. This should work quite well, easy to convert to JavaScript.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static function quadraticBezierAngle(value:Number, anchor1:Point, anchor2:Point, control:Point):Number { | |
var uc:Number = 1 - value; | |
var dx:Number = (uc * control.x + value * anchor2.x) - (uc * anchor1.x + value * control.x); | |
var dy:Number = (uc * control.y + value * anchor2.y) - (uc * anchor1.y + value * control.y); | |
return Math.atan2(dy, dx); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If anyone wants the JavaScript version: