cz.cuni.utils.math.vertexSpace.vertex3Dspace
Class Vertex3DSpace

java.lang.Object
  extended by cz.cuni.utils.math.vertexSpace.vertex3Dspace.Vertex3DSpace
All Implemented Interfaces:
Vertex3DSpaceInterface

public class Vertex3DSpace
extends java.lang.Object
implements Vertex3DSpaceInterface

We're counting with a certain precision epsilon, that means ... 2 vertices which are closer then epsilon are counted as 1 ... what if distance of 2 vertices is 1,5 epsilon and there is third vertex in the middle? Basicly this structure takes care of creating new vertices and reporting those errors. Create VertexSpace with a certain precision and use it as a Vertex factory. You tell the instance the x, y, z of the vertex and then it will a) return you new Vertex b) return you an existing Vertex c) return null == error So ... this VertexSpace consists of VertexSpaceCube which overlaps each other by epsilon, in those cubes we stores actual vertexes (for additional info see VertexSpaceCube) VertexSpace should be used as a factory ... you have in input of some Tuple3D == (x, y, z) and this will return you the objects you want to play with (note that when you create the instance you have to specify VertexFactoryInterface) You know ... to have errors reported is nice, but if you want to do things fast - use SimpleVertexSpace (doesn't test for collisions, but is 25x faster, using only HashMap) ... but you can't specify the EPSILON Thism class should be used when you need to transfer from one PRECISION to another. Example - UT in T3D file saves vertexes with 6 digits precision - we want to count with higher precision, so Vertices need to be created with higher precision thus we can't use SimpleVertexSpace because of Vertex.equals using higher precision then UT. ... those kind of problems should be solved like this a) use VertexSpace too obtain new vertices b) put those vertices in SimpleVertexSpace ... loop for all vertices c) after processing all vertices, drop VertexSpace instance and use only SimpleVertexSpace (because it's faster) from now on


Field Summary
static int CUBE_SIZE_MULTI
          How big the cubes will be ... cubeSize = CUBE_SIZE_MULTI*precision Can't be less then 3!
static int[] CUBE_TRANSLATION
           
protected  java.util.HashMap cubes
           
 double cubeSize
          cubeSize = CUBE_SIZE_MULTI * precision;
 double[] cubeTranslation
          Contains X, Y, Z, random numbers - cubes are translated relatively to this, it's because - you usualy have nice coordinates like (0, 0, 1) etc.
static int MAX_PRECISION
          Beware ... maximal MAX_PRECISION should be double precision - 1
static int MIN_PRECISION
          Don't change this one...
private  int number
           
 double precision
          == 10^(-precisionInt)
 int precisionInt
          precision = 10^(-precisionInt)
 Vertex3DFactoryInterface vertexFactory
           
 
Constructor Summary
Vertex3DSpace(Vertex3DFactoryInterface vf, int iPrecision)
           
 
Method Summary
 void clear()
          Clears information about vertices, which have been created.
static Vertex3D[] convert(Vertex3DSpace vs, Tuple3D[] array)
          For testing the class only.
 Vertex3D get(double[] xyz)
           
 Vertex3D get(double x, double y, double z)
          Should return existing or new vertex which has "equal" coordinates.
 Vertex3D get(Tuple3D t)
          May return null == collision with more then one vertex.
protected  Vertex3DSpaceCube getCube(double x, double y, double z)
           
 java.util.ArrayList getCubes(double[] xyz)
           
 java.util.ArrayList getCubes(double x, double y, double z)
           
 java.util.ArrayList getCubes(Tuple3D t)
          Returns list of cubes into which the Tuple3D belongs.
 java.util.ArrayList checkVertices(double[] xyz)
           
 java.util.ArrayList checkVertices(double x, double y, double z)
           
 java.util.ArrayList checkVertices(Tuple3D t)
          Returns list of vertices in which surroundings the tuple lies.
 java.util.ArrayList checkVertices(Tuple3D t, java.util.ArrayList vertexSpaceCubes)
          Returns list of vertices in which surroundings the tuple lies.
static void main(java.lang.String[] args)
          This method is meant for testing the functionality of Vertex3DSpace class.
 void remove(Vertex3D v)
          Vertex must be removed from the space
 void set(Vertex3D v)
          You have to insert this vertex into space, possibly overwriting the existing one.
static void testArrays(Tuple3D[] first, Tuple3D[] same)
          For testing the class only.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_PRECISION

public static final int MAX_PRECISION
Beware ... maximal MAX_PRECISION should be double precision - 1

See Also:
Constant Field Values

MIN_PRECISION

public static final int MIN_PRECISION
Don't change this one...

See Also:
Constant Field Values

CUBE_SIZE_MULTI

public static final int CUBE_SIZE_MULTI
How big the cubes will be ... cubeSize = CUBE_SIZE_MULTI*precision Can't be less then 3! ... well I think it shouldn't ;)

