|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.threed.jpct.SimpleVector
SimpleVector is a class that represents a basic three-dimensional vector. Almost every passing of vectors is done using SimpleVector or at least a SimpleVector-variant is offered (sometimes (float x, float y, float z) is also offered for historical and/or performance reasons).
Field Summary | |
static SimpleVector |
ORIGIN
A SimpleVector representing the origin (0,0,0) |
float |
x
The x component of the vector |
float |
y
The y component of the vector |
float |
z
The z component of the vector |
Constructor Summary | |
SimpleVector()
Creates a new SimpleVector and sets the x,y and z components to zero |
|
SimpleVector(double x,
double y,
double z)
Creates a new SimpleVector by setting the x,y and z components of the vector. |
|
SimpleVector(float[] vector)
Creates a new SimpleVector from an array[3] of floats |
|
SimpleVector(float x,
float y,
float z)
Creates a new SimpleVector by setting the x,y and z components of the vector |
|
SimpleVector(SimpleVector s)
Creates a new SimpleVector from an existing one |
Method Summary | |
void |
add(SimpleVector vec)
Adds another SimpleVector to this SimpleVector without creating a new instance. |
SimpleVector |
calcAdd(SimpleVector vec)
Add two SimpleVectors to a new SimpleVector. |
float |
calcAngle(SimpleVector vec)
Calculates the angle between this SimpleVector and another one. |
float |
calcAngleFast(SimpleVector vec)
Calculates the angle between this SimpleVector and another one. |
SimpleVector |
calcCross(SimpleVector vec)
Calculates the cross product of two SimpleVectors. |
float |
calcDot(SimpleVector vec)
Calculates the dot product of two SimpleVectors. |
SimpleVector |
calcSub(SimpleVector vec)
Calculates the difference vector of two SimpleVectors. |
static SimpleVector |
create()
Alternative way of creating a SimpleVector. |
static SimpleVector |
create(float x,
float y,
float z)
Alternative way of creating a SimpleVector. |
static SimpleVector |
create(SimpleVector sv)
Alternative way of creating a SimpleVector. |
void |
createNormal(SimpleVector p1,
SimpleVector p2,
SimpleVector p3)
Makes this SimpleVector a normal vector of the plane in which all the three points lie. |
float |
distance(SimpleVector pos)
Returns the distance between this SimpleVector and another position vector. |
boolean |
equals(java.lang.Object obj)
Overrides the equals()-method from java.lang.Object. |
Matrix |
getRotationMatrix()
Creates a rotation matrix that can be used to rotate a vector pointing to (0,0,1) to match the direction of this vector. |
Matrix |
getRotationMatrix(Matrix mat)
Creates a rotation matrix that can be used to rotate a vector pointing to (0,0,1) to match the direction of this vector. |
Matrix |
getRotationMatrix(Matrix mat,
SimpleVector up)
Creates a rotation matrix that can be used to rotate a vector pointing to (0,0,1) to match the direction of this vector. |
Matrix |
getRotationMatrix(SimpleVector up)
Creates a rotation matrix that can be used to rotate a vector pointing to (0,0,1) to match the direction of this vector. |
int |
hashCode()
Overrides hashCode() from java.lang.Object. |
float |
length()
Gives the length of this SimpleVector |
void |
makeEqualLength(SimpleVector vec)
Makes this SimpleVector the length of another SimpleVector, but only if its longer than this. |
void |
matMul(Matrix mat)
Multiplies the SimpleVector with a matrix, i.e. it applies the matrix's transformation to the SimpleVector. |
SimpleVector |
normalize()
Normalizes a SimpleVector and returns a normalized vector as a new SimpleVector. |
SimpleVector |
normalize(SimpleVector sv)
Normalizes a SimpleVector and returns a normalized vector as a new SimpleVector. |
SimpleVector |
reflect(SimpleVector faceNormal)
Reflects this vector on a plane with the given normal. |
void |
rotate(Matrix mat)
Similar to matMul(), but uses only the rotational part of the matrix. |
SimpleVector |
rotate(SimpleVector rotVector)
Rotates this SimpleVector using the angles (x,y,z) of rotVector. |
void |
rotateAxis(SimpleVector axis,
float angle)
Rotates the vector around an arbitrary axis. |
void |
rotateX(float angle)
Rotates the SimpleVector around the x-axis. |
void |
rotateY(float angle)
Rotates the SimpleVector around the y-axis. |
void |
rotateZ(float angle)
Rotates the SimpleVector around the z-axis. |
void |
scalarMul(float scalar)
Multiplies the SimpleVector with a scalar. |
void |
set(float x,
float y,
float z)
Sets the x,y and z values of the SimpleVector to the given floats. |
void |
set(SimpleVector s)
Sets the x,y and z values of this SimpleVector to the ones of the given SimpleVector. |
void |
sub(SimpleVector vec)
Subtracts another SimpleVector from this SimpleVector without creating a new instance. |
float[] |
toArray()
Returns an float[3]-array containing the components of the vector so that [0]=x, [1]=y and [2]=z. |
java.lang.String |
toString()
Returns this SimpleVector as a String. |
Methods inherited from class java.lang.Object |
getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final SimpleVector ORIGIN
public float x
public float y
public float z
Constructor Detail |
public SimpleVector(float x, float y, float z)
x
- the x componenty
- the y componentz
- the z componentpublic SimpleVector(double x, double y, double z)
x
- the x componenty
- the y componentz
- the z componentpublic SimpleVector(SimpleVector s)
s
- the SimpleVector to "copy"public SimpleVector()
public SimpleVector(float[] vector)
vector
- the array containing the x, y and z components of the vector
in [0],[1] and [2].Method Detail |
public static SimpleVector create()
public static SimpleVector create(float x, float y, float z)
x
- the x componenty
- the y componentz
- the z component
public static SimpleVector create(SimpleVector sv)
sv
- the source vector
public void set(float x, float y, float z)
public void set(SimpleVector s)
public float[] toArray()
public java.lang.String toString()
public boolean equals(java.lang.Object obj)
obj
- the SimpleVector that should be compared to this one
public int hashCode()
public SimpleVector rotate(SimpleVector rotVector)
rotVector
- the rotation vector containing the angles for the rotations
around x,y and z axis.
public void rotateX(float angle)
angle
- the anglepublic void rotateY(float angle)
angle
- the anglepublic void rotateZ(float angle)
angle
- the anglepublic SimpleVector normalize()
public SimpleVector normalize(SimpleVector sv)
sv
- the SimpleVector to fill
public void createNormal(SimpleVector p1, SimpleVector p2, SimpleVector p3)
p1
- the first pointp2
- the second pointp3
- the third pointpublic float length()
public float distance(SimpleVector pos)
public SimpleVector calcCross(SimpleVector vec)
vec
- the second SimpleVector
public float calcDot(SimpleVector vec)
vec
- the second SimpleVector
public SimpleVector calcSub(SimpleVector vec)
vec
- the second SimpleVector
public SimpleVector calcAdd(SimpleVector vec)
vec
- the second SimpleVector
public float calcAngleFast(SimpleVector vec)
vec
- the other vector
public float calcAngle(SimpleVector vec)
vec
- the other vector
public void scalarMul(float scalar)
scalar
- the scalar to multiply withpublic void matMul(Matrix mat)
mat
- Matrix the matrix (usually a rotation or a translation matrix)public void rotate(Matrix mat)
mat
- Matrix the rotation matrixmatMul(Matrix)
public void rotateAxis(SimpleVector axis, float angle)
axis
- a direction-vector pointing into the axis directionangle
- the angle of the rotationpublic SimpleVector reflect(SimpleVector faceNormal)
faceNormal
- the face normal of the reflective plane
public void add(SimpleVector vec)
vec
- the SimpleVector to addpublic void sub(SimpleVector vec)
vec
- the SimpleVector to subtractpublic void makeEqualLength(SimpleVector vec)
vec
- the SimpleVector that defines the lengthpublic Matrix getRotationMatrix()
public Matrix getRotationMatrix(SimpleVector up)
up
- the up vector used in the calculation
public Matrix getRotationMatrix(Matrix mat)
mat
- the Matrix to fill
public Matrix getRotationMatrix(Matrix mat, SimpleVector up)
up
- the up vector used in the calculationmat
- the Matrix to fill
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |