我正在尋找算法來計算落在矩形區域內的六邊形,無論是否裁剪。在矩形內計算六邊形?
我瞭解以下內容:
rectWidth = 1280;
rectHeight = 720;
hexRadius = 50; // middle to corner
hexHeight = hexRadius * 2;
hexShortSpan = hexRadius * 0.5;
hexLongSpan = cos(radians(30)) * hexRadius;
hexWidth = hexLongSpan * 2;
hexSide = hexRadius + hexShortSpan; // this is not a side but side + shortSpan for horizontal rows
想不通國防部運算得到正確的結果。
float A = rectWidth/hexWidth;
float B = rectHeight/hexSide;
float hexCount = A * B +????;
// etc. etc. not sure about the rest...
羅布
下面是一個圖片...
http://moggach.com/media/img/hexGrid.jpg
你對六角形定位有什麼瞭解?你有'錨'六角?什麼是定位?像我畫或旋轉? – Ante
不知道你'錨'的意思是什麼'尖',即。旋轉 – mogga
帶錨我的意思是在矩形中定義一個六邊形的位置。它可以是輸入參數,也可以有一些請求。在圖片中,矩形的左下角也是六角形的「左下角」。所有配置都適用嗎? – Ante