See Also:
Constant Field Values

cubeTranslation

public final double[] cubeTranslation
Contains X, Y, Z, random numbers - cubes are translated relatively to this, it's because - you usualy have nice coordinates like (0, 0, 1) etc. See? 0, 0, 1 are numbers on borders of the cubes ... nasty ;) cubeTranslation = new double[]{precision, 2*precision, 3*precision};


CUBE_TRANSLATION

public static final int[] CUBE_TRANSLATION

vertexFactory

public final Vertex3DFactoryInterface vertexFactory

precision

public final double precision
== 10^(-precisionInt)


precisionInt

public final int precisionInt
precision = 10^(-precisionInt)


cubeSize

public final double cubeSize
cubeSize = CUBE_SIZE_MULTI * precision;


cubes

protected java.util.HashMap cubes

number

private int number
Constructor Detail

Vertex3DSpace

public Vertex3DSpace(Vertex3DFactoryInterface vf,
                     int iPrecision)
Method Detail

getCube

protected Vertex3DSpaceCube getCube(double x,
                                    double y,
                                    double z)

getCubes

public java.util.ArrayList getCubes(Tuple3D t)
Returns list of cubes into which the Tuple3D belongs. Sort of cruel one ... if you look at code, you have to check for many possibilities regarding where the tuple is (26 possibilities)

Parameters:
t -
Returns:
ArrayList of cubes

getCubes

public java.util.ArrayList getCubes(double x,
                                    double y,
                                    double z)

getCubes

public java.util.ArrayList getCubes(double[] xyz)

checkVertices

public java.util.ArrayList checkVertices(Tuple3D t)
Returns list of vertices in which surroundings the tuple lies.

Parameters:
t -
Returns:
ArrayList

checkVertices

public java.util.ArrayList checkVertices(double x,
                                         double y,
                                         double z)

checkVertices

public java.util.ArrayList checkVertices(double[] xyz)

checkVertices

public java.util.ArrayList checkVertices(Tuple3D t,
                                         java.util.ArrayList vertexSpaceCubes)
Returns list of vertices in which surroundings the tuple lies. Note that it isn't "cool" ... same vertex may be returned from different cubes (because they overlap) so we have to be sure that result will be unique. vertexSpaceCubes - which cubes should be checked

Parameters:
t -
vertexSpaceCubes -
Returns:
ArrayList

get

public Vertex3D get(Tuple3D t)
May return null == collision with more then one vertex.

Specified by:
get in interface Vertex3DSpaceInterface
Parameters:
t -
Returns:
Vertex3D which belongs to 't'

get

public Vertex3D get(double x,
                    double y,
                    double z)
Description copied from interface: Vertex3DSpaceInterface
Should return existing or new vertex which has "equal" coordinates.

Specified by:
get in interface Vertex3DSpaceInterface
Returns:
Vertex3D

get

public Vertex3D get(double[] xyz)

set

public void set(Vertex3D v)
Description copied from interface: Vertex3DSpaceInterface
You have to insert this vertex into space, possibly overwriting the existing one.

Specified by:
set in interface Vertex3DSpaceInterface

remove

public void remove(Vertex3D v)
Description copied from interface: Vertex3DSpaceInterface
Vertex must be removed from the space

Specified by:
remove in interface Vertex3DSpaceInterface

clear

public void clear()
Description copied from interface: Vertex3DSpaceInterface
Clears information about vertices, which have been created.

Specified by:
clear in interface Vertex3DSpaceInterface

convert

public static Vertex3D[] convert(Vertex3DSpace vs,
                                 Tuple3D[] array)
For testing the class only.


testArrays

public static void testArrays(Tuple3D[] first,
                              Tuple3D[] same)
For testing the class only.


main

public static void main(java.lang.String[] args)
This method is meant for testing the functionality of Vertex3DSpace class.