2016-02-26 57 views
13

由於我以前的approach似乎不起作用,解決方案會相當複雜,所以我決定嘗試另一種方法,可能會更簡單一些。用六邊形填充圓(不同的方法)

這次,在代碼繪製任何六邊形之前,它必須確定有多少行和列可以放入預定義的圓中,然後根據此結果開始繪製所有六邊形。

到目前爲止,這是一種工作,但正如我以前的做法一樣,有時候這些格子是重疊的,或者在圓的下半部分留下了大的空隙。

另一個問題是,如何將這些六邊形格式化爲網格?

請注意,畫布下方有一個小滑塊,可讓您增加/減小圓的半徑並重新繪製六邊形。

var c_el = document.getElementById("myCanvas"); 
 
var ctx = c_el.getContext("2d"); 
 

 
var canvas_width = c_el.clientWidth; 
 
var canvas_height = c_el.clientHeight; 
 
var circle = { 
 
\t r: 120, /// radius 
 
\t pos: { 
 
\t \t x: (canvas_width/2), 
 
\t \t y: (canvas_height/2) 
 
\t } 
 
} 
 

 
var hexagon = { 
 
\t r: 20, 
 
\t pos:{ 
 
\t \t x: 0, 
 
\t \t y: 0 
 
\t } 
 
} 
 

 
var hex_w = hexagon.r * 2; 
 
var hex_h = Math.floor(Math.sqrt(3) * hexagon.r); 
 
var hex_s = (3/2) * hexagon.r; 
 

 
fill_CircleWithHex(circle); 
 

 
function fill_CircleWithHex(circle){ 
 
\t drawCircle(circle); 
 
\t 
 
\t var c_h = circle.r * 2; /// circle height //// 
 
\t var c_w = c_h; //// circle width ///// 
 
\t 
 
\t var max_hex_H = Math.round(c_h/hex_h); 
 
\t 
 
\t var row_sizes = [] 
 
\t for(var row= 0; row< max_hex_H; row++){ 
 
\t \t 
 
\t \t var d = circle.r - (row* hex_h); //// distance from circle's center to the row's chord //// 
 
\t \t var c = 2 * (Math.sqrt((circle.r*circle.r) - (d * d))); /// length of the row's chord //// 
 
\t \t var row_length = Math.floor(c/(hexagon.r * 3)); 
 
\t \t row_sizes.push(row_length ) 
 
\t } 
 
\t 
 
\t console.log("circle_r : "+circle.r); 
 
\t console.log("hex_r : "+hexagon.r); 
 
\t console.log("max_hex_H : "+max_hex_H); 
 
\t console.log("max_hex_W : ", row_sizes) 
 

 
\t for(var row = 0; row < row_sizes.length; row++){ 
 
\t \t var max_hex_W = row_sizes[row]; 
 
\t \t 
 
\t \t var x_offset = Math.floor((c_w - (max_hex_W * hex_w))/2); 
 
\t \t 
 
\t \t for(var col = 1; col < max_hex_W; col++){ 
 
\t \t \t hexagon.pos.x = (col * hex_w) + (circle.pos.x - circle.r) + x_offset ; 
 
\t \t \t hexagon.pos.y = (row * hex_h) + (circle.pos.y - circle.r); 
 
\t \t \t ctx.fillText(row+""+col, hexagon.pos.x - 6, hexagon.pos.y+4); 
 
\t \t \t drawHexagon(hexagon) 
 
\t \t } 
 
\t } 
 
} 
 

 
function drawHexagon(hex){ 
 
\t var angle_deg, angle_rad, cor_x, cor_y; 
 
\t ctx.beginPath(); 
 
\t for(var c=0; c <= 5; c++){ 
 
\t \t angle_deg = 60 * c; 
 
\t \t angle_rad = (Math.PI/180) * angle_deg; 
 
\t \t cor_x = hex.r * Math.cos(angle_rad); //// corner_x /// 
 
\t \t cor_y = hex.r* Math.sin(angle_rad); //// corner_y /// 
 
\t \t if(c === 0){ 
 
\t \t \t ctx.moveTo(hex.pos.x+ cor_x, hex.pos.y+cor_y); 
 
\t \t }else{ 
 
\t \t \t ctx.lineTo(hex.pos.x+cor_x, hex.pos.y+cor_y); 
 
\t \t } 
 
\t } 
 
\t ctx.closePath(); 
 
\t ctx.stroke(); 
 
} 
 

 
function drawCircle(circle){ 
 
\t ctx.beginPath(); 
 
\t ctx.arc(circle.pos.x, circle.pos.y, circle.r, 0, 2 * Math.PI); 
 
\t ctx.stroke(); 
 
} 
 

 

 
    $(function() { 
 
    $("#slider").slider({ 
 
\t \t max: 200, 
 
\t \t min:0, 
 
\t \t value:100, 
 
\t \t create: function(event, ui) { 
 
\t \t \t $("#value").html($(this).slider('value')); 
 
\t \t }, 
 
\t \t change: function(event, ui) { 
 
\t \t \t $("#value").html(ui.value); 
 
\t \t }, 
 
\t \t slide: function(event, ui){ 
 
\t \t \t $("#value").html(ui.value); 
 
\t \t \t circle.r = ui.value; 
 
\t \t \t ctx.clearRect(0,0, canvas_width, canvas_height); 
 
\t \t \t fill_CircleWithHex(circle); 
 
\t \t } 
 
\t }); 
 
    });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> 
 
