Created
June 16, 2013 05:32
-
-
Save turusuke/5790883 to your computer and use it in GitHub Desktop.
CreateJSのPointクラスでオブジェクト間の角度を取得できるメソッド
getDigree(度数法)とgetRadian(ラジアン)を利用できるようにしたプラグイン。
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
/** | |
* User: turusuke | |
* Date: 13/06/16 | |
* version: 0.1 | |
*/ | |
(function(window) { | |
if (!createjs || !createjs.Point) { | |
return; | |
} | |
var toDigree = 180 / Math.PI; | |
/* オブジェクト間の角度を度数法で返す */ | |
createjs.Point.getDigree = function(pt1, pt2){ | |
return Math.atan2( (pt2.y - pt1.y),(pt2.x - pt1.x) ) * toDigree; | |
} | |
/* オブジェクト間の角度をラジアンで返す */ | |
createjs.Point.getRadian = function(pt1, pt2){ | |
return Math.atan2( (pt2.y - pt1.y),(pt2.x - pt1.x) ); | |
} | |
}(window)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment