Class PointHashGrid2d<T>
Hash Grid for 2D points. You provide the 'point' type. If you have an indexable
set of points this can just be int, or can be more complex point data structure
(but be careful w/ structs...)
Does not actually store 2D points. So, to remove a point
you must also know it's 2D coordinate, so we can look up the cell coordinates.
Hence, to 'update' a point, you need to know both it's old and new 2D coordinates.
Inheritance
PointHashGrid2d<T>
Namespace: g3
Assembly: cs.temp.dll.dll
Syntax
public class PointHashGrid2d<T>
Type Parameters
Constructors
PointHashGrid2d(Double, T)
"invalid" value will be returned by queries if no valid result is found (eg bounded-distance query)
Declaration
public PointHashGrid2d(double cellSize, T invalidValue)
Parameters
Type |
Name |
Description |
Double |
cellSize |
|
T |
invalidValue |
|
Properties
InvalidValue
Declaration
public T InvalidValue { get; }
Property Value
Methods
FindNearestInRadius(Vector2d, Double, Func<T, Double>, Func<T, Boolean>)
Find nearest point in grid, within radius, without locking / thread-safety
You must provided distF which returns distance between query_pt and the point argument
You can ignore specific points via ignoreF lambda
Declaration
public KeyValuePair<T, double> FindNearestInRadius(Vector2d query_pt, double radius, Func<T, double> distF, Func<T, bool> ignoreF = null)
Parameters
Returns
InsertPoint(T, Vector2d)
Insert point at position. This function is thread-safe, uses a SpinLock internally
Declaration
public void InsertPoint(T value, Vector2d pos)
Parameters
Type |
Name |
Description |
T |
value |
|
Vector2d |
pos |
|
InsertPointUnsafe(T, Vector2d)
Insert point without locking / thread-safety
Declaration
public void InsertPointUnsafe(T value, Vector2d pos)
Parameters
Type |
Name |
Description |
T |
value |
|
Vector2d |
pos |
|
RemovePoint(T, Vector2d)
Insert point. This function is thread-safe, uses a SpinLock internally
Declaration
public bool RemovePoint(T value, Vector2d pos)
Parameters
Type |
Name |
Description |
T |
value |
|
Vector2d |
pos |
|
Returns
RemovePointUnsafe(T, Vector2d)
Remove point without locking / thread-safety
Declaration
public bool RemovePointUnsafe(T value, Vector2d pos)
Parameters
Type |
Name |
Description |
T |
value |
|
Vector2d |
pos |
|
Returns
UpdatePoint(T, Vector2d, Vector2d)
Move point from old to new position. This function is thread-safe, uses a SpinLock internally
Declaration
public void UpdatePoint(T value, Vector2d old_pos, Vector2d new_pos)
Parameters
UpdatePointUnsafe(T, Vector2d, Vector2d)
Move point from old to new position without locking / thread-safety
Declaration
public void UpdatePointUnsafe(T value, Vector2d old_pos, Vector2d new_pos)
Parameters