Field Summary |
|
float | x |
float | y |
float | z |
Constructor Summary |
Vector3f() Default constructor initializing all components to zero |
Vector3f(float x, float y, float z) Constructs a vector using 3 components |
Vector3f(Vector3f vec) Constructs a copy of vec |
Method Summary |
|
void |
add(float scalar) Add a scalar to all components of this |
void |
add(Vector3f vec) Add a vector to this |
void |
cross(Vector3f a, Vector3f b) Sets this to the cross product of a and b |
float |
distance(Vector3f vec) Returns the distance between this and the argument vector |
void |
div(float scalar) Divides a scalar from all components of this |
void |
div(Vector3f vec) Divides a vector from this (component wise division) |
float |
dot(Vector3f b) Computes the 3d dot product of this and a second vector |
Vector3f |
dup() Creates a copy |
bool | equals(Object obj) |
float |
length() Returns the euclidean length of this vector |
void |
lerp(float t, Vector3f a, Vector3f b) Sets this to a linear interpolation between a and b |
void |
mul(float scalar) Multiplies a scalar to all components of this |
void |
mul(Vector3f vec) Multiplies a vector to this (component wise multiplication) |
float |
normalize() Normalizes the vector (make the euclidean length to 1) |
void |
set(float scalar) Sets all components of the vector with a scalar |
void |
set(float x, float y, float z) Sets the vector using 3 components |
void |
set(Vector3f vec) Sets the vector's elements from the elements of vec |
void |
setZero() Sets the vector's elements to zero |
float |
sqrDistance(Vector3f vec) Returns the squared distance between this and the argument vector |
float |
sqrLength() Returns the squared euclidean length of this vector |
void |
sub(float scalar) Subtract a scalar from all components of this |
void |
sub(Vector3f vec) Subtract a vector from this |
String | toString() |
Field Detail |
Constructor Detail |
public Vector3f()
Default constructor initializing all components to zero
public Vector3f(float x, float y, float z)
Constructs a vector using 3 components
public Vector3f(Vector3f vec)
Constructs a copy of vec
Method Detail |
public final void add(float scalar)
Add a scalar to all components of this
public final void add(Vector3f vec)
Add a vector to this
public final void cross(Vector3f a, Vector3f b)
Sets this to the cross product of a and b
Pseudo code: this = a (x) b. All parameters including this might be the same reference.
Parameters:
a | - | first vector | |
b | - | second vector |
Since:
2.2.4.3
public final float distance(Vector3f vec)
Returns the distance between this and the argument vector
Parameters:
vec | - | the argument vector |
Returns:
the distance between this and vec
Since:
2.2.4.3
public final void div(float scalar)
Divides a scalar from all components of this
public final void div(Vector3f vec)
Divides a vector from this (component wise division)
public final float dot(Vector3f b)
Computes the 3d dot product of this and a second vector
Pseudo code: result = this.x*b.x + this.y*b.y + this.z*b.z
Parameters:
b | - | second vector |
Returns:
dot product of this and b
Since:
2.6.2.0
public final Vector3f dup()
Creates a copy
public bool equals(Object obj)
public final float length()
Returns the euclidean length of this vector
Returns:
the squared length of this
public final void lerp(float t, Vector3f a, Vector3f b)
Sets this to a linear interpolation between a and b
Pseudo code: this = (1-t) * a + t * b. All parameters including this might be the same reference.
Parameters:
a | - | first vector | |
b | - | second vector |
public final void mul(float scalar)
Multiplies a scalar to all components of this
public final void mul(Vector3f vec)
Multiplies a vector to this (component wise multiplication)
public final float normalize()
Normalizes the vector (make the euclidean length to 1)
If the length is currently 0, the vector will be set to the zero vector Returns the length prior to normalization.
public final void set(float scalar)
Sets all components of the vector with a scalar
x, y, z will be set to scalar
Since:
2.6.2.0
public final void set(float x, float y, float z)
Sets the vector using 3 components
public final void set(Vector3f vec)
Sets the vector's elements from the elements of vec
public final void setZero()
Sets the vector's elements to zero
public final float sqrDistance(Vector3f vec)
Returns the squared distance between this and the argument vector
Is slightly faster than distance().
Parameters:
vec | - | the argument vector |
Returns:
the squared distance between this and vec
Since:
2.2.4.3
public final float sqrLength()
Returns the squared euclidean length of this vector
Is slightly faster than length().
Returns:
the squared length of this
public final void sub(float scalar)
Subtract a scalar from all components of this
public final void sub(Vector3f vec)
Subtract a vector from this
public String toString()