org.mt4j.util.math
Class Vertex

java.lang.Object
  extended by org.mt4j.util.math.Vector3D
      extended by org.mt4j.util.math.Vertex
Direct Known Subclasses:
BezierVertex

public class Vertex
extends Vector3D

    

A point in space for describing geometry.

Author:
Christopher Ruff

Field Summary
 
Fields inherited from class org.mt4j.util.math.Vector3D
BEZIERVERTEX, VECTOR, VERTEX, w, x, X_AXIS, y, Y_AXIS, z, Z_AXIS, ZERO_VECTOR
 
Constructor Summary
Vertex()
          Instantiates a new vertex. (0,0,0)
Vertex(float x, float y)
          Instantiates a new vertex with z=0.
Vertex(float x, float y, float z)
          Instantiates a new vertex.
Vertex(float x, float y, float z, float w)
          Instantiates a new vertex.
Vertex(float x, float y, float z, float textureX, float textureY)
          Instantiates a new vertex.
Vertex(float x, float y, float z, float r, float g, float b, float a)
          Instantiates a new vertex.
Vertex(float x, float y, float z, float textureX, float textureY, float r, float g, float b, float a)
          Instantiates a new vertex.
Vertex(float x, float y, float z, float w, float textureU2, float textureV2, float r, float g, float b, float a)
          Instantiates a new vertex.
Vertex(Vector3D vector)
          Instantiates a new vertex.
 
Method Summary
 boolean equalsVector(Vector3D vertex)
          Checks if the two vectors have the same components (XYZW).
 float getA()
          Gets the a.
 Vector3D getAdded(Vector3D v)
          NOTE: texture coordinates and color of the calling vector are kept.
 float getB()
          Gets the b.
 Vector3D getCopy()
          Copy the vector.
 Vector3D getCross(Vector3D v)
          Calculate the cross product with another vector.
static java.util.ArrayList<Vertex[]> getDeepVertexArrayCopy(java.util.ArrayList<Vertex[]> vertices)
          Returns a list of exact copies of the provided vertices.
static Vertex[] getDeepVertexArrayCopy(Vertex[] vertices)
          Returns an array of exact copies of the provided vertices.
 float getG()
          Gets the g.
 float getR()
          Gets the r.
 Vector3D getSubtracted(Vector3D v)
          NOTE: texture coordinates of the calling vector are kept.
 float getTexCoordU()
          Gets the tex coord u.
 float getTexCoordV()
          Gets the tex coord v.
static Vertex[] scaleVectorArray(Vertex[] inputArray, Vector3D scalingPoint, float factor)
          scales the Vertex[] around the scalingpoint by the given factor evenly in the X and Y direction.
static Vertex[] scaleVectorArray(Vertex[] inputArray, Vector3D scalingPoint, float X, float Y, float Z)
          scales the Vertex[] around the scalingpoint by the factors given for each dimension.
 void setA(float a)
          Sets the a.
 void setB(float b)
          Sets the b.
 void setG(float g)
          Sets the g.
 void setR(float r)
          Sets the r.
 void setRGBA(float r, float g, float b, float a)
          Sets the rgba.
 void setTexCoordU(float coordinateX)
          Sets the tex coord u.
 void setTexCoordV(float coordinateY)
          Sets the tex coord v.
static Vertex[] transFormArray(Matrix transformMatrix, Vertex[] points)
          Multiplicates all Vector3D of the Vector3D array with the given transformation matrix, thus transforming them.
static Vertex[] translateArray(Vertex[] inputArray, Vector3D directionVector)
          translates an array of Vertex by the given amounts in the directionvector.
static Vertex[] xRotateVectorArray(Vertex[] inputArray, Vector3D rotationPoint, float degree)
          rotates the Vertex array around the rotationpoint by the given degree.
static Vertex[] yRotateVectorArray(Vertex[] inputArray, Vector3D rotationPoint, float degree)
          rotates the Vertex array around the rotationpoint by the given degree.
static Vertex[] zRotateVectorArray(Vertex[] inputArray, Vector3D rotationPoint, float degree)
          rotates the Vertex array around the rotationpoint by the given degree.
 
