Show / Hide Table of Contents

TriangleGrid

Quick facts
GridTriangleGrid
CellTypeHexCellType
CellDirPTHexDir (for flat-sides grids)
FTHexDir (for flat-topped grids)
CellRotationHexRotation
BoundTriangleBound
Properties2d, Planar, Repeating, Infinite

TriangleGrid is a tiling of the plane with triangles. It supports both flat-topped and flat-sides varieties.

Cell co-ordinates

The co-ordinate systems used are shown above - it uses three co-ordinates that always sum to 1 (for left and down pointing triangles) or 2 (for right or up pointing triangles). This scheme is explained more on my blog.

TriangleGrid comes with methods IsUp/IsDown/IsLeft/IsRight to determine which direction a given cell is pointing.

Hexagonal basis

Note that Triangle grid shares several classes in common with hexagons. E.g. A flat-topped triangle grid uses FTHexDir to get the list of directions, and flat-sides triangle grid uses PTHexDir.

That means, for an up-pointing triangle, it has adjacent triangles FTHexDir.Down, FTHexDir.UpLeft and FTHexDir.UpRight. The other three directions, FTHexDir.Up, FTHexDir.DownRight and FTHexDir.DownLeft are not used for an up-pointing triangle. It's the other way around for a downward pointing triangle, and similar for left/right.

Hexes are used in these cases so that triangles pointing in opposite directions do not re-use the same CellDir values to mean different things. Sylves supports that, but it would effectively mean you'd have to deal with some triangles being rotated 180 degress compared to others. Rotation is a concept best avoided where possible.

If you do want a triangle grid with only 3 directions, using NGonCellType.Get(3), and so on, then you can construct one using PeriodicPlanarMeshGrid.

In This Article
Back to top Generated by DocFX