二つの線分の交差する角度を求める

point1が交点。

var point0:Point, point1:Point, point2:Point;
point0 = new Point( 50, 100 );
point1 = new Point( 200, 200 );
point2 = new Point( 100, 300 );

point0.offset( -point1.x, -point1.y );
point2.offset( -point1.x, -point1.y );

var vector0:Vector3D, vector1:Vector3D;
vector0 = new Vector3D( point0.x, point0.y, 0 );
vector1 = new Vector3D( point2.x, point2.y, 0 );
var angle:Number = Vector3D.angleBetween( vector0, vector1 ); //このときはまだラジアン
var d:Number = angle * 180/Math.PI;

もっと早い書き方があるような気がするが、なんとか算出できた。

2010年 7月 22日 | Posted in Flash / ActionScript3.0
タグ:
まだコメントはありません。

コメントする

XHTML: 使用可能タグ: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>