Methods inherited from class org.mt4j.util.math.Vector3D
addLocal, angleBetween, angleBetween, crossLocal, distance, distance, distance2D, distance2D, distanceSquared, divideLocal, dot, equalsVectorWithTolerance, getDeepVertexArrayCopy, getInterpolatedTo, getInverted, getJava2DPoint, getLimited, getNormalized, getScaled, getType, getW, getX, getY, getZ, invertLocal, length, lengthSquared, normalizeLocal, rotateAroundAxisLocal, rotateX, rotateX, rotateXVectorArray, rotateY, rotateY, rotateYVectorArray, rotateZ, rotateZ, rotateZVectorArray, scaleLocal, scaleVectorArray, scaleVectorArray, set, setType, setValues, setW, setX, setXYZ, setXYZW, setY, setZ, subtractLocal, toArray, toString, transform, transFormArrayLocal, transformDirectionVector, transformNormal, translate, translateVectorArray
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Vertex

public Vertex()
Instantiates a new vertex. (0,0,0)


Vertex

public Vertex(float x,
              float y)
Instantiates a new vertex with z=0.

Parameters:
x - the x
y - the y

Vertex

public Vertex(float x,
              float y,
              float z)
Instantiates a new vertex.

Parameters:
x - the x
y - the y
z - the z

Vertex

public Vertex(Vector3D vector)
Instantiates a new vertex.

Parameters:
vector - the vector

Vertex

public Vertex(float x,
              float y,
              float z,
              float w)
Instantiates a new vertex.

Parameters:
x - the x
y - the y
z - the z
w - the w

Vertex

public Vertex(float x,
              float y,
              float z,
              float textureX,
              float textureY)
Instantiates a new vertex.

Parameters:
x - the x
y - the y
z - the z
textureX - the texture x
textureY - the texture y

Vertex

public Vertex(float x,
              float y,
              float z,
              float r,
              float g,
              float b,
              float a)
Instantiates a new vertex.

Parameters:
x - the x
y - the y
z - the z
r - the r
g - the g
b - the b
a - the a

Vertex

public Vertex(float x,
              float y,
              float z,
              float textureX,
              float textureY,
              float r,
              float g,
              float b,
              float a)
Instantiates a new vertex.

Parameters:
x - the x
y - the y
z - the z
textureX - the texture x
textureY - the texture y
r - the r
g - the g
b - the b
a - the a

Vertex

public Vertex(float x,
              float y,
              float z,
              float w,
              float textureU2,
              float textureV2,
              float r,
              float g,
              float b,
              float a)
Instantiates a new vertex.

Parameters:
x - the x
y - the y
z - the z
w - the w
textureU2 - the texture u2
textureV2 - the texture v2
r - the r
g - the g
b - the b
a - the a
Method Detail

getDeepVertexArrayCopy

public static Vertex[] getDeepVertexArrayCopy(Vertex[] vertices)
Returns an array of exact copies of the provided vertices.

Parameters:
vertices - the vertices
Returns:
the deep vertex array copy

getDeepVertexArrayCopy

public static java.util.ArrayList<Vertex[]> getDeepVertexArrayCopy(java.util.ArrayList<Vertex[]> vertices)
Returns a list of exact copies of the provided vertices.

Parameters:
vertices - the vertices
Returns:
the deep vertex array copy

transFormArray

public static Vertex[] transFormArray(Matrix transformMatrix,
                                      Vertex[] points)
Multiplicates all Vector3D of the Vector3D array with the given transformation matrix, thus transforming them.
Make a deepcopy of the vectors first if you dont want the originals being altered!

Parameters:
points - the points
transformMatrix - the transform matrix
Returns:
the transformed vector array

translateArray

public static Vertex[] translateArray(Vertex[] inputArray,
                                      Vector3D directionVector)
translates an array of Vertex by the given amounts in the directionvector.

Parameters:
inputArray - the input array
directionVector - the direction vector
Returns:
the vertex[]

xRotateVectorArray

