cdx
Class Reducer

java.lang.Object
  extended by cdx.Reducer

public class Reducer
extends java.lang.Object

Reduces the set of collisions to be tested using a voxel hashing algorithm.


Field Summary
 Vector2d horizontal
          The horizontal side of a voxel.
 Vector2d vertical
          The vertical side of a voxel.
 float voxel_size
          The voxel size.
 
Constructor Summary
Reducer(float voxel_size)
          Initialise the reducer with a voxel size.
 
Method Summary
protected  void dfsVoxelHashRecurse(Motion motion, Vector2d next_voxel, HashMap voxel_map, HashMap graph_colors)
          Recursive method to check which voxels overlap with a motion
protected  boolean isInVoxel(Vector2d voxel, Motion motion)
          Given a voxel and a Motion, determines if they overlap.
protected  void performVoxelHashing(Motion motion, HashMap voxel_map, HashMap graph_colors)
          Colours all of the voxels that overlap with the Motion.
protected  void putIntoMap(HashMap voxel_map, Vector2d voxel, Motion motion)
          Puts a Motion object into the voxel map at a voxel.
 LinkedList reduceCollisionSet(LinkedList motions)
          Takes a List of Motions and returns an List of Lists of Motions, where the inner lists implement RandomAccess.
protected  void voxelHash(Vector3d position, Vector2d voxel)
          Creates a Vector2d that represents a voxel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

voxel_size

public final float voxel_size
The voxel size. Each voxel is a square, so this is the length of a side.


horizontal

public final Vector2d horizontal
The horizontal side of a voxel.


vertical

public final Vector2d vertical
The vertical side of a voxel.

Constructor Detail

Reducer

public Reducer(float voxel_size)
Initialise the reducer with a voxel size.

Parameters:
voxel_size - the size of a voxel
Method Detail

voxelHash

protected void voxelHash(Vector3d position,
                         Vector2d voxel)
Creates a Vector2d that represents a voxel.

Parameters:
position - a aircraft 3D position
voxel - a 2D voxel

putIntoMap

protected void putIntoMap(HashMap voxel_map,
                          Vector2d voxel,
                          Motion motion)
Puts a Motion object into the voxel map at a voxel.

Parameters:
voxel_map - a voxel hashmap
voxel - a voxel
motion - a motion to be hashed in the map

isInVoxel

protected boolean isInVoxel(Vector2d voxel,
                            Motion motion)
Given a voxel and a Motion, determines if they overlap.

Parameters:
voxel - a voxel to be checked
motion - a motion to be checked in the voxel
Returns:
false if no overlapping

dfsVoxelHashRecurse

protected void dfsVoxelHashRecurse(Motion motion,
                                   Vector2d next_voxel,
                                   HashMap voxel_map,
                                   HashMap graph_colors)
Recursive method to check which voxels overlap with a motion

Parameters:
motion - a motion to be checked with voxels
next_voxel - the next voxel in the map
voxel_map - the hashmap for all voxels
graph_colors - the hashmap who colors the voxels that overlap with the motion

performVoxelHashing

protected void performVoxelHashing(Motion motion,
                                   HashMap voxel_map,
                                   HashMap graph_colors)
Colours all of the voxels that overlap with the Motion.

Parameters:
motion - the checked motion
voxel_map - the hashmap of all voxels
graph_colors - the haspmap where coloured voxels overlap with this motion

reduceCollisionSet

public LinkedList reduceCollisionSet(LinkedList motions)
Takes a List of Motions and returns an List of Lists of Motions, where the inner lists implement RandomAccess. Each Vector of Motions that is returned represents a set of Motions that might have collisions.

Parameters:
motions - a lisit of motions that are to be checked with voxels
Returns:
a list of sets of motions that might have collisions