<link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.css" rel="stylesheet"/> 
 
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script> 
 

 
<canvas id="myCanvas" width="350" height="250" style="border:1px solid #d3d3d3;"> </canvas> 
 
<div style="width: 200px; height: 40px;"> 
 
\t <div id="slider" style="position:relative; width: 150px; top: 4px;float: left;"></div> <div id="value" style="float: left;"> 0 </div> 
 
</div>

+0

我很困惑。給定的六邊形和圓的大小?你能更準確地陳述問題嗎?什麼是硬約束和你想要最大化什麼。 –

+0

硬約束是圓的大小,在此基礎上生成六邊形網格。 – Alexus

+0

它只是看起來像一個六邊形圖案?六角形是否必須編號?我正在考慮應用智能CSS背景來生成六角形樣式。 – Paul

回答

6

下解決了中心的圓的中點常規蜂窩結構的包裝問題。常規的意思是:

  • 所有六邊形的集合在圍繞圓中心60度旋轉下是對稱的。

單獨六邊形的座標表示六邊形殼的順序號,從中央開始計數,順時針順序號從正午開始計數。

隨着圓圈變寬,新的六邊形殼體不一定會作爲整體填充。儘管填充外殼的自由度部分產生了改進的解決方案,但仍不是最佳的。除了60度(即120和180度)之外的其他角度,將規律性放鬆到旋轉對稱性將允許更高的圓圈內部覆蓋範圍。

我將研究這個代碼的下一個版本的背後的數學(並可能找到一個定理來證明圓的中點周圍的旋轉對稱是最優性的必要條件)。

var c_el; 
 
var ctx; 
 
var canvas_width; 
 
var canvas_height; 
 
var circle; 
 
var hexagon; 
 
var hex_w; 
 
var hex_h; 
 
var hex_s; 
 