public static Vertex[] xRotateVectorArray(Vertex[] inputArray,
                                          Vector3D rotationPoint,
                                          float degree)
rotates the Vertex array around the rotationpoint by the given degree.

Parameters:
inputArray - the input array
rotationPoint - the rotation point
degree - the degree
Returns:
the rotated Vertex array

yRotateVectorArray

public static Vertex[] yRotateVectorArray(Vertex[] inputArray,
                                          Vector3D rotationPoint,
                                          float degree)
rotates the Vertex array around the rotationpoint by the given degree.

Parameters:
rotationPoint - the rotation point
degree - the degree
inputArray - the input array
Returns:
the rotated Vertex array

zRotateVectorArray

public static Vertex[] zRotateVectorArray(Vertex[] inputArray,
                                          Vector3D rotationPoint,
                                          float degree)
rotates the Vertex array around the rotationpoint by the given degree.

Parameters:
rotationPoint - the rotation point
degree - the degree
inputArray - the input array
Returns:
the rotated vector3D array

scaleVectorArray

public static Vertex[] scaleVectorArray(Vertex[] inputArray,
                                        Vector3D scalingPoint,
                                        float factor)
scales the Vertex[] around the scalingpoint by the given factor evenly in the X and Y direction.

Parameters:
inputArray - the input array
scalingPoint - the scaling point
factor - the factor
Returns:
the resulting vector array

scaleVectorArray

public static Vertex[] scaleVectorArray(Vertex[] inputArray,
                                        Vector3D scalingPoint,
                                        float X,
                                        float Y,
                                        float Z)
scales the Vertex[] around the scalingpoint by the factors given for each dimension.

Parameters:
inputArray - the input array
scalingPoint - the scaling point
X - the x
Y - the y
Z - the z
Returns:
the resulting vector array

getAdded

public Vector3D getAdded(Vector3D v)
NOTE: texture coordinates and color of the calling vector are kept.

Overrides:
getAdded in class Vector3D
Parameters:
v - the v
Returns:
an new Vector with the result of the addition

getSubtracted

public Vector3D getSubtracted(Vector3D v)
NOTE: texture coordinates of the calling vector are kept.

Overrides:
getSubtracted in class Vector3D
Parameters:
v - the v
Returns:
an new Vector with the result of the substraction

getCross

public Vector3D getCross(Vector3D v)
Calculate the cross product with another vector.

Overrides:
getCross in class Vector3D
Parameters:
v - the v
Returns:
the cross product

equalsVector

public boolean equalsVector(Vector3D vertex)
Description copied from class: Vector3D
Checks if the two vectors have the same components (XYZW).
Does NOT check for object identity equality!

Overrides:
equalsVector in class Vector3D
Parameters:
vertex - the vector3 d
Returns:
true, if equals vector

getCopy

public Vector3D getCopy()
Copy the vector.

Overrides:
getCopy in class Vector3D
Returns:
a copy of the vector

getTexCoordU

public float getTexCoordU()
Gets the tex coord u.

Returns:
the tex coord u

setTexCoordU

public void setTexCoordU(float coordinateX)
Sets the tex coord u.

Parameters:
coordinateX - the new tex coord u

getTexCoordV

public float getTexCoordV()
Gets the tex coord v.

Returns:
the tex coord v

setTexCoordV

public void setTexCoordV(float coordinateY)
Sets the tex coord v.

Parameters:
coordinateY - the new tex coord v

getA

public float getA()
Gets the a.

Returns:
the a

setA

public void setA(float a)
Sets the a.

Parameters:
a - the new a

getB

public float getB()
Gets the b.

Returns:
the b

setB

public void setB(float b)
Sets the b.

Parameters:
b - the new b

getG

public float getG()
Gets the g.

Returns:
the g

setG

public void setG(float g)
Sets the g.

Parameters:
g - the new g

getR

public float getR()
Gets the r.

Returns:
the r

setR

public void setR(float r)
Sets the r.

Parameters:
r - the new r

setRGBA

public void setRGBA(float r,
                    float g,
                    float b,
                    float a)
Sets the rgba.

Parameters:
r - the r
g - the g
b - the b
a - the a