at.tuwien.ifs.somtoolbox.visualization
Class Snapper3D

java.lang.Object
  extended by at.tuwien.ifs.somtoolbox.visualization.Snapper
      extended by at.tuwien.ifs.somtoolbox.visualization.Snapper3D

public class Snapper3D
extends Snapper


Field Summary
private  Point3d[] grid
           
private static double gridSize
           
 
Fields inherited from class at.tuwien.ifs.somtoolbox.visualization.Snapper
distanceFunction, lineDistanceFunction
 
Constructor Summary
Snapper3D(AbstractMetric distanceFunction, DistanceFunctionType lineDistanceFunction)
           
Snapper3D(double gridSize, AbstractMetric distanceFunction, DistanceFunctionType lineDistanceFunction)
           
 
Method Summary
 double[][] convert(Point3d[] array)
           
 Point3d[] createGrid(int xSize, int ySize, int zSize)
           
 Point3d[] doSnapping(double[][] centres)
           
 Point3d[] doSnapping(Point3d[] line)
           
private  int getDirection(Point3d current, Point3d next)
          returns the direction between two nodes based on the following scheme: 0 7 left up up right up 1 \ | / 6 left - * - right 6 / | \ 5 left down down right down 3 4
 double[][] getGrid()
           
 Point3d[] getNeighbouringUnits(Point3d p)
           
static double[] normalise(double[] vec)
           
private  Point3d[] snap(Point3d[] line)
          Returns a snapped line of the given line.
private  Point3d[] snapPoint(Point3d startPoint, Point3d[] line, int currentPosition, int direction, int bins)
          Snaps the next point on the line.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

grid

private Point3d[] grid

gridSize

private static double gridSize
Constructor Detail

Snapper3D

public Snapper3D(AbstractMetric distanceFunction,
                 DistanceFunctionType lineDistanceFunction)

Snapper3D

public Snapper3D(double gridSize,
                 AbstractMetric distanceFunction,
                 DistanceFunctionType lineDistanceFunction)
Method Detail

normalise

public static double[] normalise(double[] vec)

doSnapping

public Point3d[] doSnapping(double[][] centres)
                     throws SOMToolboxException
Throws:
SOMToolboxException

doSnapping

public Point3d[] doSnapping(Point3d[] line)
                     throws SOMToolboxException
Throws:
SOMToolboxException

getDirection

private int getDirection(Point3d current,
                         Point3d next)
returns the direction between two nodes based on the following scheme: 0 7 left up up right up 1 \ | / 6 left - * - right 6 / | \ 5 left down down right down 3 4

Parameters:
current - current node
next - next node to go to
Returns:
dir from current to next

createGrid

public Point3d[] createGrid(int xSize,
                            int ySize,
                            int zSize)

getGrid

public double[][] getGrid()

convert

public double[][] convert(Point3d[] array)

snap

private Point3d[] snap(Point3d[] line)
Returns a snapped line of the given line. Snapping the metro lines means to find a line as similar as possible to the given line, which has all bin centres in the unit centres, and line segments are connected in multiples of 45° degree angles to each other.
TODO: Consider disallowing 135° / 315° as too sharp turns.


snapPoint

private Point3d[] snapPoint(Point3d startPoint,
                            Point3d[] line,
                            int currentPosition,
                            int direction,
                            int bins)
Snaps the next point on the line.

Parameters:
startPoint - the point to start from
line - the line to snap
currentPosition - the current position on the line
direction - forward (1) or backwards (-1)
bins - number of bins
Returns:
a snapped line

getNeighbouringUnits

public Point3d[] getNeighbouringUnits(Point3d p)