var delta; 
 

 
function drawHexagonAt (po_ctr_hex, pn_circle, pn_sector) { 
 
    var cur 
 
     ; 
 
     
 
    cur = { x: po_ctr_hex.x - 0.5 * hexagon.r, y: po_ctr_hex.y - delta }; 
 
    
 
    ctx.beginPath(); 
 
    ctx.moveTo(cur.x, cur.y); 
 
    cur.x = cur.x + hexagon.r; 
 
    cur.y = cur.y; 
 
    ctx.lineTo(cur.x, cur.y); 
 
    cur.x = cur.x + hexagon.r/2; 
 
    cur.y = cur.y + delta; 
 
    ctx.lineTo(cur.x, cur.y); 
 
    cur.x = cur.x - hexagon.r/2; 
 
    cur.y = cur.y + delta; 
 
    ctx.lineTo(cur.x, cur.y); 
 
    cur.x = cur.x - hexagon.r; 
 
    cur.y = cur.y; 
 
    ctx.lineTo(cur.x, cur.y); 
 
    cur.x = cur.x - hexagon.r/2; 
 
    cur.y = cur.y - delta; 
 
    ctx.lineTo(cur.x, cur.y); 
 
    cur.x = cur.x + hexagon.r/2; 
 
    cur.y = cur.y - delta; 
 
    ctx.lineTo(cur.x, cur.y); 
 
\t ctx.closePath(); 
 
\t ctx.stroke(); 
 

 
    cur.x = cur.x + hexagon.r/2; 
 
    cur.y = cur.y + delta; 
 
\t ctx.fillText(pn_circle + "/" + pn_sector, cur.x-6, cur.y+4); 
 
} // drawHexagonAt 
 

 
function fill_CircleWithHex(circle){ 
 
\t drawCircle(circle); 
 
\t 
 
\t var radacc2; 
 
\t var iter = 0; 
 
\t var sector = 0; 
 
\t var i, j; 
 
\t var ctr  = { x: circle.pos.x , y: circle.pos.y }; 
 
\t var cur  = { x: 0   , y: 0 }; 
 
\t 
 
\t delta = Math.floor(Math.sqrt(3) * 0.5 * hexagon.r); 
 
    radacc2 = hexagon.r * hexagon.r; 
 
\t while ((radacc2 < circle.r * circle.r)) { 
 
\t  cur.x = ctr.x; 
 
\t  cur.y = ctr.y - iter * 2 * delta; 
 
\t  
 
\t  if (iter === 0) { 
 
\t   drawHexagonAt (cur, 0, 0); 
 
\t  } 
 
\t  else { 
 
    \t  for (var i=0; i < 6; i++) { 
 
    \t   // j-loops -- next honeycomb 
 
    \t   sector = 0; 
 
    \t   for (var j=0; j < iter; j++) { 
 
    \t    cur.x = cur.x + 1.5 * hexagon.r; 
 
    \t    cur.y = cur.y + delta; 
 
    \t    drawHexagonAt (cur, iter, sector++); 
 
    \t   } 
 
    \t   for (var j=0; j < iter; j++) { 
 
    \t    cur.x = cur.x; 
 
    \t    cur.y = cur.y + 2 * delta; 
 
    \t    drawHexagonAt (cur, iter, sector++); 
 
    \t   } 
 
    \t   for (var j=0; j < iter; j++) { 
 
    \t    cur.x = cur.x - 1.5 * hexagon.r; 
 
    \t    cur.y = cur.y + delta; 
 
    \t    drawHexagonAt (cur, iter, sector++); 
 
    \t   } 
 
    \t   for (var j=0; j < iter; j++) { 
 
    \t    cur.x = cur.x - 1.5 * hexagon.r; 
 
    \t    cur.y = cur.y - delta; 
 
    \t    drawHexagonAt (cur, iter, sector++); 
 
    \t   } 
 
    \t   for (var j=0; j < iter; j++) { 
 
    \t    cur.x = cur.x; 
 
    \t    cur.y = cur.y - 2 * delta; 
 
    \t    drawHexagonAt (cur, iter, sector++); 
 
    \t   } 
 
    \t   for (var j=0; j < iter; j++) { 
 
    \t    cur.x = cur.x + 1.5 * hexagon.r; 
 
    \t    cur.y = cur.y - delta; 
 
    \t    drawHexagonAt (cur, iter, sector++); 
 
    \t   } 
 
    \t  } // i-loop -- meta-honeycomb 
 
    \t } // if -- Iteration 1 vs. n > 1 
 
    \t  
 
    \t  // radacc update 
 
    \t  iter++; 
 
     radacc2 = ((2*iter + 1) * delta) * ((2*iter + 1) * delta) + hexagon.r * hexagon.r/4; 
 
    } // while -- komplette Shells 
 
    
 
    // 
 
    // Partielle Shells 
 
    // 
 
    var proceed; 
 
    do { 
 
\t  cur.x = ctr.x; 
 
\t  cur.y = ctr.y - iter * 2 * delta; 
 
     proceed = false; 
 

 
\t  for (var i=0; i < 6; i++) { 
 
\t   // j-loops -- next honeycomb 
 
\t   sector = 0; 
 
\t   for (var j=0; j < iter; j++) { 
 
\t    cur.x = cur.x + 1.5 * hexagon.r; 
 
\t    cur.y = cur.y + delta; 
 
\t    sector++ 
 
\t    if (Math.sqrt ((cur.x - ctr.x) * (cur.x - ctr.x) + (cur.y - ctr.y) * (cur.y - ctr.y)) + hexagon.r < circle.r) { 
 
\t     drawHexagonAt (cur, iter, sector); 
 
\t     proceed = true; 
 
\t    } 
 
\t   } 
 
\t   for (var j=0; j < iter; j++) { 
 
\t    cur.x = cur.x; 
 
\t    cur.y = cur.y + 2 * delta; 
 
\t    sector++ 
 
\t    if (Math.sqrt ((cur.x - ctr.x) * (cur.x - ctr.x) + (cur.y - ctr.y) * (cur.y - ctr.y)) + hexagon.r < circle.r) { 
 
\t     drawHexagonAt (cur, iter, sector); 
 
\t     proceed = true; 
 
\t    } 
 
\t   } 
 
\t   for (var j=0; j < iter; j++) { 
 
\t    cur.x = cur.x - 1.5 * hexagon.r; 
 
\t    cur.y = cur.y + delta; 
 
\t    sector++ 
 
\t    if (Math.sqrt ((cur.x - ctr.x) * (cur.x - ctr.x) + (cur.y - ctr.y) * (cur.y - ctr.y)) + hexagon.r < circle.r) { 
 
\t     drawHexagonAt (cur, iter, sector); 
 
\t     proceed = true; 
 
\t    } 
 
\t   } 
 
\t   for (var j=0; j < iter; j++) { 
 
\t    cur.x = cur.x - 1.5 * hexagon.r; 
 
\t    cur.y = cur.y - delta; 
 
\t    sector++ 
 
\t    if (Math.sqrt ((cur.x - ctr.x) * (cur.x - ctr.x) + (cur.y - ctr.y) * (cur.y - ctr.y)) + hexagon.r < circle.r) { 
 
\t     drawHexagonAt (cur, iter, sector); 
 
\t     proceed = true; 
 
\t    } 
 
\t   } 
 
\t   for (var j=0; j < iter; j++) { 
 
\t    cur.x = cur.x; 
 
\t    cur.y = cur.y - 2 * delta; 
 
\t    sector++ 
 
\t    if (Math.sqrt ((cur.x - ctr.x) * (cur.x - ctr.x) + (cur.y - ctr.y) * (cur.y - ctr.y)) + hexagon.r < circle.r) { 
 
\t     drawHexagonAt (cur, iter, sector); 
 
\t     proceed = true; 
 
\t    } 
 
\t   } 
 
\t   for (var j=0; j < iter; j++) { 
 
\t    cur.x = cur.x + 1.5 * hexagon.r; 
 
\t    cur.y = cur.y - delta; 
 
\t    sector++ 
 
\t    if (Math.sqrt ((cur.x - ctr.x) * (cur.x - ctr.x) + (cur.y - ctr.y) * (cur.y - ctr.y)) + hexagon.r < circle.r) { 
 
\t     drawHexagonAt (cur, iter, sector); 
 
\t     proceed = true; 
 
\t    } 
 
\t   } 
 
\t  } // i-loop -- meta-honeycomb 
 
\t  
 
\t  iter++; 
 
    } while (proceed && (iter < 15));  
 
    
 
} // fill_CircleWithHex 
 

 

 
function drawCircle(circle){ 
 
\t ctx.beginPath(); 
 
\t ctx.arc(circle.pos.x, circle.pos.y, circle.r, 0, 2 * Math.PI); 
 
\t ctx.stroke(); 
 
} 
 

 

 
    $(function() { 
 
    $("#slider").slider({ 
 
\t \t max: 200, 
 
\t \t min:0, 
 
\t \t value:100, 
 
\t \t create: function(event, ui) { 
 
\t \t \t $("#value").html($(this).slider('value')); 
 
\t \t }, 
 
\t \t change: function(event, ui) { 
 
\t \t \t $("#value").html(ui.value); 
 
\t \t }, 
 
\t \t slide: function(event, ui){ 
 
\t \t \t $("#value").html(ui.value); 
 
\t \t \t circle.r = ui.value; 
 
\t \t \t ctx.clearRect(0,0, canvas_width, canvas_height); 
 
\t \t \t fill_CircleWithHex(circle); 
 
\t \t } 
 
\t }); 
 
    }); 
 
    
 
