|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcz.cuni.utils.math.vertexSpace.vertex3Dspace.Vertex3DSpace
public class Vertex3DSpace
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 |
---|
public static final int MAX_PRECISION
public static final int MIN_PRECISION
public static final int CUBE_SIZE_MULTI
public final double[] cubeTranslation
public static final int[] CUBE_TRANSLATION
public final Vertex3DFactoryInterface vertexFactory
public final double precision
public final int precisionInt
public final double cubeSize
protected java.util.HashMap cubes
private int number
Constructor Detail |
---|
public Vertex3DSpace(Vertex3DFactoryInterface vf, int iPrecision)
Method Detail |
---|
protected Vertex3DSpaceCube getCube(double x, double y, double z)
public java.util.ArrayList getCubes(Tuple3D t)
t
-
public java.util.ArrayList getCubes(double x, double y, double z)
public java.util.ArrayList getCubes(double[] xyz)
public java.util.ArrayList checkVertices(Tuple3D t)
t
-
public java.util.ArrayList checkVertices(double x, double y, double z)
public java.util.ArrayList checkVertices(double[] xyz)
public java.util.ArrayList checkVertices(Tuple3D t, java.util.ArrayList vertexSpaceCubes)
t
- vertexSpaceCubes
-
public Vertex3D get(Tuple3D t)
get
in interface Vertex3DSpaceInterface
t
-
public Vertex3D get(double x, double y, double z)
Vertex3DSpaceInterface
get
in interface Vertex3DSpaceInterface
public Vertex3D get(double[] xyz)
public void set(Vertex3D v)
Vertex3DSpaceInterface
set
in interface Vertex3DSpaceInterface
public void remove(Vertex3D v)
Vertex3DSpaceInterface
remove
in interface Vertex3DSpaceInterface
public void clear()
Vertex3DSpaceInterface
clear
in interface Vertex3DSpaceInterface
public static Vertex3D[] convert(Vertex3DSpace vs, Tuple3D[] array)
public static void testArrays(Tuple3D[] first, Tuple3D[] same)
public static void main(java.lang.String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |