Skip to content

Instantly share code, notes, and snippets.

@ikekou
Last active December 17, 2015 05:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ikekou/5559127 to your computer and use it in GitHub Desktop.
Save ikekou/5559127 to your computer and use it in GitHub Desktop.
[Math][JavaScript][CoffeeScript]2次ベジェ曲線の中間点の座標を求める
#2次ベジェの中間点の座標を求める
#a1はアンカーポイント1
#c1はアンカーポイント1から出るコントロールポイント
#c2はアンカーポイント2から出るコントロールポイント
#a2はアンカーポイント2
#tは分割する割合、0~1の範囲
getQuadraticBezierPoint:(a1x,a1y,cx,cy,a2x,a2y,t)->
tp = 1 - t
x = t*t*a2x + 2*t*tp*cx + tp*tp*a1x
y = t*t*a2y + 2*t*tp*cy + tp*tp*a1y
return [x,y]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment