|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcz.cuni.utils.math.vertexSpace.vertex2Dspace.Vertex2DSpace
public class Vertex2DSpace
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 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 VertexSpaceSquares which overlaps each other by epsilon, in those squares we stores actual vertexes (for additional info see VertexSpaceCube) VertexSpace should be used as a factory ... you have in input of some Tuple2D == (x, y) 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 This 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 |
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) |
static int |
SQUARE_SIZE_MULTI
How big the squares will be ... squareSize = SQUARE_SIZE_MULTI*precision Can't be less then 3! |
static int[] |
SQUARE_TRANSLATION
|
protected java.util.HashMap |
squares
|
double |
squareSize
cubeSize = CUBE_SIZE_MULTI * precision; |
double[] |
squareTranslation
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. |
Vertex2DFactoryInterface |
vertexFactory
|
Constructor Summary | |
---|---|
Vertex2DSpace(Vertex2DFactoryInterface vf,
int iPrecision)
|
Method Summary | |
---|---|
void |
clear()
Clears information about vertices, which have been created. |
static Vertex2D[] |
convert(Vertex2DSpace vs,
Tuple2D[] array)
For testing the class only. |
Vertex2D |
get(double[] xy)
|
Vertex2D |
get(double x,
double y)
Should return existing or new vertex which has "equal" coordinates. |
Vertex2D |
get(Tuple2D t)
May return null == collision with more then one vertex. |
java.util.ArrayList |
getCubes(double[] xy)
|
java.util.ArrayList |
getCubes(double x,
double y)
|
protected Vertex2DSpaceSquare |
getSquare(double x,
double y)
|
java.util.ArrayList |
getSquares(Tuple2D t)
Returns list of cubes into which the Tuple3D belongs. |
java.util.ArrayList |
checkVertices(double[] xy)
|
java.util.ArrayList |
checkVertices(double x,
double y)
|
java.util.ArrayList |
checkVertices(Tuple2D t)
Returns list of vertices in which surroundings the tuple lies. |
java.util.ArrayList |
checkVertices(Tuple2D 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(Vertex2D v)
Vertex must be removed from the space |
void |
set(Vertex2D v)
You have to insert this vertex into space, possibly overwriting the existing one. |
static void |
testArrays(Tuple2D[] first,
Tuple2D[] 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 SQUARE_SIZE_MULTI
public final double[] squareTranslation
public static final int[] SQUARE_TRANSLATION
public final Vertex2DFactoryInterface vertexFactory
public final double precision
public final int precisionInt
public final double squareSize
protected java.util.HashMap squares
private int number
Constructor Detail |
---|
public Vertex2DSpace(Vertex2DFactoryInterface vf, int iPrecision)
Method Detail |
---|
protected Vertex2DSpaceSquare getSquare(double x, double y)
public java.util.ArrayList getSquares(Tuple2D t)
t
-
public java.util.ArrayList getCubes(double x, double y)
public java.util.ArrayList getCubes(double[] xy)
public java.util.ArrayList checkVertices(Tuple2D t)
t
-
public java.util.ArrayList checkVertices(double x, double y)
public java.util.ArrayList checkVertices(double[] xy)
public java.util.ArrayList checkVertices(Tuple2D t, java.util.ArrayList vertexSpaceCubes)
t
- vertexSpaceCubes
-
public Vertex2D get(Tuple2D t)
get
in interface Vertex2DSpaceInterface
t
-
public Vertex2D get(double x, double y)
Vertex2DSpaceInterface
get
in interface Vertex2DSpaceInterface
x
- coordinatey
- coordinate
public Vertex2D get(double[] xy)
public void set(Vertex2D v)
Vertex2DSpaceInterface
set
in interface Vertex2DSpaceInterface
public void remove(Vertex2D v)
Vertex2DSpaceInterface
remove
in interface Vertex2DSpaceInterface
public void clear()
Vertex2DSpaceInterface
clear
in interface Vertex2DSpaceInterface
public static Vertex2D[] convert(Vertex2DSpace vs, Tuple2D[] array)
public static void testArrays(Tuple2D[] first, Tuple2D[] 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 |