
Код:
public function calcVertex(o:BasicObject):Array{
var w_2:Number = o.dim_w/2;//полуширина
var h_2:Number = o.dim_h/2;//полувысота
var r:Number = Math.sqrt(w_2*w_2 + h_2*h_2);//полудиаметр
var dir:Number = Math.acos(w_2/r)*(180/Math.PI);//угол
var p:Array = new Array();//вершины обекта
p[0] = new Vector();
p[0].x = o.x+Math.cos((o.rotation-dir)*(Math.PI/180))*r;
p[0].y = o.y+Math.sin((o.rotation-dir)*(Math.PI/180))*r;
p[1] = new Vector();
p[1].x = o.x+Math.cos((o.rotation-(180-dir*2)-dir)*(Math.PI/180))*r;
p[1].y = o.y+Math.sin((o.rotation-(180-dir*2)-dir)*(Math.PI/180))*r;
p[2] = new Vector();
p[2].x = o.x+Math.cos((o.rotation-(180+dir*2)+dir)*(Math.PI/180))*r;
p[2].y = o.y+Math.sin((o.rotation-(180+dir*2)+dir)*(Math.PI/180))*r;
p[3] = new Vector();
p[3].x = o.x+Math.cos((o.rotation+dir)*(Math.PI/180))*r;
p[3].y = o.y+Math.sin((o.rotation+dir)*(Math.PI/180))*r;
return p;
}
код писал давно