Class TriangleGrid
A uniform tiling of triangles.
TriangleOrientation.FlatSides gives columns of triangles that alternate pointing left/right.
TriangleOrientation.FlatTopped gives rows of triangles that alternate pointing up/down.
In both cases, the cell type used is actually TriangleCellType. For each triangle, three of the directions
point towards neighbors, and the other three will point to nothing.
This is a similar setup to DoubleOddFaces, and is usually simpler to work with
as it doesn't force you to consider some cells as rotated by 180 degrees.
Inheritance
System.Object
TriangleGrid
Assembly: Sylves.dll
Syntax
public class TriangleGrid : Object, IGrid
Constructors
TriangleGrid(Vector2, TriangleOrientation, TriangleBound)
Creates a triangle grid where each triangle has width and height given by cellSize.x and cellSize.y
Declaration
public TriangleGrid(Vector2 cellSize, TriangleOrientation orientation, TriangleBound bound = null)
Parameters
TriangleGrid(Single, TriangleOrientation, TriangleBound)
Creates a triangle grid where each triangle is equilateral and has each side length of cellSide.
I.e. the incircle diameter is cellSide * sqrt(1/3) and circumcircle diameter is 2 * cellSide * sqrt(1/3)
Declaration
public TriangleGrid(float cellSide, TriangleOrientation orientation, TriangleBound bound = null)
Parameters
Properties
CellSize
Declaration
public Vector2 CellSize { get; }
Property Value
CoordinateDimension
Declaration
public int CoordinateDimension { get; }
Property Value
| Type |
Description |
| System.Int32 |
|
IndexCount
Declaration
public int IndexCount { get; }
Property Value
| Type |
Description |
| System.Int32 |
|
Is2d
Declaration
public bool Is2d { get; }
Property Value
| Type |
Description |
| System.Boolean |
|
Is3d
Declaration
public bool Is3d { get; }
Property Value
| Type |
Description |
| System.Boolean |
|
IsFinite
Declaration
public bool IsFinite { get; }
Property Value
| Type |
Description |
| System.Boolean |
|
IsOrientable
Declaration
public bool IsOrientable { get; }
Property Value
| Type |
Description |
| System.Boolean |
|
IsPlanar
Declaration
public bool IsPlanar { get; }
Property Value
| Type |
Description |
| System.Boolean |
|
IsRepeating
Declaration
public bool IsRepeating { get; }
Property Value
| Type |
Description |
| System.Boolean |
|
IsSingleCellType
Declaration
public bool IsSingleCellType { get; }
Property Value
| Type |
Description |
| System.Boolean |
|
Orientation
Declaration
public TriangleOrientation Orientation { get; }
Property Value
Unbounded
Declaration
public IGrid Unbounded { get; }
Property Value
Unwrapped
Declaration
public IGrid Unwrapped { get; }
Property Value
Methods
BoundBy(IBound)
Declaration
public IGrid BoundBy(IBound bound)
Parameters
| Type |
Name |
Description |
| IBound |
bound |
|
Returns
FindBasicPath(Cell, Cell)
Declaration
public IEnumerable<(Cell, CellDir)> FindBasicPath(Cell startCell, Cell destCell)
Parameters
| Type |
Name |
Description |
| Cell |
startCell |
|
| Cell |
destCell |
|
Returns
| Type |
Description |
| System.Collections.Generic.IEnumerable<System.ValueTuple<Cell, CellDir>> |
|
FindCell(Matrix4x4, out Cell, out CellRotation)
Declaration
public bool FindCell(Matrix4x4 matrix, out Cell cell, out CellRotation rotation)
Parameters
Returns
| Type |
Description |
| System.Boolean |
|
FindCell(Vector3, out Cell)
Declaration
public bool FindCell(Vector3 position, out Cell cell)
Parameters
Returns
| Type |
Description |
| System.Boolean |
|
FindGridSymmetry(ISet<Cell>, ISet<Cell>, Cell, CellRotation)
Declaration
public GridSymmetry FindGridSymmetry(ISet<Cell> src, ISet<Cell> dest, Cell srcCell, CellRotation cellRotation)
Parameters
| Type |
Name |
Description |
| System.Collections.Generic.ISet<Cell> |
src |
|
| System.Collections.Generic.ISet<Cell> |
dest |
|
| Cell |
srcCell |
|
| CellRotation |
cellRotation |
|
Returns
GetBound()
Declaration
Returns
GetBound(IEnumerable<Cell>)
Declaration
public IBound GetBound(IEnumerable<Cell> cells)
Parameters
| Type |
Name |
Description |
| System.Collections.Generic.IEnumerable<Cell> |
cells |
|
Returns
GetCellByIndex(Int32)
Declaration
public Cell GetCellByIndex(int index)
Parameters
| Type |
Name |
Description |
| System.Int32 |
index |
|
Returns
GetCellCenter(Cell)
Returns the center of the cell in local space
Declaration
public Vector3 GetCellCenter(Cell cell)
Parameters
| Type |
Name |
Description |
| Cell |
cell |
|
Returns
GetCellCorner(Cell, CellCorner)
Declaration
public Vector3 GetCellCorner(Cell cell, CellCorner corner)
Parameters
Returns
GetCellCorners(Cell)
Declaration
public IEnumerable<CellCorner> GetCellCorners(Cell cell)
Parameters
| Type |
Name |
Description |
| Cell |
cell |
|
Returns
| Type |
Description |
| System.Collections.Generic.IEnumerable<CellCorner> |
|
GetCellDirs(Cell)
Declaration
public IEnumerable<CellDir> GetCellDirs(Cell cell)
Parameters
| Type |
Name |
Description |
| Cell |
cell |
|
Returns
| Type |
Description |
| System.Collections.Generic.IEnumerable<CellDir> |
|
GetCells()
Declaration
public IEnumerable<Cell> GetCells()
Returns
| Type |
Description |
| System.Collections.Generic.IEnumerable<Cell> |
|
GetCellsInBounds(IBound)
Declaration
public IEnumerable<Cell> GetCellsInBounds(IBound bound)
Parameters
| Type |
Name |
Description |
| IBound |
bound |
|
Returns
| Type |
Description |
| System.Collections.Generic.IEnumerable<Cell> |
|
GetCellsIntersectsApprox(Vector3, Vector3)
Declaration
public IEnumerable<Cell> GetCellsIntersectsApprox(Vector3 min, Vector3 max)
Parameters
Returns
| Type |
Description |
| System.Collections.Generic.IEnumerable<Cell> |
|
GetCellType(Cell)
Declaration
public ICellType GetCellType(Cell cell)
Parameters
| Type |
Name |
Description |
| Cell |
cell |
|
Returns
GetCellTypes()
Declaration
public IEnumerable<ICellType> GetCellTypes()
Returns
| Type |
Description |
| System.Collections.Generic.IEnumerable<ICellType> |
|
Declaration
public Deformation GetDeformation(Cell cell)
Parameters
| Type |
Name |
Description |
| Cell |
cell |
|
Returns
GetDual()
Declaration
public virtual IDualMapping GetDual()
Returns
GetIndex(Cell)
Declaration
public int GetIndex(Cell cell)
Parameters
| Type |
Name |
Description |
| Cell |
cell |
|
Returns
| Type |
Description |
| System.Int32 |
|
GetMeshData(Cell, out MeshData, out Matrix4x4)
Declaration
public void GetMeshData(Cell cell, out MeshData meshData, out Matrix4x4 transform)
Parameters
GetPolygon(Cell, out Vector3[], out Matrix4x4)
Declaration
public void GetPolygon(Cell cell, out Vector3[] vertices, out Matrix4x4 transform)
Parameters
GetTriangleMesh(Cell)
Declaration
public IEnumerable<(Vector3, Vector3, Vector3, CellDir)> GetTriangleMesh(Cell cell)
Parameters
| Type |
Name |
Description |
| Cell |
cell |
|
Returns
GetTRS(Cell)
Returns the appropriate transform for the cell.
The translation will always be to GetCellCenter.
Not inclusive of cell rotation, that should be applied first.
Declaration
public TRS GetTRS(Cell cell)
Parameters
| Type |
Name |
Description |
| Cell |
cell |
|
Returns
IntersectBounds(IBound, IBound)
Declaration
public IBound IntersectBounds(IBound bound, IBound other)
Parameters
Returns
IsCellInBound(Cell, IBound)
Declaration
public bool IsCellInBound(Cell cell, IBound bound)
Parameters
Returns
| Type |
Description |
| System.Boolean |
|
IsCellInGrid(Cell)
Declaration
public bool IsCellInGrid(Cell cell)
Parameters
| Type |
Name |
Description |
| Cell |
cell |
|
Returns
| Type |
Description |
| System.Boolean |
|
IsDown(Cell)
Declaration
public bool IsDown(Cell cell)
Parameters
| Type |
Name |
Description |
| Cell |
cell |
|
Returns
| Type |
Description |
| System.Boolean |
|
IsLeft(Cell)
Declaration
public bool IsLeft(Cell cell)
Parameters
| Type |
Name |
Description |
| Cell |
cell |
|
Returns
| Type |
Description |
| System.Boolean |
|
IsRight(Cell)
Declaration
public bool IsRight(Cell cell)
Parameters
| Type |
Name |
Description |
| Cell |
cell |
|
Returns
| Type |
Description |
| System.Boolean |
|
IsUp(Cell)
Declaration
public bool IsUp(Cell cell)
Parameters
| Type |
Name |
Description |
| Cell |
cell |
|
Returns
| Type |
Description |
| System.Boolean |
|
ParallelTransport(IGrid, Cell, Cell, Cell, CellRotation, out Cell, out CellRotation)
Declaration
public virtual bool ParallelTransport(IGrid aGrid, Cell aSrcCell, Cell aDestCell, Cell srcCell, CellRotation startRotation, out Cell destCell, out CellRotation destRotation)
Parameters
Returns
| Type |
Description |
| System.Boolean |
|
Raycast(Vector3, Vector3, Single)
Declaration
public IEnumerable<RaycastInfo> Raycast(Vector3 origin, Vector3 direction, float maxDistance = InfinityF)
Parameters
| Type |
Name |
Description |
| Vector3 |
origin |
|
| Vector3 |
direction |
|
| System.Single |
maxDistance |
|
Returns
| Type |
Description |
| System.Collections.Generic.IEnumerable<RaycastInfo> |
|
TryApplySymmetry(GridSymmetry, Cell, out Cell, out CellRotation)
Declaration
public bool TryApplySymmetry(GridSymmetry s, Cell src, out Cell dest, out CellRotation r)
Parameters
Returns
| Type |
Description |
| System.Boolean |
|
TryApplySymmetry(GridSymmetry, IBound, out IBound)
Declaration
public bool TryApplySymmetry(GridSymmetry s, IBound srcBound, out IBound destBound)
Parameters
Returns
| Type |
Description |
| System.Boolean |
|
TryMove(Cell, CellDir, out Cell, out CellDir, out Connection)
Declaration
public bool TryMove(Cell cell, CellDir dir, out Cell dest, out CellDir inverseDir, out Connection connection)
Parameters
Returns
| Type |
Description |
| System.Boolean |
|
TryMoveByOffset(Cell, Vector3Int, Vector3Int, CellRotation, out Cell, out CellRotation)
Declaration
public bool TryMoveByOffset(Cell startCell, Vector3Int startOffset, Vector3Int destOffset, CellRotation startRotation, out Cell destCell, out CellRotation destRotation)
Parameters
Returns
| Type |
Description |
| System.Boolean |
|
UnionBounds(IBound, IBound)
Declaration
public IBound UnionBounds(IBound bound, IBound other)
Parameters
Returns
WithIncircleDiameter(Single, TriangleOrientation, TriangleBound)
Creates a triangle grid where each triangle is equilateral and the given incircle diameter.
The incircle diameter is the distance between the centers of two adjacent triangles.
Declaration
public static TriangleGrid WithIncircleDiameter(float incircleDiameter, TriangleOrientation orientation, TriangleBound bound = null)
Parameters
Returns
Implements