public final class Vector3F
extends java.lang.Object
Vector3F denotes a 3-dimensional vector with elements denoted by X, Y and Z.
This class is immutable and therefore thread-safe.
| Modifier and Type | Field and Description |
|---|---|
float |
x
The element value along the X-axis.
|
float |
y
The element value along the Y-axis.
|
float |
z
The element value along the Z-axis.
|
| Constructor and Description |
|---|
Vector3F()
Constructs a new
Vector3F instance given its element values 0.0F, 0.0F and 0.0F. |
Vector3F(float x,
float y,
float z)
Constructs a new
Vector3F instance given its element values x, y and z. |
Vector3F(Point3F p)
Constructs a new
Vector3F instance given a Point3F. |
| Modifier and Type | Method and Description |
|---|---|
Vector3F |
add(Vector3F v)
Adds
v to this Vector3F instance. |
Vector3F |
crossProduct(Vector3F v)
Computes the cross product between this
Vector3F instance and v. |
static Vector3F |
direction(float u,
float v)
Returns a
Vector3F based on the U- and V-coordinates u and v. |
static Vector3F |
direction(Point3F eye,
Point3F lookAt)
Returns a
Vector3F pointing in the direction from eye to lookAt. |
Vector3F |
divide(float s)
Divides this
Vector3F instance by s. |
float |
dotProduct(Vector3F v)
Returns the dot product between this
Vector3F instance and v. |
boolean |
equals(java.lang.Object object)
Compares
object to this Vector3F instance for equality. |
int |
hashCode()
Returns a hash code for this
Vector3F instance. |
float |
length()
Returns the length of this
Vector3F instance. |
float |
lengthSquared()
Returns the length of this
Vector3F instance in squared form. |
Vector3F |
multiply(float s)
Multiplies this
Vector3F instance with s. |
Vector3F |
negate()
Negates this
Vector3F instance. |
static Vector3F |
normal(Point3F a,
Point3F b,
Point3F c)
Returns a
Vector3F denoting the normal of the plane defined by a, b and c. |
Vector3F |
normalize()
Normalizes this
Vector3F instance. |
static Vector3F |
normalNormalized(Point3F a,
Point3F b,
Point3F c)
Returns a
Vector3F denoting the normalized normal of the plane defined by a, b and c. |
Vector3F |
subtract(Vector3F v)
Subtracts
v from this Vector3F instance. |
java.lang.String |
toString()
Returns a
String representation of this Vector3F instance. |
Vector3F |
transform(Matrix44F m)
Performs a transformation.
|
Vector3F |
transform(OrthoNormalBasis33F orthoNormalBasis)
Performs a transformation.
|
Vector3F |
transformReverse(OrthoNormalBasis33F orthoNormalBasis)
Performs a transformation in reverse order.
|
Vector3F |
transformTranspose(Matrix44F m)
Performs a transformation in transpose order.
|
static Vector3F |
x()
Returns a new
Vector3F instance equivalent to new Vector3F(1.0F, 0.0F, 0.0F). |
static Vector3F |
x(float x)
Returns a new
Vector3F instance equivalent to new Vector3F(x, 0.0F, 0.0F). |
static Vector3F |
y()
Returns a new
Vector3F instance equivalent to new Vector3F(0.0F, 1.0F, 0.0F). |
static Vector3F |
y(float y)
Returns a new
Vector3F instance equivalent to new Vector3F(0.0F, y, 0.0F). |
static Vector3F |
z()
Returns a new
Vector3F instance equivalent to new Vector3F(0.0F, 0.0F, 1.0F). |
static Vector3F |
z(float z)
Returns a new
Vector3F instance equivalent to new Vector3F(0.0F, 0.0F, z). |
public final float x
public final float y
public final float z
public Vector3F()
Vector3F instance given its element values 0.0F, 0.0F and 0.0F.
Calling this constructor is equivalent to the following:
new Vector3F(0.0F, 0.0F, 0.0F)
public Vector3F(float x,
float y,
float z)
Vector3F instance given its element values x, y and z.x - the element value along the X-axisy - the element value along the Y-axisz - the element value along the Z-axispublic Vector3F(Point3F p)
Vector3F instance given a Point3F.
Calling this constructor is equivalent to the following:
new Vector3F(p.x, p.y, p.z);
If p is null, a NullPointerException will be thrown.p - a Point3Fjava.lang.NullPointerException - thrown if, and only if, p is nullpublic java.lang.String toString()
String representation of this Vector3F instance.toString in class java.lang.ObjectString representation of this Vector3F instancepublic Vector3F add(Vector3F v)
v to this Vector3F instance.
Returns a new Vector3F instance with the result of the addition.
If v is null, a NullPointerException will be thrown.
v - the Vector3F to addVector3F instance with the result of the additionjava.lang.NullPointerException - thrown if, and only if, v is nullpublic Vector3F crossProduct(Vector3F v)
Vector3F instance and v.
Returns a new Vector3F instance with the result of the computation.
If v is null, a NullPointerException will be thrown.
v - a Vector3FVector3F instance with the result of the computationjava.lang.NullPointerException - thrown if, and only if, v is nullpublic Vector3F divide(float s)
Vector3F instance by s.
Returns a new Vector3F instance with the result of the division.
s - the scalar value to divide byVector3F instance with the result of the divisionpublic Vector3F multiply(float s)
Vector3F instance with s.
Returns a new Vector3F instance with the result of the multiplication.
s - the scalar value to multiply withVector3F instance with the result of the multiplicationpublic Vector3F negate()
Vector3F instance.
Returns a new Vector3F instance with the result of the negation.
Vector3F instance with the result of the negationpublic Vector3F normalize()
Vector3F instance.
Returns a new Vector3F instance with the result of the normalization.
Vector3F instance with the result of the normalizationpublic Vector3F subtract(Vector3F v)
v from this Vector3F instance.
Returns a new Vector3F instance with the result of the subtraction.
If v is null, a NullPointerException will be thrown.
v - the Vector3 to subtractVector3F instance with the result of the subtractionjava.lang.NullPointerException - thrown if, and only if, v is nullpublic Vector3F transform(Matrix44F m)
Returns a new Vector3F with the result of the transformation.
If m is null, a NullPointerException will be thrown.
m - the Matrix44F to perform the transformation withVector3F with the result of the transformationjava.lang.NullPointerException - thrown if, and only if, m is nullpublic Vector3F transform(OrthoNormalBasis33F orthoNormalBasis)
Returns a new Vector3F with the result of the transformation.
If orthoNormalBasis is null, a NullPointerException will be thrown.
orthoNormalBasis - an OrthoNormalBasis33FVector3F with the result of the transformationjava.lang.NullPointerException - thrown if, and only if, orthoNormalBasis is nullpublic Vector3F transformReverse(OrthoNormalBasis33F orthoNormalBasis)
Returns a new Vector3F with the result of the transformation.
If orthoNormalBasis is null, a NullPointerException will be thrown.
orthoNormalBasis - an OrthoNormalBasis33FVector3F with the result of the transformationjava.lang.NullPointerException - thrown if, and only if, orthoNormalBasis is nullpublic Vector3F transformTranspose(Matrix44F m)
Returns a new Vector3F with the result of the transformation.
If m is null, a NullPointerException will be thrown.
m - a Matrix44FVector3F with the result of the transformationjava.lang.NullPointerException - thrown if, and only if, m is nullpublic boolean equals(java.lang.Object object)
object to this Vector3F instance for equality.
Returns true if, and only if, object is an instance of Vector3F, and their respective values are equal, false otherwise.
equals in class java.lang.Objectobject - the Object to compare to this Vector3F instance for equalitytrue if, and only if, object is an instance of Vector3F, and their respective values are equal, false otherwisepublic float dotProduct(Vector3F v)
Vector3F instance and v.
If v is null, a NullPointerException will be thrown.
v - a Vector3FVector3F instance and vjava.lang.NullPointerException - thrown if, and only if, v is nullpublic float length()
Vector3F instance.Vector3F instancepublic float lengthSquared()
Vector3F instance in squared form.Vector3F instance in squared formpublic int hashCode()
Vector3F instance.hashCode in class java.lang.ObjectVector3F instancepublic static Vector3F direction(float u, float v)
Vector3F based on the U- and V-coordinates u and v.u - the U-coordinatev - the V-coordinateVector3F based on the U- and V-coordinates u and vpublic static Vector3F direction(Point3F eye, Point3F lookAt)
Vector3F pointing in the direction from eye to lookAt.
If either eye or lookAt are null, a NullPointerException will be thrown.
eye - a Point3F denoting the eye to look fromlookAt - a Point3F denoting the target to look atVector3F pointing in the direction from eye to lookAtjava.lang.NullPointerException - thrown if, and only if, either eye or lookAt are nullpublic static Vector3F normal(Point3F a, Point3F b, Point3F c)
Vector3F denoting the normal of the plane defined by a, b and c.
If either a, b or c are null, a NullPointerException will be thrown.
a - one of the three Point3Fs in the planeb - one of the three Point3Fs in the planec - one of the three Point3Fs in the planeVector3F denoting the normal of the plane defined by a, b and cjava.lang.NullPointerException - thrown if, and only if, either a, b or c are nullpublic static Vector3F normalNormalized(Point3F a, Point3F b, Point3F c)
Vector3F denoting the normalized normal of the plane defined by a, b and c.
If either a, b or c are null, a NullPointerException will be thrown.
a - one of the three Point3Fs in the planeb - one of the three Point3Fs in the planec - one of the three Point3Fs in the planeVector3F denoting the normalized normal of the plane defined by a, b and cjava.lang.NullPointerException - thrown if, and only if, either a, b or c are nullpublic static Vector3F x()
Vector3F instance equivalent to new Vector3F(1.0F, 0.0F, 0.0F).Vector3F instance equivalent to new Vector3F(1.0F, 0.0F, 0.0F)public static Vector3F x(float x)
Vector3F instance equivalent to new Vector3F(x, 0.0F, 0.0F).x - the element value along the X-axisVector3F instance equivalent to new Vector3F(x, 0.0F, 0.0F)public static Vector3F y()
Vector3F instance equivalent to new Vector3F(0.0F, 1.0F, 0.0F).Vector3F instance equivalent to new Vector3F(0.0F, 1.0F, 0.0F)public static Vector3F y(float y)
Vector3F instance equivalent to new Vector3F(0.0F, y, 0.0F).y - the element value along the Y-axisVector3F instance equivalent to new Vector3F(0.0F, y, 0.0F)public static Vector3F z()
Vector3F instance equivalent to new Vector3F(0.0F, 0.0F, 1.0F).Vector3F instance equivalent to new Vector3F(0.0F, 0.0F, 1.0F)public static Vector3F z(float z)
Vector3F instance equivalent to new Vector3F(0.0F, 0.0F, z).z - the element value along the Z-axisVector3F instance equivalent to new Vector3F(0.0F, 0.0F, z)