<?xml version='1.0' encoding="utf-8"?>
      <rss version='2.0'>
      <channel>
      <title>Форум на Исходниках.RU</title>
      <link>https://forum.sources.ru</link>
      <description>Форум на Исходниках.RU</description>
      <generator>Форум на Исходниках.RU</generator>
  	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=249891&amp;view=findpost&amp;p=2070991</guid>
        <pubDate>Wed, 17 Sep 2008 18:37:08 +0000</pubDate>
        <title>Определение принадлежности точки n-му шестиугольнику</title>
        <link>https://forum.sources.ru/index.php?showtopic=249891&amp;view=findpost&amp;p=2070991</link>
        <description><![CDATA[Stud555: Решил проблему. Ошибка была в том, что номера соседних квадратов при 6-ти угольной системе, в четных и нечетных столбцах разные.<br><br>Если надо, могу полученный код скинуть.]]></description>
        <author>Stud555</author>
        <category>Алгоритмы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=249891&amp;view=findpost&amp;p=2070819</guid>
        <pubDate>Wed, 17 Sep 2008 14:31:42 +0000</pubDate>
        <title>Определение принадлежности точки n-му шестиугольнику</title>
        <link>https://forum.sources.ru/index.php?showtopic=249891&amp;view=findpost&amp;p=2070819</link>
        <description><![CDATA[MBo: Наверно, ошибки в алгоритме<br>Гексагональное поле отличается от квадратного тем, что ячейки не 4-х связные, а 6- связные, т.е каждая имеет 6 соседей по ребрам, и ты каких-то соседей упускаешь]]></description>
        <author>MBo</author>
        <category>Алгоритмы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=249891&amp;view=findpost&amp;p=2070760</guid>
        <pubDate>Wed, 17 Sep 2008 13:41:52 +0000</pubDate>
        <title>Определение принадлежности точки n-му шестиугольнику</title>
        <link>https://forum.sources.ru/index.php?showtopic=249891&amp;view=findpost&amp;p=2070760</link>
        <description><![CDATA[Stud555: Точно.  :D  Ни как&#33; <br>
<br>
<span class="tag-color tag-color-named" data-value="gray" style="color: gray"><span class='tag-size' data-value='7' style='font-size:7pt;'>Добавлено <time class="tag-mergetime" datetime="2008-09-17T13:47:43+00:00">17.09.08, 13:47</time></span></span><br>
Тогда еще вопрос, поиск пути.<br>
<br>
Работаю по волновому алгоритму. Когда поле было квадратное, проблем небыло, но вот на 6-ти гранном не получается. Переодически выпадают клетки из пути, т.е. когда просчет идет ячейки с координатами (х+1,у+1) и (х-1,у-1). Другие клетки(х,у-1),(х+1,0) без проблем.<br>
<br>
Почему такая проблема?]]></description>
        <author>Stud555</author>
        <category>Алгоритмы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=249891&amp;view=findpost&amp;p=2070628</guid>
        <pubDate>Wed, 17 Sep 2008 11:31:13 +0000</pubDate>
        <title>Определение принадлежности точки n-му шестиугольнику</title>
        <link>https://forum.sources.ru/index.php?showtopic=249891&amp;view=findpost&amp;p=2070628</link>
        <description><![CDATA[MBo: А как 8-угольниками замостить плоскость?]]></description>
        <author>MBo</author>
        <category>Алгоритмы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=249891&amp;view=findpost&amp;p=2070610</guid>
        <pubDate>Wed, 17 Sep 2008 11:10:51 +0000</pubDate>
        <title>Определение принадлежности точки n-му шестиугольнику</title>
        <link>https://forum.sources.ru/index.php?showtopic=249891&amp;view=findpost&amp;p=2070610</link>
        <description><![CDATA[Stud555: <strong class='tag-b'>MBo</strong><br>
А не подскажешь этот алгоритм для 8-ми угольника?]]></description>
        <author>Stud555</author>
        <category>Алгоритмы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=249891&amp;view=findpost&amp;p=2069474</guid>
        <pubDate>Mon, 15 Sep 2008 20:08:04 +0000</pubDate>
        <title>Определение принадлежности точки n-му шестиугольнику</title>
        <link>https://forum.sources.ru/index.php?showtopic=249891&amp;view=findpost&amp;p=2069474</link>
        <description><![CDATA[Stud555: <span class="tag-color tag-color-named" data-value="red" style="color: red"><span class='tag-size' data-value='21' style='font-size:21pt;'>СПАСИБО</span></span>&#33;&#33;&#33;]]></description>
        <author>Stud555</author>
        <category>Алгоритмы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=249891&amp;view=findpost&amp;p=2069115</guid>
        <pubDate>Mon, 15 Sep 2008 12:47:34 +0000</pubDate>
        <title>Определение принадлежности точки n-му шестиугольнику</title>
        <link>https://forum.sources.ru/index.php?showtopic=249891&amp;view=findpost&amp;p=2069115</link>
        <description><![CDATA[MBo: Немного другое рисование поля<br>
<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">const</div><div class="code_line">&nbsp;&nbsp;Edge = 80;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp;HalfEdge = Edge div 2;</div><div class="code_line">&nbsp;&nbsp;HalfHgt = Edge * 1732 div 2000; //Sqrt(3)/2</div><div class="code_line">&nbsp;&nbsp;Hgt = HalfHgt * 2;</div><div class="code_line">&nbsp;&nbsp;Wdt = 2 * Edge;</div><div class="code_line">&nbsp;&nbsp;CellWdt = 3 * HalfEdge;</div><div class="code_line">&nbsp;&nbsp;Shift = Edge;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;</div><div class="code_line">function TForm6.FindHexCell(x, y: Integer): TPoint;</div><div class="code_line">var</div><div class="code_line">&nbsp;&nbsp;nx, remx, ny, remy, tmp: Integer;</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp;x := x - Shift + HalfEdge;</div><div class="code_line">&nbsp;&nbsp;y := y - Shift + HalfHgt;</div><div class="code_line">&nbsp;&nbsp;nx := x div CellWdt;</div><div class="code_line">&nbsp;&nbsp;remx := ((x mod CellWdt) - CellWdt) * HalfHgt;</div><div class="code_line">&nbsp;&nbsp;tmp := -1;</div><div class="code_line">&nbsp;&nbsp;if Odd(nx) then begin</div><div class="code_line">&nbsp;&nbsp; &nbsp;y := y - HalfHgt;</div><div class="code_line">&nbsp;&nbsp; &nbsp;Inc(tmp);</div><div class="code_line">&nbsp;&nbsp;end;</div><div class="code_line">&nbsp;&nbsp;ny := y div Hgt;</div><div class="code_line">&nbsp;&nbsp;remy := ((y mod Hgt) - HalfHgt) * HalfEdge;</div><div class="code_line">&nbsp;&nbsp;if remy &#60; remx then begin</div><div class="code_line">&nbsp;&nbsp; &nbsp;Inc(nx);</div><div class="code_line">&nbsp;&nbsp; &nbsp;Inc(ny, tmp);</div><div class="code_line">&nbsp;&nbsp;end;</div><div class="code_line">&nbsp;&nbsp;if remy &#62; -remx then begin</div><div class="code_line">&nbsp;&nbsp; &nbsp;Inc(nx);</div><div class="code_line">&nbsp;&nbsp; &nbsp;Inc(ny, tmp + 1);</div><div class="code_line">&nbsp;&nbsp;end;</div><div class="code_line">&nbsp;&nbsp;Result.X := nx;</div><div class="code_line">&nbsp;&nbsp;Result.Y := ny;</div><div class="code_line">end;</div><div class="code_line">&nbsp;</div><div class="code_line">procedure TForm6.FormMouseDown(Sender: TObject; Button: TMouseButton;</div><div class="code_line">&nbsp;&nbsp;Shift: TShiftState; X, Y: Integer);</div><div class="code_line">var</div><div class="code_line">&nbsp;&nbsp;p: TPoint;</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp;p := FindHexCell(x, y);</div><div class="code_line">&nbsp;&nbsp;Caption := Format(&#39; &nbsp; &nbsp; &nbsp;%d: %d&#39;, [p.Y, p.X]);</div><div class="code_line">end;</div><div class="code_line">&nbsp;</div><div class="code_line">procedure TForm6.FormPaint(Sender: TObject);</div><div class="code_line">var</div><div class="code_line">&nbsp;&nbsp;ix, iy, xx, yy: Integer;</div><div class="code_line">&nbsp;&nbsp;s: string;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp;procedure DrawHex;</div><div class="code_line">&nbsp;&nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp;Canvas.MoveTo(xx - Edge, yy);</div><div class="code_line">&nbsp;&nbsp; &nbsp;Canvas.LineTo(xx - HalfEdge, yy - HalfHgt);</div><div class="code_line">&nbsp;&nbsp; &nbsp;Canvas.LineTo(xx + HalfEdge, yy - HalfHgt);</div><div class="code_line">&nbsp;&nbsp; &nbsp;Canvas.LineTo(xx + Edge, yy);</div><div class="code_line">&nbsp;&nbsp; &nbsp;Canvas.LineTo(xx + HalfEdge, yy + HalfHgt);</div><div class="code_line">&nbsp;&nbsp; &nbsp;Canvas.LineTo(xx - HalfEdge, yy + HalfHgt);</div><div class="code_line">&nbsp;&nbsp; &nbsp;Canvas.LineTo(xx - Edge, yy);</div><div class="code_line">&nbsp;&nbsp;end;</div><div class="code_line">&nbsp;</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp;for iy := 0 to 3 do</div><div class="code_line">&nbsp;&nbsp; &nbsp;for ix := 0 to 3 do begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;yy := Shift + iy * Hgt;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if Odd(ix) then</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;yy := yy + HalfHgt;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;xx := Shift + CellWdt * ix;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;DrawHex;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;s := Format(&#39;%d: %d&#39;, [iy, ix]);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;Canvas.TextOut(xx - 10, yy - 10, s);</div><div class="code_line">&nbsp;&nbsp; &nbsp;end;</div><div class="code_line">end;</div></ol></div></div></div></div><script>preloadCodeButtons('1');</script>]]></description>
        <author>MBo</author>
        <category>Алгоритмы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=249891&amp;view=findpost&amp;p=2069018</guid>
        <pubDate>Mon, 15 Sep 2008 11:46:38 +0000</pubDate>
        <title>Определение принадлежности точки n-му шестиугольнику</title>
        <link>https://forum.sources.ru/index.php?showtopic=249891&amp;view=findpost&amp;p=2069018</link>
        <description><![CDATA[Stud555: Игровое поле рисую так:<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">&nbsp;&nbsp;for i := 0 to 25 do</div><div class="code_line">&nbsp;&nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp;for j := 0 to 50 do</div><div class="code_line">&nbsp;&nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;Image2.Canvas.Brush.Color := Map.ColM[i, j];</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if Odd(i) then</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;dx := 6;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;dy := 6;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;Image2.Canvas.Polygon(</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[Point(0 + dx * i, 6 + dy * j),</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Point(3 + dx * i, 3 + dy * j),</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Point(6 + dx * i, 3 + dy * j),</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Point(9 + dx * i, 6 + dy * j),</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Point(6 + dx * i, 9 + dy * j),</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Point(3 + dx * i, 9 + dy * j)]);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;end</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;else</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;dx := 6;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;dy := 6;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;ii := i - 1;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; Image2.Canvas.Polygon(</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[Point(6 + dx * ii, 3 + dy * j),</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Point(9 + dx * ii, 0 + dy * j),</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Point(12 + dx * ii, 0 + dy * j),</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Point(15 + dx * ii, 3 + dy * j),</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Point(12 + dx * ii, 6 + dy * j),</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Point(9 + dx * ii, 6 + dy * j)]);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp;end;</div></ol></div></div></div></div><br>
Вопрос:<br>
Как в обработчике <br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">procedure TForm1.Image2MouseMove(Sender: TObject; Shift: TShiftState; X,</div><div class="code_line">&nbsp;&nbsp;Y: integer);</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp;Label3.Caption := IntToStr(X) + &#39;-&#39; + IntToStr(Y);</div><div class="code_line">end;</div></ol></div></div></div></div><br>
Вместо X и Y получить i и j, т.е. номер 6-гранника?]]></description>
        <author>Stud555</author>
        <category>Алгоритмы</category>
      </item>
	
      </channel>
      </rss>
	