Class GridUtils
Inheritance
System.Object
GridUtils
Assembly: Eco.Simulation.dll
Syntax
public class GridUtils : Object
Constructors
GridUtils()
Declaration
Methods
BruteForceLine(Vector2, Vector2, Single)
Slow grid-traverse algorithm for finding path from start to end point
Declaration
public List<Vector2i> BruteForceLine(Vector2 start, Vector2 end, float delta)
Parameters
Returns
Type |
Description |
System.Collections.Generic.List<Vector2i> |
|
DrawLine(Vector3, Vector3)
Declaration
public static IEnumerable<Vector3i> DrawLine(Vector3 start, Vector3 end)
Parameters
Type |
Name |
Description |
System.Numerics.Vector3 |
start |
|
System.Numerics.Vector3 |
end |
|
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<Vector3i> |
|
FastVoxelTraversal(Vector3, Vector3, Func<Vector3i, Boolean>)
Return all voxels that are visited by a ray going from to by J. Amanatides, A. Woo. A Fast Voxel Traversal Algorithm for Ray Tracing. Eurographics '87. http://www.cse.yorku.ca/~amana/research/grid.pdf
We are following the equation {u} +t{v} (it represents a ray).
General idea:
1: initialize phase begins with identifying the voxel where the ray begins, find if our ray (by each axis) is incremented or decremented (step sign).
Then we define t value - where the ray crosses the first voxel boundary (in each axis diraction).
And compute delta for each axis direction - how far in units of t we should follow along the ray to make this distance be equal to width of a voxel (1 in our case).
Declaration
public static IEnumerable<Vector3i> FastVoxelTraversal(Vector3 start, Vector3 end, Func<Vector3i, bool> visit)
Parameters
Type |
Name |
Description |
System.Numerics.Vector3 |
start |
|
System.Numerics.Vector3 |
end |
|
System.Func<Vector3i, System.Boolean> |
visit |
|
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<Vector3i> |
|
GridTraverse(Vector2, Vector2, Func<Vector2i, Boolean>)
Grid traversal algorithm based on bresenham's algorithm. Iterates through all 2d cells along a line.
Declaration
public static bool GridTraverse(Vector2 start, Vector2 end, Func<Vector2i, bool> visit)
Parameters
Returns
Type |
Description |
System.Boolean |
|