$(document).ready(function() { 
 
    c_el = document.getElementById("myCanvas"); 
 
    ctx = c_el.getContext("2d"); 
 
    
 
    canvas_width = c_el.clientWidth; 
 
    canvas_height = c_el.clientHeight; 
 

 
    circle = { 
 
    \t r: 120, /// radius 
 
    \t pos: { 
 
    \t \t x: (canvas_width/2), 
 
    \t \t y: (canvas_height/2) 
 
    \t } 
 
    }; 
 
    
 
    hexagon = { 
 
    \t r: 20, 
 
    \t pos:{ 
 
    \t \t x: 0, 
 
    \t \t y: 0 
 
    \t } 
 
    }; 
 
    
 
    hex_w = hexagon.r * 2; 
 
    hex_h = Math.floor(Math.sqrt(3) * hexagon.r); 
 
    hex_s = (3/2) * hexagon.r; 
 
    
 
    fill_CircleWithHex(circle); 
 
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> 
 
<link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.css" rel="stylesheet"/> 
 
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script> 
 

 
<canvas id="myCanvas" width="350" height="250" style="border:1px solid #d3d3d3;"> </canvas> 
 
<div style="width: 200px; height: 40px;"> 
 
<div id="slider" style="position:relative; width: 150px; top: 4px;float: left;"></div> <div id="value" style="float: left;"> 0 </div> 
 
</div>

+0

到目前爲止最好的答案,雖然比我想象的要複雜得多......那麼簡化它有可能嗎? (我指的是在上面的例子中使用的for循環的數量。) – Alexus

+0

最內層的6個循環可以在switch語句的cpost中摺疊6個case來區分要繪製的下一個六邊形的中點的計算。同樣,部分外殼的代碼可以摺疊到第一個循環中。但是,目前最內六邊形的中點和圓圈總是重合。放寬這將允許一個更好的解決方案,但代碼結構可能需要適應無論如何。今晚我會看看這個。 – collapsar

+3

不錯的工作。可以將這些內部循環變成函數調用:https://jsfiddle.net/7ekv24ab/簡化一下。 – tiffon

0

花在你的代碼一些時間來收拾十六進制的。它不完美,並且肯定有更好的方法來做到這一點。檢查一下,如果有幫助,或者如果你可以修復十六進制的出界[現在,計算row_sizes有一個問題]。也許我可以在有空的時候再看一遍,或者我們可以通過其他方式來做到這一點。

var c_el = document.getElementById("myCanvas"); 
 
var ctx = c_el.getContext("2d"); 
 

 
var canvas_width = c_el.clientWidth; 
 
var canvas_height = c_el.clientHeight; 
 
var circle = { 
 
\t r: 120, /// radius 
 
\t pos: { 
 
\t \t x: (canvas_width/2), 
 
\t \t y: (canvas_height/2) 
 
\t } 
 
} 
 

 
var hexagon = { 
 
\t r: 20, 
 
\t pos:{ 
 
\t \t x: 0, 
 
\t \t y: 0 
 
\t } 
 
} 
 

 
var hex_w = hexagon.r * 3; /// added spacing 
 
var hex_h = Math.floor(Math.sqrt(3) * hexagon.r/2); /// added spacing 
 
var hex_s = (3/2) * hexagon.r; 
 

 
var hex_width = 33.4; //based on r = 20 
 

 
fill_CircleWithHex(circle); 
 

 
function fill_CircleWithHex(circle){ 
 
\t drawCircle(circle); 
 
\t 
 
\t var c_h = circle.r * 2; /// circle height //// 
 
\t var c_w = c_h; //// circle width ///// 
 

 
\t var max_hex_H = Math.round(c_h/(hex_h )); 
 
\t var row_sizes = [] 
 
    
 
\t for(var col= 0; col < max_hex_H; col++){ 
 
\t \t 
 
\t \t var d = circle.r - (col * hex_h); //// distance from circle's center to the row's chord //// 
 
\t \t var c = 2 * (Math.sqrt((circle.r*circle.r) - (d * d))); /// length of the row's chord //// 
 
\t \t 
 
\t \t row_sizes.push(Math.ceil(c/(hexagon.r * 3))) 
 
\t } 
 

 
\t for(var row = 0; row < row_sizes.length; row++){ 
 
\t \t var max_hex_W = row_sizes[row]; 
 
    console.log(hex_w); 
 
\t \t var x_offset = Math.floor((c_w - (max_hex_W * hex_w))) + row%2 * hex_width - hex_width/2; // changed offset to define a zig zag 
 
\t \t 
 
\t \t for(var col = 1; col < max_hex_W; col++){ 
 
\t \t \t hexagon.pos.x = (col * hex_w) + (circle.pos.x - circle.r) + x_offset ; 
 
\t \t \t hexagon.pos.y = (row * 17.3) + (circle.pos.y - circle.r) ; 
 
\t \t \t ctx.fillText(row+""+col, hexagon.pos.x - 6, hexagon.pos.y+4); 
 
\t \t \t drawHexagon(hexagon) 
 
\t \t } 
 
\t } 
 
} 
 

 
function drawHexagon(hex){ 
 
\t var angle_deg, angle_rad, cor_x, cor_y; 
 
\t ctx.beginPath(); 
 
    
 
\t for(var c=0; c <= 5; c++){ 
 
\t \t angle_deg = 60 * c; 
 
\t \t angle_rad = (Math.PI/180) * angle_deg; 
 
\t \t cor_x = hex.r * Math.cos(angle_rad); //// corner_x /// 
 
\t \t cor_y = hex.r* Math.sin(angle_rad); //// corner_y /// 
 
\t \t if(c === 0){ 
 
\t \t \t ctx.moveTo(hex.pos.x+ cor_x, hex.pos.y+cor_y); 
 
\t \t }else{ 
 
\t \t \t ctx.lineTo(hex.pos.x+cor_x, hex.pos.y+cor_y); 
 
\t \t } 
 
\t } 
 
\t ctx.closePath(); 
 
\t ctx.stroke(); 
 
} 
 

 
function drawCircle(circle){ 
 
\t ctx.beginPath(); 
 
\t ctx.arc(circle.pos.x, circle.pos.y, circle.r, 0, 2 * Math.PI); 
 
\t ctx.stroke(); 
 
} 
 

 

 
    $(function() { 
 
    $("#slider").slider({ 
 
\t \t max: 200, 
 
\t \t min:0, 
 
\t \t value:100, 
 
\t \t create: function(event, ui) { 
 
\t \t \t $("#value").html($(this).slider('value')); 
 
\t \t }, 
 
\t \t change: function(event, ui) { 
 
\t \t \t $("#value").html(ui.value); 
 
\t \t }, 
 
\t \t slide: function(event, ui){ 
 
\t \t \t $("#value").html(ui.value); 
 
\t \t \t circle.r = ui.value; 
 
\t \t \t ctx.clearRect(0,0, canvas_width, canvas_height); 
 
\t \t \t fill_CircleWithHex(circle); 
 
\t \t } 
 
\t }); 
 
    });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> 
 
<link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.css" rel="stylesheet"/> 
 
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script> 
 

 
<canvas id="myCanvas" width="350" height="250" style="border:1px solid #d3d3d3;"> </canvas> 
 
<div style="width: 200px; height: 40px;"> 
 
\t <div id="slider" style="position:relative; width: 150px; top: 4px;float: left;"></div> <div id="value" style="float: left;"> 0 </div> 
 
</div>

+0

由於您的解決方案違反了限制約束而降低了投票率。 – collapsar

0

簡短的回答:有沒有簡單的方法來做到這一點。你有太多的特殊情況。爲了說明這一點,從1,2,3,4,6和7個六邊形開始簡單,繪製適合它們的最小圓圈,並記下圓圈中心的最終位置。

正如你所看到的,圓的中心移動了很多。它可以在六角形的中間,頂點或交叉點處結束。

從此它只會變得更糟。

我能找到的最接近的問題是this page

編輯:你可能想看看以下博客頁面的六邊形編程非常全面的待遇。

http://www.redblobgames.com/grids/hexagons/