我有以下六角形網格並試圖從中心計算度到每個邊緣六邊形(淺藍色): 如何獲得正確表示的極座標?
藍色突出顯示的十六進制爲0度正確,以及象限(右下)是正確的。這裏是我的角度計算方法:
private static function calculateAngle(hex1:Hexagon, hex2:Hexagon):Number {
// hex1 is always passed in as the grid center or start
var diffY:Number = Math.abs(hex2.center.y) - Math.abs(hex1.center.y);
var diffX:Number = Math.abs(hex2.center.x) - Math.abs(hex1.center.x);
var radians:Number = Math.atan(diffY/diffX);
return radians * 180/Math.PI;
}
爲什麼剩餘角度(每個六角形中的文本)不正確?
「中心」屬性是「點」對象嗎? – null
@null:是'center'是一個'Point'對象。 – IAbstract
以爲在['Point'](http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/geom/Point.html)中有角度的吸氣劑,但只有一個靜態方法polar(len:Number,angle:Number):Point'從極座標構造'Point'。沒有建立一個現有的極座標的方式。 – null