Login

Fancade Wiki

Created How to make hexagons? (markdown)

... ...
@@ -0,0 +1,34 @@
1
This is a tutorial how to create a perfect regular hexagon in Fancade. This exact method is used to create hexagons in games Hexoban and Hexals.
2
3
## Classic method
4
5
Hexagons are made out of 6 square pieces, properly placed and rotated. First of all, we need to create one such a square piece. We're going to create a green hexagon with a darker boundary, so our piece looks like this:
6
7
[[/uploads/Screenshot_20210423-140008~2.jpg | height=200px]]
8
9
This piece will be copied 5 times and the other pieces will be placed relatively to the original one. To obtain the coordinates of the remaining pieces, we need to add the following vectors to the position of the original piece:
10
- (-0.317, 0, 0.183),
11
- (-0.317, 0, 0.549),
12
- (0, 0, 0.732),
13
- (0.317, 0, 0.183),
14
- (0.317, 0, 0.549).
15
16
These coordinates are not exact (the exact coordinates are irrational and they require a square root of three), but three decimal places is enough for our hexagon to look good. Let's put them in a list (starting from the index 1 for convenience):
17
18
[[/uploads/Screenshot_20210423-140026~2.jpg | height=500px]]
19
20
Now our hexagon can be created with a simple loop. We create the remaining pieces and we set their positions using the list above. We also need to rotate them (by 60°, 120° etc) and for that we're going to use Make Rotation block. The loop looks like this:
21
22
[[/uploads/Screenshot_20210423-140054~2.jpg | height=450px]]
23
24
Let's start the script now. See what happened to our original object!
25
26
[[/uploads/Screenshot_20210423-140112~2.jpg | height=250px]]
27
28
Here we go! A perfect regular hexagon!
29
30
## Advanced method
31
32
Instead of creating the list of positions, they can be calculated in Fancade using trigonometric functions.
33
34
(TBA)
... ...
\ No newline at end of file
Fancade Wiki