Skip to content

Commit 8d2b00c

Browse files
Correct triangular tiling calculations
1 parent 189b6ab commit 8d2b00c

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/hexagonify_wasm.ml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -663,14 +663,22 @@ def _gen_carre(larg, haut, a):
663663

664664
def _gen_triangle(larg, haut, a):
665665
h = hauteur_tri(a)
666-
cols = entier(math.ceil((larg + a * 2.0) / a)) + 2
667-
rangs = entier(math.ceil((haut + h * 2.0) / (2.0 * h))) + 2
666+
cols = entier(math.ceil((larg + a * 2.0) / (a / 2.0))) + 2
667+
rangs = entier(math.ceil((haut + h * 2.0) / h)) + 2
668668
pour rang dans range(rangs):
669-
y = -h + rang * (2.0 * h)
669+
y = -h + rang * h
670670
pour col dans range(cols):
671-
x = -a + col * a
672-
_ajouter_tuile_3_direct(x, y + h, x + a / 2.0, y, x + a, y + h, larg, haut)
673-
_ajouter_tuile_3_direct(x, y + h, x + a, y + h, x + a / 2.0, y + 2.0 * h, larg, haut)
671+
x = -a + col * (a / 2.0)
672+
vers_haut = 1
673+
si (rang + col) % 2 != 0:
674+
vers_haut = 0
675+
soit x0 = sommet_tri_x(x, a, 0, vers_haut)
676+
soit y0 = sommet_tri_y(y, a, 0, vers_haut)
677+
soit x1 = sommet_tri_x(x, a, 1, vers_haut)
678+
soit y1 = sommet_tri_y(y, a, 1, vers_haut)
679+
soit x2 = sommet_tri_x(x, a, 2, vers_haut)
680+
soit y2 = sommet_tri_y(y, a, 2, vers_haut)
681+
_ajouter_tuile_3_direct(x0, y0, x1, y1, x2, y2, larg, haut)
674682
retour 0
675683

676684

0 commit comments

Comments
 (0)