Class GridF<P>
A data structure that represents a three dimensional grid.
Inheritance
Inherited Members
Namespace: Fusee.Structures
Assembly: Fusee.Structures.dll
Syntax
public abstract class GridF<P>
Type Parameters
Name | Description |
---|---|
P | The type of the payload. |
Constructors
GridF(float3, float3, Int32, Int32, Int32)
Creates a new instance of type GridF.
Declaration
public GridF(float3 center, float3 size, int noOfCellsX, int noOfCellsY, int noOfCellsZ)
Parameters
Type | Name | Description |
---|---|---|
float3 | center | The center of the grid. |
float3 | size | The size of the grid. |
System.Int32 | noOfCellsX | Number of cells in x direction. |
System.Int32 | noOfCellsY | Number of cells in y direction. |
System.Int32 | noOfCellsZ | Number of cells in z direction. |
Fields
CellSize
The size of a grid cell.
Declaration
public readonly float3 CellSize
Field Value
Type | Description |
---|---|
float3 |
Center
The center of the grid.
Declaration
public readonly float3 Center
Field Value
Type | Description |
---|---|
float3 |
NumberOfGridCells
The number of grid cells in each dimension.
Declaration
public readonly int3 NumberOfGridCells
Field Value
Type | Description |
---|---|
int3 |
Properties
GridCellsDict
All grid cells as Dictionary, using the three dimensional index as key.
Declaration
public Dictionary<int3, GridCellF<P>> GridCellsDict { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.Dictionary<int3, GridCellF<P>> |
Size
The size of the grid.
Declaration
public float3 Size { get; }
Property Value
Type | Description |
---|---|
float3 |
Methods
CreateCellForItem(Func<P, float3>, P)
Sorts a payload item into a grid cell. This method needs to determine if the respective cell already exists and create it if that's not the case.
Declaration
public abstract void CreateCellForItem(Func<P, float3> GetPositionOfPayloadItem, P payloadItem)
Parameters
Type | Name | Description |
---|---|---|
System.Func<P, float3> | GetPositionOfPayloadItem | Method that returns the position of a payload item. |
P | payloadItem | The payload item. |
CreateCells()
Creates all cells for this grid without any payload.
Declaration
public void CreateCells()
CreateCells(IEnumerable<P>)
Creates cells for this grid by calling CreateCellForItem(Func<P, float3>, P) for each payload item.
Declaration
public void CreateCells(IEnumerable<P> payload)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<P> | payload | The payload that shall be read to this grid. |
GetCellForPos(float3, float3, float3, out int3)
Gets the GridCell and its index for a given position. The GridCell can be null if it hasn't been created yet. See https://math.stackexchange.com/questions/528501/how-to-determine-which-cell-in-a-grid-a-point-belongs-to
Declaration
public GridCellF<P> GetCellForPos(float3 gridSize, float3 gridCenter, float3 pos, out int3 cellIdx)
Parameters
Type | Name | Description |
---|---|---|
float3 | gridSize | The size of the whole grid. |
float3 | gridCenter | The center of the grid. |
float3 | pos | The position to get the cell for. |
int3 | cellIdx | The index of the GridCell this point falls into. |
Returns
Type | Description |
---|---|
GridCellF<P> |
GetGridNeighbourIndices(int3, Int32)
Gets the indices of the direct or indirect neighbor.
Declaration
protected List<int3> GetGridNeighbourIndices(int3 startIdx, int dist = 1)
Parameters
Type | Name | Description |
---|---|---|
int3 | startIdx | The index of the cell we want to get the neighbors for. |
System.Int32 | dist | The distance to the neighbors. Default is 1 - this will get the direct neighbors. |
Returns
Type | Description |
---|---|
System.Collections.Generic.List<int3> |
GetPositionOfPayloadItem(P)
Returns the (x,y,z) coordinates of a payload item.
Declaration
public abstract float3 GetPositionOfPayloadItem(P item)
Parameters
Type | Name | Description |
---|---|---|
P | item | The payload item. |
Returns
Type | Description |
---|---|
float3 |