Java 3D API Specification
A P P E N D I X A |
Math Objects |
Mathematical objects allow Java 3D users to represent and manipulate low-level mathematical constructs such as vectors and matrices. Math objects also define specific operations that allow users to manipulate them in appropriate ways.
Java 3D needs these vector and matrix math classes. It uses them internally and also makes them available to applications for their use. However, they are not part of Java 3D. Rather, they are defined here for convenience. These classes will become more widely distributed. That is why Java 3D defines them as a separate
java.vecmath
package. Figure A-1 shows the math object hierarchy.
Figure A-1 Math Object Hierarchy
Java 3D uses tuple objects to represent and manipulate two-, three-, and four-element values.
A.1.1 Tuple2f Class
The Tuple2f class is mostly used for specifying two-element points and vectors made up of single-precision floating point x,y coordinates.
Variables
The component values of a Tuple2f are directly accessible through the public variables
x
andy
. To access the x component of a Tuple2f called upperLeftCorner, a programmer would writeupperLeftCorner.x
. The programmer would access the y component similarly.public float x public float yThe x and y coordinates, respectively.
Constructors
public Tuple2f(float x, float y) public Tuple2f(float[] t) public Tuple2f(Tuple2f t1) public Tuple2f()These four constructors each return a new Tuple2f. The first constructor generates a Tuple2f from two floating point numbers
x
andy
. The second constructor generates a Tuple2f from the first two elements of arrayt
. The third constructor generates a Tuple2f from the tuplet1
. The final constructor generates a Tuple2f with value (0.0, 0.0).Methods
public final void set(float x, float y) public final void set(float[] t) public final void set(Tuple2f t1) public final void get(float[] t)The
set
methods set the value of tuplethis
to the values provided. Theget
method copies the values of the elements of this tuple into the arrayt
.public final void add(Tuple2f t1, Tuple2f t1) public final void add(Tuple2f t1) public final void sub(Tuple2f t1, Tuple2f t1) public final void sub(Tuple2f t1)The first
add
method computes the element-by-element sum of tuplest1
andt2
placing the result inthis
. The secondadd
method computes the element-by-element sum of this tuple and tuplet1
placing the result inthis
. The firstsub
method performs an element-by-element subtraction of tuplet2
from tuplet1
and places the result inthis
(this = t1 - t2). The secondsub
method performs an element-by-element subtraction oft1
fromthis
and places the result inthis
(this = this - t1).public final void negate(Tuple2f t1) public final void negate()The first
negate
method negates the tuplet1
, places the result inthis
, and sets the referenced object to that negated value. The secondnegate
method negates the tuplethis
and places the resulting tuple back intothis
.public final void scale(float s, Tuple2f t1) public final void scale(float s) public final void scaleAdd(float s, Tuple2f t1, Tuple2f t2)The first
scale
method multiplies each element of the tuplet1
by the scale factors
and places the resulting scaled tuple intothis
. The secondscale
method multiplies each element of this tuple by the scale factors
and places the resulting scaled tuple intothis
. The thirdscale
method scales tuplet1
by the scale factors
, adds the result to tuplet2
, and places the result into the tuplethis
.public final void absolute() public final void absolute(Tuple2f t)The first
absolute
method sets each component of this tuple to its absolute value. The secondabsolute
method sets each component of the tuple parameter to its absolute value and places the modified values into this tuple.public final void clamp(float min, float max) public final void clamp(float min, float max, Tuple2f t) public final void clampMin(float min) public final void clampMin(float min, Tuple2f t) public final void clampMax(float max)The first
clamp
method clamps this tuple to the range (low, high). The secondclamp
method clamps this tuple to the range (low, high) and places the values into tuplet
. The firstclampMin
method clamps the minimum value of this tuple to themin
parameter. The secondclampMin
method clamps the minimum value of this tuple to themin
parameter and places the values into the tuplet
. The firstclampMax
method clamps the maximum value of this tuple to themax
parameter. The secondclampMax
method clamps the maximum value of this tuple to themax
parameter and places the values into the tuplet
.public final void interpolate(Tuple2f t1, Tuple2f t2, float alpha) public final void interpolate(Tuple2f t1, float alpha)The first method linearly interpolates between tuples
t1
andt2
and places the result into this tuple (this = alpha · t1 + (1-alpha) · t2). The second method linearly interpolates between this tuple and tuplet1
and places the result into this tuple (this = alpha · this + (1-alpha) · t1).public boolean equals(Tuple2f t1)This method returns true if all of the data members of tuple
t1
are equal to the corresponding data members in this tuple.public boolean epsilonEquals(Tuple2f t1, float epsilon)This method returns true if the L-infinite distance between this tuple and tuple
t1
is less than or equal to the epsilon parameter. Otherwise, this method returns false. The L-infinite distance is equal to MAX[abs(x1 - x2), abs(y1 - y2)].public int hashCode()The
hashCode
method returns a hash number based on the data values in this object. Two Tuple2f objects with identical data values (i.e., returns true forequals(Tuple2f)
) will return the same hash number. Two vectors with different data members may return the same hash number, although this is not likely.public String toString()This method returns a string that contains the values of this Tuple2f.
A.1.1.1 Point2f Class
The Point2f class extends Tuple2f. The Point2f is a two-element point represented by single-precision floating x,y coordinates.
Constructors
public Point2f(float x, float y) public Point2f(float[] p) public Point2f(Point2f p1) public Point2f()These four constructors each return a new Point2f. The first constructor generates a Point2f from two floating point numbers
x
andy
. The second constructor generates a Point2f from the first two elements of arrayp
. The third constructor generates a Point2f from the pointp1
. The final constructor generates a Point2f with value (0.0, 0.0).Methods
public final float distanceSquared(Point2f v1) public final float distance(Point2f v1)The
distanceSquared
method computes the square of the distance between this point and pointv1
and returns the result. Thedistance
method computes the distance between this point and pointv1
and returns the result.public final float distanceL1(Point2f p1) public final float distanceLinf(Point2f p1)The
distanceL1
method computes the L - 1 (Manhattan) distance between this point and point p1. The L - 1 distance is equal to: abs(x1 - x2) + abs(y1 - y2) + abs(z1 - z2). ThedistanceLinf
method computes the L - infinite distance between this point and point p1. The L - infinite distance is equal to: MAX[abs(x1 - x2), abs(y1 - y2), abs(z1 - z2)].public final void project(Point3f p1)This method multiplies both of the x and y components of the point3f parameter
p1
by 1/z and places the projected values into this point.A.1.1.2 Vector2f Class
The Vector2f class extends Tuple2f. The Vector2f is a two-element vector represented by single-precision floating x,y coordinates.
Constructors
public Vector2f(float x, float y) public Vector2f(float[] v) public Vector2f(Vector2f v1) public Vector2f()These four constructors each return a new Vector2f. The first constructor generates a Vector2f from two floating point numbers
x
andy
. The second constructor generates a Vector2f from the first two elements of arrayv
. The third constructor generates a Vector2f from the vectorv1
. The final constructor generates a Vector2f with value (0.0, 0.0).Methods
public final float dot(Vector2f v1)The
dot
method computes the dot product between this vector and vectorv1
and returns the resulting value.public final float lengthSquared() public final float length()The
lengthSquared
method computes the square of the vector length of the vectorthis
and returns its length as a single-precision floating-point number. Thelength
method computes the vector length of the vectorthis
and returns its length as a single-precision floating-point number.public final void normalize(Vector2f v1) public final void normalize()The first
normalize
method normalizes the vectorv1
to unit length and places the result inthis
. The secondnormalize
method normalizes the vectorthis
and places the resulting unit vector back intothis
.public final float angle(Vector2f v1)This method returns the angle in radians between this vector and the vector parameter. The return value is constrained to the range [0,PI].
A.1.1.3 TexCoord2f Class
The TexCoord2f class is a subset of Tuple2f. The TexCoord2f is a two-element vector represented by single-precision floating x,y coordinates.
Constructors
public TexCoord2f(float x, float y) public TexCoord2f(float[] v) public TexCoord2f(TexCoord2f v1) public TexCoord2f()These four constructors each return a new TexCoord2f. The first constructor generates a TexCoord2f from two floating point numbers
x
andy
. The second constructor generates a TexCoord2f from the first two elements of arrayv
. The third constructor generates a TexCoord2f from the TexCoord2fv1
. The final constructor generates a TexCoord2f with value (0.0, 0.0).A.1.2 Tuple3b Class
The Tuple3b class is used for colors. This class represents a three-byte vector.
Variables
The component values of a Tuple3b are directly accessible through the public variables
x
,y
, andz
. To access thex
(red) component of a Tuple3b called myColor, a programmer would writemyColor.x
. The programmer would access the y (green) andz
(blue) components similarly.
Note: Java defines a byte as a signed integer in the range -128 to 127. However, colors are more typically represented by values in the range 0 to 255. Java 3D recognizes this and, in those cases where Color3b is used to represent color, treats the bytes as if the range were 0 to 255.
public byte x public byte y public byte zThe red, green, and blue values, respectively.
Constructors
public Tuple3b(byte b1, byte b2, byte b3) public Tuple3b(byte[] t) public Tuple3b(Tuple3b t1) public Tuple3b()These four constructors each return a new Tuple3b. The first constructor generates a Tuple3b from three bytes
b1
,b2
, andb3
. The second constructor generates a Tuple3b from the first three elements of arrayt
. The third constructor generates a Tuple3b from the byte-precision Tuple3bt1
. The final constructor generates a Tuple3b with value (0.0, 0.0, 0.0).Methods
public String toString()This method returns a string that contains the values of this Tuple3b.
public final void set(byte[] t) public final void set(Tuple3b t1) public final void get(byte[] t) public final void get(Tuple3b t1)The first
set
method sets the value of the x, y, and z data members of this Tuple3b to the values in the arrayt
of length three. The secondset
method sets the value of the x, y, and z data members of this Tuple3b to the values in the value of the argument tuplet1
. The firstget
method places the values of the x, y, and z components of this Tuple3b into the arrayt
of length three. The secondget
method places the values of the x, y, and z components of this Tuple3b into the tuplet1
.public boolean equals(Tuple3b t1)This method returns true if all of the data members of Tuple3b
v1
are equal to the corresponding data members in this tuple.public int hashCode()This method returns a hash number based on the data values in this object. Two different Tuple3b objects with identical data values (i.e., returns true for
equals(Tuple3b)
) will return the same hash number. Two tuples with different data members may return the same hash value, although this is not likely.A.1.2.1 Color3b Class
The Color3b class extends Tuple3b. The Color3b is a three-byte color value.
Constructors
public Color3b(byte c1, byte c2, byte c3) public Color3b(byte[] c) public Color3b(Color3b c1) public Color3b()These four constructors each return a new Color3b. The first constructor generates a Color3b from three bytes
c1
,c2
, andc3
. The second constructor generates a Color3b from the first three elements of arrayc
. The third constructor generates a Color3b from the byte-precision Color3bc1
. The final constructor generates a Color3b with value (0.0, 0.0, 0.0).A.1.3 Tuple3d Class
The Tuple3d class serves to represent three-vector points and vectors in double-precision floating point x, y, and z coordinates.
Variables
The component values of a Tuple3d are directly accessible through the public variables
x
,y
, andz
. To access the x component of a Tuple3d called upperLeftCorner, a programmer would writeupperLeftCorner.x
. The programmer would access the y and z components similarly.public double x public double y public double zThe x, y, and z coordinates, respectively.
Constructors
public Tuple3d(double x, double y, double z) public Tuple3d(double[] t) public Tuple3d(Tuple3d t1) public Tuple3d(Tuple3f t1) public Tuple3d()These five constructors each return a new Tuple3d. The first constructor generates a Tuple3d from three floating-point numbers
x
,y
, andz
. The second constructor generates a Tuple3d from the first three elements of arrayt
. The third constructor generates a Tuple3d from the double-precision Tuple3dt1
. The fourth constructor generates a Tuple3d from the single-precision Tuple3ft1
. The final constructor generates a Tuple3d with value (0.0, 0.0, 0.0).Methods
public final void set(double x, double y, double z) public final void set(double[] t) public final void set(Tuple3d t1) public final void set(Tuple3f t1) public final void get(double[] t) public final void get(Tuple3d t)The four
set
methods set the value of tuplethis
to the values specified or to the values of the specified vectors. The twoget
methods copy thex
,y
, andz
values into the arrayt
of length three.public final void add(Tuple3d t1, Tuple3d t2) public final void add(Tuple3d t1) public final void sub(Tuple3d t1, Tuple3d t2) public final void sub(Tuple3d t1)The first
add
method computes the element-by-element sum of tuplest1
andt2
and places the result inthis
. The secondadd
method computes the element-by-element sum of this tuple and tuplet1
and places the result intothis
. The firstsub
method performs an element-by-element subtraction of tuplet2
from tuplev1
and places the result inthis
(this = t1 - t2). The secondsub
method performs an element-by-element subtraction of tuplet1
from this tuple and places the result inthis
(this = this - t1).public final void negate(Tuple3d t1) public final void negate()The first
negate
method negates the tuplet1
, places the result inthis
, and sets the referenced object to that negated value. The secondnegate
method negates the tuplethis
and places the resulting tuple back intothis
.public final void scale(double s, Tuple3d t1) public final void scale(double s) public final void scaleAdd(double s, Tuple3d t1, Tuple3d t2)The first
scale
method multiplies each element of the tuplet1
by the scale factors
and places the resulting scaled tuple intothis
. The secondscale
method multiplies each element ofthis
tuple by the scale factors
and places the resulting scaled tuple back intothis
. ThescaleAdd
method scales the tuplet1
by the scale factors
, adds the result to the tuplet2
, and places the result into the vectorthis
.public String toString()This method returns a string that contains the values of this Tuple3d. The form is (x,y,z).
public int hashCode()This method returns a hash number based on the data values in this object. Two different Tuple3d objects with identical data values (i.e., returns true for
equals(Tuple3d)
) will return the same hash number. Two tuples with different data members may return the same hash value, although this is not likely.public boolean equals(Tuple3d v1)This method returns true if all of the data members of Tuple3d
v1
are equal to the corresponding data members in this Tuple3d.public boolean epsilonEquals(Tuple3d t1, double epsilon)This method returns true if the L-infinite distance between this tuple and tuple
t1
is less than or equal to the epsilon parameter. Otherwise, this method returns false. The L-infinite distance is equal to MAX[abs(x1 - x2), abs(y1 - y2), abs(z1 - z2)].public final void absolute() public final void absolute(Tuple3d t)The first
absolute
method sets each component of this tuple to its absolute value. The secondabsolute
method sets each component of the tuple parameter to its absolute value and places the modified values into this tuple.public final void clamp(float min, float max) public final void clamp(float min, float max, Tuple3d t) public final void clampMin(float min) public final void clampMin(float min, Tuple3d t) public final void clampMax(float max) public final void ClampMax(float max, Tuple3dt)The first
clamp
method clamps this tuple to the range (low, high). The secondclamp
method clamps this tuple to the range (low, high) and places the values into tuplet
. The firstclampMin
method clamps the minimum value of this tuple to themin
parameter. The secondclampMin
method clamps the minimum value of this tuple to themin
parameter and places the values into the tuplet
. The firstclampMax
method clamps the maximum value of this tuple to themax
parameter. The secondclampMax
method clamps the maximum value of this tuple to themax
parameter and places the values into the tuplet
.public final void interpolate(Tuple3d t1, Tuple3d t2, float alpha) public final void interpolate(Tuple3d t1, float alpha)The first interpolate method linearly interpolates between tuples
t1
andt2
and places the result into this tuple (this = alpha · t1 + (1-alpha) · t2). The second interpolate method linearly interpolates between this tuple and tuplet1
and places the result into this tuple (this = alpha · this + (1-alpha) · t1).A.1.3.1 Point3d Class
The Point3d class extends Tuple3d. The Point3d is a three-element point represented by double-precision floating x, y, and z coordinates.
Constructors
public Point3d(double x, double y, double z) public Point3d(double[] p) public Point3d(Point3d p1) public Point3d(Point3f p1) public Point3d()These five constructors each return a new Point3d. The first constructor generates a Point3d from three floating-point numbers
x
,y
, andz
. The second constructor generates a Point3d from the first three elements of arrayp
. The third constructor generates a Point3d from the double-precision Point3dp1
. The fourth constructor generates a Point3d from the single-precision Point3fp1
. The final constructor generates a Point3d with value (0.0, 0.0, 0.0).Methods
public final double distanceSquared(Point3d p1) public final double distance(Point3d p1)The
distanceSquared
method computes the square of the distance between this Point3d and the Point3dp1
and returns the result. Thedistance
method computes the distance between this Point3d and the Point3dp1
and returns the result.public final float distanceL1(Point3d p1) public final float distanceLinf(Point3d p1)The
distanceL1
method computes the L - 1 (Manhattan) distance between this point and point p1. The L - 1 distance is equal to: abs(x1 - x2) + abs(y1 - y2) + abs(z1 - z2). ThedistanceLinf
method computes the L - infinite distance between this point and point p1. The L - infinite distance is equal to: MAX[abs(x1 - x2), abs(y1 - y2), abs(z1 - z2)].public final void project(Point3d p1)This method multiplies both of the x and y components of the point3d parameter
p1
by 1/z and places the projected values into this point.A.1.3.2 Vector3d Class
The Vector3d class extends Tuple3d. The Vector3d is a three-element vector represented by double-precision floating x, y, and z coordinates.
Constructors
public Vector3d(double x, double y, double z) public Vector3d(double[] v) public Vector3d(Vector3d v1) public Vector3d(Vector3f v1) public Vector3d()These five constructors each return a new Vector3d. The first constructor generates a Vector3d from three floating-point numbers
x
,y
, andz
. The second constructor generates a Vector3d from the first three elements of arrayv
. The third constructor generates a Vector3d from the double-precision vectorv1
. The fourth constructor generates a Vector3d from the single-precision vectorv1
. The final constructor generates a Vector3d with value (0.0, 0.0, 0.0).Methods
public final void cross(Vector3d v1, Vector3d v2)The
cross
method computes the vector cross-product of vectorsv1
andv2
and places the result inthis
.public final void normalize(Vector3d v1) public final void normalize()The first
normalize
method normalizes the vectorv1
to unit length and places the result inthis
. The secondnormalize
method normalizes the vectorthis
and places the resulting unit vector back intothis
.public final double dot(Vector3d v1)The
dot
method returns the dot product of this vector and vectorv1
.public final double lengthSquared() public final double length()The
lengthSquared
method returns the squared length of this vector. Thelength
method returns the length of this vector.public final double angle(Vector3d v1)This method returns the angle in radians between this vector and the vector
v1
parameter. The return value is constrained to the range [0,PI].A.1.4 Tuple3f Class
The Tuple3f class serves to represent many different types of three-vectors: coordinates, normals, and three-component colors.
Variables
The component values of a Tuple3f are directly accessible through the public variables
x
,y
, andz
. To access the x component of a Tuple3f called upperLeftCorner, a programmer would writeupperLeftCorner.x
. The programmer would access the y and z components similarly.public float x public float y public float zThe x, y, and z coordinates, respectively.
Constructors
public Tuple3f(float x, float y, float z) public Tuple3f(float[] t) public Tuple3f(Tuple3d t1) public Tuple3f(Tuple3f t1) public Tuple3f()These five constructors each return a new Tuple3f. The first constructor generates a three-vector from three floating point numbers
x
,y
, andz
. The second constructor generates a three-vector from the first three elements of arrayt
. The third constructor generates a three-vector from the double-precision three-vectort1
. The fourth constructor generates a three-vector from the single-precision three vectort1
. The final constructor generates a three-vector with value (0.0, 0.0, 0.0).Methods
public String toString()This method returns a string that contains the values of this Tuple3f.
public final void set(float x, float y, float z) public final void set(float[] t) public final void set(Tuple3f t1) public final void set(Tuple3d t1) public final void get(float[] t) public final void get(Tuple3f t)The four
set
methods set the value of vectorthis
to the coordinates provided or to the values of the vectors provided. The firstget
method gets the value of this vector and copies the values into the arrayt
. The secondget
method gets the value of this vector and copies the values into tuplet
.public final void add(Tuple3f t1, Tuple3f t2) public final void add(Tuple3f t1) public final void sub(Tuple3f t1, Tuple3f t2) public final void sub(Tuple3f t1)The first
add
method computes the element-by-element sum of tuplest1
andt2
placing the result inthis
. The secondadd
method computes the element-by-element sum ofthis
and tuplet1
and places the result inthis
. The firstsub
method performs an element-by-element subtraction of tuple22
from tuplet1
and places the result inthis
(this = t1 - t2). The secondsub
method performs an element-by element subtraction of tuplet1
fromthis
and places the result inthis
(this = this - t1).public final void negate(Tuple3f t1) public final void negate()The first
negate
method negates the vectort1
, places the result inthis
, and sets the referenced object to that negated value. The secondnegate
method negates the vectorthis
and places the resulting unit vector back intothis
.public final void scale(float s, Tuple3f t1) public final void scale(float s) public final void scaleAdd(float s, Tuple3f t1, Tuple3f t2)The first
scale
method multiplies each element of the vectort1
by the scale factors
and places the resulting scaled vector intothis
. The secondscale
method multiples the vectorthis
by the scale factors
and replacesthis
with the scaled value. ThescaleAdd
method scales tuplet1
by the scale factors
, adds the result to tuplet2
, and places the result into the vectorthis
.public boolean equals(Tuple3f t1)This method returns true if all of the data members of tuple
t1
are equal to the corresponding data members in this Tuple3f.public boolean epsilonEquals(Tuple3f t1, float epsilon)This method returns true if the L-infinite distance between this tuple and tuple
t1
is less than or equal to the epsilon parameter. Otherwise, this method returns false. The L-infinite distance is equal to MAX[abs(x1 - x2), abs(y1 - y2), abs(z1 - z2)].public final void absolute() public final void absolute(Tuple3f t)The first
absolute
method sets each component of this tuple to its absolute value. The secondabsolute
method sets each component of the tuple parameter to its absolute value and places the modified values into this tuple.public final void clamp(float min, float max) public final void clamp(float min, float max, Tuple3f t) public final void clampMin(float min) public final void clampMin(float min, Tuple3f t) public final void clampMax(float max)The first
clamp
method clamps this tuple to the range (low, high). The secondclamp
method clamps this tuple to the range (low, high) and places the values into tuplet
. The firstclampMin
method clamps the minimum value of this tuple to themin
parameter. The secondclampMin
method clamps the minimum value of this tuple to themin
parameter and places the values into the tuplet
. The firstclampMax
method clamps the maximum value of this tuple to themax
parameter. The secondclampMax
method clamps the maximum value of this tuple to themax
parameter and places the values into the tuplet
.public final void interpolate(Tuple3f t1, Tuple3f t2, float alpha) public final void interpolate(Tuple3f t1, float alpha)The first method linearly interpolates between tuples t1 and t2 and places the result into this tuple (this = alpha · t1 + (1-alpha) · t2). The second method linearly interpolates between this tuple and tuple t1 and places the result into this tuple (this = alpha · this + (1-alpha) · t1).
int hashCode()This method returns a hash number based on the data values in this object. Two different Tuple3f objects with identical data values (i.e., returns true for
equals(Tuple3f)
) will return the same hash number. Two tuples with different data members may return the same hash value, although this is not likely.A.1.4.1 Point3f Class
The Point3f class extends Tuple3f. The Point3f is a three-element point represented by single-precision floating x, y, and z coordinates.
Constructors
public Point3f(float x, float y, float z) public Point3f(float[] p) public Point3f(Point3d p1) public Point3f(Point3f p1) public Point3f()These five constructors each return a new Point3f. The first constructor generates a point coordinate from three floating point numbers
x
,y
, andz
. The second constructor generates a point coordinate from the first three elements of arrayp
. The third constructor generates a point coordinate from the double-precision point coordinatep1
. The fourth constructor generates a point coordinate from the single-precision point coordinatep1
. The final constructor generates a point coordinate with value (0.0, 0.0, 0.0).Methods
public final float distance(Point3f p1) public final float distanceSquared(Point3f p1)The
distance
method computes the distance between this point and the pointp1
and returns the result. ThedistanceSquared
method computes the square of the distance between this point and the pointp1
and returns the result.public final float distanceL1(Point3f p1) public final float distanceLinf(Point3f p1)The
distanceL1
method computes the L - 1 (Manhattan) distance between this point and point p1. The L - 1 distance is equal to: abs(x1 - x2) + abs(y1 - y2) + abs(z1 - z2). ThedistanceLinf
method computes the L - infinite distance between this point and point p1. The L - infinite distance is equal to: MAX[abs(x1 - x2), abs(y1 - y2), abs(z1 - z2)].public final void project(Point3f p1)This method multiplies both of the x and y components of the point3f parameter
p1
by 1/z and places the projected values into this point.A.1.4.2 Vector3f Class
The Vector3f class extends Tuple3f. The Vector3f is a three-element vector represented by single-precision floating x, y, and z coordinates.
Constructors
public Vector3f(float x, float y, float z) public Vector3f(float[] v) public Vector3f(Vector3d v1) public Vector3f(Vector3f v1) public Vector3f()These five constructors each return a new Vector3f. The first constructor generates a three-vector from three floating point numbers
x
,y
, andz
. The second constructor generates a three-vector from the first three elements of arrayv
. The third constructor generates a three-vector from the double-precision three-vectorv1
. The fourth constructor generates a three-vector from the single-precision three vectorv1
. The final constructor generates a three-vector with value (0.0, 0.0, 0.0).Methods
public final float length() public final float lengthSquared()The
length
method computes the vector length of the vectorthis
and returns its length as a single-precision floating-point number. ThelengthSquared
method computes the square of the vector length of the vectorthis
and returns its length as a single-precision floating-point number.public final void cross(Vector3f v1, Vector3f v2)The
cross
method computes the vector cross-product ofv1
andv2
and places the result inthis
.public final float dot(Vector3f v1)The
dot
method computes the dot product between this vector and the vectorv1
and returns the resulting value.public final void normalize(Vector3f v1) public final void normalize()The first
normalize
method normalizes the vectorv1
to unit length and places the result inthis
. The secondnormalize
method normalizes the vectorthis
and places the resulting unit vector back intothis
.public final float angle(Vector3f v1)This method returns the angle in radians between this vector and the vector parameter. The return value is constrained to the range [0,PI].
A.1.4.3 TexCoord3f Class
The TexCoord3f class extends Tuple3f. The TexCoord3f is a three-element coordinate represented by single-precision floating x, y, and z coordinates.
Constructors
public TexCoord3f(float x, float y, float z) public TexCoord3f(float[] v) public TexCoord3f(TexCoord3f v1) public TexCoord3f()These four constructors each return a new TexCoord3f. The first constructor generates a texture coordinate from three floating point numbers
x
,y
, andz
. The second constructor generates a texture coordinate from the first three elements of arrayv
. The third constructor generates a texture coordinate from the single-precision three-vectorv1
. The final constructor generates a texture coordinate with value (0.0, 0.0, 0.0).A.1.4.4 Color3f Class
The Color3f class extends Tuple3f. The Color3f is a three-element color value represented by single-precision floating x, y, and z values. The x, y, and z values represent the red, blue, and green color values, respectively.
Constructors
public Color3f(float x, float y, float z) public Color3f(float[] v) public Color3f(Color3f v1) public Color3f()These four constructors each return a new Color3f. The first constructor generates a Color3f from three floating point numbers
x
,y
, andz
. The second constructor generates a Color3f from the first three elements of arrayv
. The third constructor generates a Color3f from the single-precision colorv1
. The final constructor generates a Color3f with value (0.0, 0.0, 0.0).A.1.5 Tuple4b Class
The Tuple4b class represents four bytes, used for colors with alpha.
Variables
The component values of a Tuple4b are directly accessible through the public variables
x
,y
,z
, andw
. Thex
,y
,z
, andw
values represent the red, green, blue, and alpha values, respectively. To access the x (red) component of a Tuple4b-called backgroundColor, a programmer would writebackgroundColor.x
. The programmer would access the y (green), z (blue), and w (alpha) components similarly.
Note: Java defines a byte as a signed integer in the range -128 to 127. However, colors are more typically represented by values in the range 0 to 255. Java 3D recognizes this and, in those cases where Color4b is used to represent color, treats the bytes as if the range were 0 to 255.
public byte x public byte y public byte z public byte wThe red, green, blue, and alpha values, respectively.
Constructors
public Tuple4b(byte b1, byte b2, byte b3, byte b4) public Tuple4b(byte[] t) public Tuple4b(Tuple4b t1) public Tuple4b()These four constructors each return a new Tuple4b. The first constructor generates a Tuple4b from four bytes
b1
,b2
,b3
, andb4
. The second constructor generates a Tuple4b from the first four elements of arrayt
. The third constructor generates a Tuple4b from the byte-precision Tuple4bt1
. The final constructor generates a Tuple4b with value (0.0, 0.0, 0.0, 0.0).Methods
public String toString()This method returns a string that contains the values of this Tuple4b.
public final void set(byte[] b) public final void set(Tuple4b t1) public final void get(byte[] b) public final void get(Tuple4b t1)The first
set
method sets the value of the data members of this Tuple4b to the value of the arrayb
. The secondset
method sets the value of the data members of this Tuple4b to the value of the argument tuplet1
. The firstget
method places the value of thex
,y
,z
, andw
components of this Tuple4b into the byte arrayb
. The secondget
method places the value of thex
,y
,z
, andw
components of this Tuple4b into the Tuple4bt1
.public boolean equals(Tuple4b t1)This method returns true if all of the data members of Tuple4b
v1
are equal to the corresponding data members in this Tuple4b.public int hashCode()This method returns a hash number based on the data values in this object. Two different Tuple4b objects with identical data values (i.e., returns true for
equals(Tuple4b)
) will return the same hash number. Two vectors with different data members may return the same hash value, although this is not likely.A.1.5.1 Color4b Class
The Color4b class extends Tuple4b. The Color4b is a four-byte color value (rgb and alpha).
Constructors
public Color4b(byte b1, byte b2, byte b3, byte b4) public Color4b(byte[] c) public Color4b(Color4b c1) public Color4b()These four constructors each return a new Color4b. The first constructor generates a Color4b from four bytes
b1
,b2
,b3
, andb4
. The second constructor generates a Color4b from the first four elements of byte arrayc
. The third constructor generates a Color4b from the byte-precision Color4bc1
. The final constructor generates a Color4b with value (0.0, 0.0, 0.0, 0.0).A.1.6 Tuple4d Class
The Tuple4d class represents a four-element point, quaternion, or vector consisting of double precision floating point x, y, z, and w coordinates. The Tuple4d class is used for rows and columns for 4 x 4 matrices, and quaternions.
Variables
The component values of a Tuple4d are directly accessible through the public variables
x
,y
,z
, andw
. To access the x component of a Tuple4d called upperLeftCorner, a programmer would writeupperLeftCorner.x
. The programmer would access they
,z
, andw
components similarly.public double x public double y public double z public double wThe x, y, z, and w coordinates, respectively.
Constructors
public Tuple4d(double x, double y, double z, double w) public Tuple4d(double[] t) public Tuple4d(Tuple4d t1) public Tuple4d(Tuple4f t1) public Tuple4d()These five constructors each return a new Tuple4d. The first constructor generates a Tuple4d from four floating point numbers
x
,y
,z
, andw
. The second constructor generates a Tuple4d from the first four elements of arrayt
. The third constructor generates a Tuple4d from the double-precision tuplet1
. The fourth constructor generates a Tuple4d from the single-precision tuplet1
. The final constructor generates a Tuple4d with value (0.0, 0.0, 0.0, 0.0).Methods
public final void set(double x, double y, double z, double w) public final void set(double[] t) public final void set(Tuple4d t1) public final void set(Tuple4d t1) public final void get(double[] t) public final void get(Tuple4d t)These methods set the value of the tuple
this
to the values specified or to the values of the specified tuples. The firstget
method retrieves the value of this tuple and places it into the arrayt
of length four, in x, y, z, w order. The second get method retrieves the value of this tuple and places into tuplet
.public final void add(Tuple4d t1, Tuple4d t2) public final void add(Tuple4d t1) public final void sub(Tuple4d t1, Tuple4d t2) public final void sub(Tuple4d t1)The first
add
method computes the element-by-element sum of the tuplet1
and the tuplet2
placing the result inthis
. The secondadd
method computes the element-by-element sum of this tuple and the tuplet1
and places the result inthis
. The firstsub
method performs an element-by-element subtraction of tuplet2
from tuplet1
and places the result inthis
. The secondsub
method performs an element-by-element subtraction of tuplet1
from this tuple and places the result inthis
.public final void negate(Tuple4d t1) public final void negate()The first
negate
method negates the tuplet1
, places the result inthis
, and sets the referenced object to that negated value. The secondnegate
method negates the tuplethis
and places the resulting unit tuple back intothis
.public final void scale(double s, Tuple4d t1) public final void scale(double s) public final void scaleAdd(double s, Tuple4d t1, Tuple4d t2)The first
scale
method multiplies each element of the tuplev1
by the scale factors
and places the resulting scaled tuple intothis
. The second scale method multiples the tuplethis
by the scale factors
and replacesthis
with the scaled value. The third scale method scales tuplev1
by the scale factors
, adds the result to tuplev2
, and places the result into the tuplethis
.public void interpolate(Tuple4d t1, Tuple4d t2, float alpha) public void interpolate(Tuple4d t1, float alpha)The first interpolate method linearly interpolates between tuples
t1
andt2
and places the result into this tuple (this = alpha · t1 + (1-alpha) · t2). The second interpolate method linearly interpolates between this tuple and tuplet1
and places the result into this tuple (this = alpha · this + (1-alpha) · t1).public String toString()This method returns a string that contains the values of this tuple. The form is (x, y, z, w).
public boolean equals(Tuple4d v1)This method returns true if all of the data members of tuple
v1
are equal to the corresponding data members in this tuple.public boolean epsilonEquals(Tuple4d t1, double epsilon)This method returns true if the L-infinite distance between this axis-angle and axis-angle
a1
is less than or equal to the epsilon parameter. Otherwise, this method returns false. The L-infinite distance is equal to MAX[abs(x1 - x2), abs(y1 - y2), abs(w1 - w2)].public final void absolute() public final void absolute(Tuple4d t)The first
absolute
method sets each component of this tuple to its absolute value. The secondabsolute
method sets each component of the tuple parameter to its absolute value and places the modified values into this tuple.public final void clamp(float min, float max) public final void clamp(float min, float max, Tuple4d t) public final void clampMin(float min) public final void clampMin(float min, Tuple4d t) public final void clampMax(float max) public final void clampMax(float max, Tuple4d t)The first
clamp
method clamps this tuple to the range (low, high). The secondclamp
method clamps this tuple to the range (low, high) and places the values into tuplet
. The firstclampMin
method clamps the minimum value of this tuple to themin
parameter. The secondclampMin
method clamps the minimum value of this tuple to themin
parameter and places the values into the tuplet
. The firstclampMax
method clamps the maximum value of this tuple to themax
parameter. The secondclampMax
method clamps the maximum value of this tuple to themax
parameter and places the values into the tuplet
.public int hashCode()This method returns a hash number based on the data values in this object. Two different Tuple4d objects with identical data values (i.e, returns true for
equals(Tuple4d)
) will return the same hash number. Two vectors with different data members may return the same hash value, although this is not likely.A.1.6.1 Point4d Class
The Point4d class extends Tuple4d. The Point4d is a four-element point represented by double-precision floating x, y, z, and w coordinates.
Constructors
public Point4d(double x, double y, double z, double w) public Point4d(double[] p) public Point4d(Point4d p1) public Point4d(Point4f p1) public Point4d()These five constructors each return a new Point4d. The first constructor generates a Point4d from four floating point numbers
x
,y
,z
, andw
. The second constructor generates a Point4d from the first four elements of arrayp
. The third constructor generates a Point4d from the double-precision pointp1
. The fourth constructor generates a Point4d from the single-precision pointp1
. The final constructor generates a Point4d with value (0.0, 0.0, 0.0, 0.0).Methods
public final double distance(Point4d p1) public final double distanceSquared(Point4d p1)The
distance
method computes the distance between this point and the pointp1
and returns the result. ThedistanceSquared
method computes the square of the distance between this point and the pointp1
and returns the result.public final float distanceL1(Point4d p1) public final float distanceLinf(Point4d p1)The
distanceL1
method computes the L - 1 (Manhattan) distance between this point and point p1. The L - 1 distance is equal to: abs(x1 - x2) + abs(y1 - y2) + abs(z1 - z2). ThedistanceLinf
method computes the L - infinite distance between this point and point p1. The L - infinite distance is equal to: MAX[abs(x1 - x2), abs(y1 - y2), abs(z1 - z2)].public final void project(Point4d p1)This method multiplies both of the x and y components of the point4d parameter
p1
by 1/z and places the projected values into this point.A.1.6.2 Vector4d Class
The Vector4d class extends Tuple4d. The Vector4d is a four-element vector represented by double-precision floating x, y, z, and w coordinates.
Constructors
public Vector4d(double x, double y, double z, double w) public Vector4d(double[] v) public Vector4d(Vector4d v1) public Vector4d(Vector4f v1) public Vector4d()These five constructors each return a new Vector4d. The first constructor generates a four-vector from four floating point numbers
x
,y
,z
, andw
. The second constructor generates a four-vector from the first four elements of arrayv
. The third constructor generates a four-vector from the double-precision four-vectorv1
. The fourth constructor generates a four-vector from the single-precision four-vectorv1
. The final constructor generates a four-vector with value (0.0, 0.0, 0.0, 0.0).Methods
public final double length() public final double lengthSquared()The
length
method computes the vector length of the vectorthis
and returns its length as a double-precision floating-point number. ThelengthSquared
method computes the square of the vector length of the vectorthis
and returns its length as a double-precision floating-point number.public final void dot(Vector4d v1)This method returns the dot product of this vector and vector
v1
.public final void normalize(Vector4d v1) public final void normalize()The first
normalize
method normalizes the vectorv1
to unit length and places the result inthis
. The secondnormalize
method normalizes the vectorthis
and places the resulting unit vector back intothis
.public final double angle(Vector4d v1)This method returns the (four-space) angle in radians between this vector and the vector
v1
parameter. The return value is constrained to the range [0,PI].A.1.6.3 Quat4d Class
The Quat4d class extends Tuple4d. The Quat4d is a four-element quaternion represented by double-precision floating point x, y, z, and w values.
Constructors
public Quat4d(double x, double y, double z, double w) public Quat4d(double[] q) public Quat4d(Quat4d q1) public Quat4d(Quat4f q1) public Quat4d()These five constructors each return a new Quat4d. The first constructor generates a quaternion from four floating point numbers
x
,y
,z
, andw
. The second constructor generates a quaternion from the first four elements of arrayq
of length four. The third constructor generates a quaternion from the double-precision quaternionq1
. The fourth constructor generates a quaternion from the single-precision quaternionq1
. The final constructor generates a quaternion with value (0.0, 0.0, 0.0, 0.0).Methods
public final void conjugate(Quat4d q1) public final void conjugate()The first
conjugate
method sets the value of this quaternion to the conjugate of quaternionq1
. The secondconjugate
method negates the value of each of this quaternion's x, y, and z coordinates in place.public final void mul(Quat4d q1, Quat4d q2) public final void mul(Quat4d q1)The first
mul
method sets the value of this quaternion to the quaternion product of quaternionsq1
andq2
(this = q1 · q2). Note that this is safe for aliasing (e.g., this can be q1 or q2). The secondmul
method sets the value of this quaternion to the quaternion products of itself andq1
(this = this · q1).public final void mulInverse(Quat4d q1, Quat4d q2) public final void mulInverse(Quat4d q1)The first
mulInverse
method multiplies quaternionq1
by the inverse of quaternionq2
and places the value into this quaternion. The value of both argument quaternions is preserved (this = q1 · q2-1). The secondmulInverse
method multiplies this quaternion by the inverse of quaternionq1
and places the value into this quaternion. The value of the argument quaternion is preserved (this = this · q-1).public final void inverse(Quat4d q1) public final void inverse()The first
inverse
method sets the value of this quaternion to the quaternion inverse of quaternionq1
. The secondinverse
method sets the value of this quaternion to the quaternion inverse of itself.public final void normalize(Quat4d q1) public final void normalize()The first
normalize
method sets the value of this quaternion to the normalized value of quaternionq1
. The secondnormalize
method normalizes the value of this quaternion in place.public final void set(Matrix4f m1) public final void set(Matrix4d m1) public final void set(Matrix3f m1) public final void set(Matrix3d m1) public final void set(AxisAngle4f a) public final void set(AxisAngle4d a)These
set
methods set the value of this quaternion to the rotational component of the passed matrix.public final void interpolate(Quat4d q1, double alpha) public final void interpolate(Quat4d q1, Quat4d q2, double alpha)The first method performs a great circle interpolation between this quaternion and the quaternion parameter and places the result into this quaternion. The second method performs a great circle interpolation between quaternion
q1
and quaternionq2
and places the result into this quaternion.A.1.7 Tuple4f Class
The Tuple4f class represents a four-element value consisting of single-precision floating point x, y, z, and w values. The Tuple4f class is used for colors (rgb plus alpha), points, rows and columns for 4 x 4 matrices, and quaternions
Variables
The component values of a Tuple4f are directly accessible through the public variables
x
,y
,z
, andw
. To access the x component of a Tuple4f called upperLeftCorner, a programmer would writeupperLeftCorner.x
. The programmer would access they
,z
, andw
components similarly.public double x public double y public double z public double wThe x, y, z, and w values, respectively.
Constructors
public Tuple4f(float x, float y, float z, float w) public Tuple4f(float[] t) public Tuple4f(Tuple4d t1) public Tuple4f(Tuple4f t1) public Tuple4f()These five constructors each return a new Tuple4f. The first constructor generates a Tuple4f from four floating point numbers
x
,y
,z
, andw
. The second constructor generates a Tuple4f from the first four elements of arrayt
. The third constructor generates a Tuple4f from the double-precision tuplet1
. The fourth constructor generates a Tuple4f from the single-precision tuplet1
. The final constructor generates a four-vector with value (0.0, 0.0, 0.0, 0.0).Methods
public final void set(float x, float y, float z, float w) public final void set(float[] t) public final void set(Tuple4f t1) public final void set(Tuple4d t1) public final void get(float[] t) public final void get(Tuple4f t)The first
set
method sets the value of this tuple to the specifiedx
,y
,z
, andw
values. The secondset
method sets the value of this tuple to the specified coordinates in the array. The next two methods set the value of tuplethis
to the value of tuplet1
. Theget
methods copy the value of this tuple into the tuplet
.public final void add(Tuple4f t1, Tuple4f t2) public final void add(Tuple4f t1) public final void sub(Tuple4f t1, Tuple4f t2) public final void sub(Tuple4f t1)The first
add
method computes the element-by-element sum of tuplest1
andt2
and places the result inthis
. The secondadd
method computes the element-by-element sum of this tuple and tuplet1
and places the result inthis
. The firstsub
method performs the element-by-element subtraction of tuplet2
from tuplet1
and places the result inthis
(this = t1 - t2). The secondsub
method performs the element-by-element subtraction of tuplet1
from this tuple and places the result inthis
(this = this - t1).public final void negate(Tuple4f t1) public final void negate()The first
negate
method negates the tuplet1
, places the result inthis
, and sets the referenced object to that negated value. The secondnegate
method negates the tuplethis
and places the resulting unit tuple back intothis
.public final void scale(float s, Tuple4f t1) public final void scale(float s) public final void scaleAdd(float s, Tuple4f t1, Tuple4f t2)The first
scale
method multiplies each element of the tuplet1
by the scale factors
and places the resulting scaled tuple intothis
. The secondscale
method multiples the tuplethis
by the scale factors
, replacingthis
with the scaled value. ThescaleAdd
method scales tuplet1
by the scale factors
, adds the result to tuplet2
, and places the result into the tuplethis
.public String toString()This method returns a string that contains the values of this Tuple4f. The form is (x, y, z, w).
public boolean equals(Tuple4f t1)This method returns true if all of the data members of Tuple4f
t1
are equal to the corresponding data members in this Tuple4f.public boolean epsilonEquals(Tuple4f t1, float epsilon)This method returns true if the L-infinite distance between this axis-angle and axis-angle
a1
is less than or equal to the epsilon parameter. Otherwise, this method returns false. The L-infinite distance is equal to MAX[abs(x1 - x2), abs(y1 - y2), abs(z1 - z2), abs(w1 - w2)].public final void absolute() public final void absolute(Tuple4f t)The first
absolute
method sets each component of this tuple to its absolute value. The secondabsolute
method sets each component of the tuple parameter to its absolute value and places the modified values into this tuple.public final void clamp(float min, float max) public final void clamp(float min, float max, Tuple4f t) public final void clampMin(float min) public final void clampMin(float min, Tuple4f t) public final void clampMax(float max) public final void clampMax(float max, Tuple4f t)The first
clamp
method clamps this tuple to the range (low, high). The secondclamp
method clamps this tuple to the range (low, high) and places the values into tuplet
. The firstclampMin
method clamps the minimum value of this tuple to themin
parameter. The secondclampMin
method clamps the minimum value of this tuple to themin
parameter and places the values into the tuplet
. The firstclampMax
method clamps the maximum value of this tuple to themax
parameter. The secondclampMax
method clamps the maximum value of this tuple to themax
parameter and places the values into the tuplet
.public void interpolate(Tuple4f t1, Tuple4f t2, float alpha) public void interpolate(Tuple4f t1, float alpha)The first interpolate method linearly interpolates between tuples
t1
andt2
and places the result into this tuple (this = alpha · t1 + (1-alpha) · t2). The second interpolate method linearly interpolates between this tuple and tuplet1
and places the result into this tuple (this = alpha · this + (1-alpha) · t1).public int hashCode()This method returns a hash number based on the data values in this object. Two different Tuple4f objects with identical data values (i.e., returns true for
equals(Tuple4f)
) will return the same hash number. Two vectors with different data members may return the same hash value, although this is not likely.A.1.7.1 Point4f Class
The Point4f class extends Tuple4f. The Point4f is a four-element point represented by single-precision floating x, y, z, and w coordinates.
Constructors
public Point4f(float x, float y, float z, float w) public Point4f(float[] p) public Point4f(Point4d p1) public Point4f(Point4f p1) public Point4f()These five constructors each return a new Point4f. The first constructor generates a Point4f from four floating point numbers
x
,y
,z
, andw
. The second constructor generates a Point4f from the first four elements of arrayp
. The third constructor generates a Point4f from the double-precision pointp1
. The fourth constructor generates a four-vector from the single-precision pointp1
. The final constructor generates a Point4f with value (0.0, 0.0, 0.0, 0.0).Methods
public final float distanceSquared(Point4f p1) public final float distance(Point4f p1)The
distanceSquared
method computes the square of the distance between this point and the pointp1
and returns the result. Thedistance
method computes the distance between this point and the pointp1
and returns the result.public final float distanceL1(Point4f p1) public final float distanceLinf(Point4f p1)The
distanceL1
method computes the L - 1 (Manhattan) distance between this point and point p1. The L - 1 distance is equal to: abs(x1 - x2) + abs(y1 - y2) + abs(z1 - z2). ThedistanceLinf
method computes the L - infinite distance between this point and point p1. The L - infinite distance is equal to: MAX[abs(x1 - x2), abs(y1 - y2), abs(z1 - z2)].public final void project(Point4f p1)This method multiplies both of the x and y components of the point4f parameter
p1
by 1/z and places the projected values into this point.A.1.7.2 Color4f Class
The Color4f class extends Tuple4f. The Color4f is a four-element color value represented by single-precision floating x, y, z, and w values. The x, y, z, and w values represent the red, blue, green, and alpha color values, respectively.
Constructors
public Color4f(float x, float y, float z, float w) public Color4f(float[] v) public Color4f(Color4d v1) public Color4f(Color4f v1) public Color4f()These four constructors each return a new Color4f. The first constructor generates a Color4f from four floating point numbers
x
,y
,z
, andw
. The second constructor generates a Color4f from the first four elements of arrayv
. The third and fourth constructors generate a Color4f from the single-precision colorv1
. The final constructor generates a Color4f with value (0.0, 0.0, 0.0, 0.0).A.1.7.3 Vector4f Class
The Vector4f class extends Tuple4f. The Vector4f is a four-element vector represented by single-precision floating x, y, z, and w coordinates.
Constructors
public Vector4f(float x, float y, float z, float w) public Vector4f(float[] v) public Vector4f(Vector4d v1) public Vector4f(Vector4f v1) public Vector4f()These five constructors each return a new Vector4f. The first constructor generates a four-vector from four floating point numbers
x
,y
,z
, andw
. The second constructor generates a four-vector from the first four elements of arrayv
. The third constructor generates a four-vector from the double-precision four-vectorv1
. The fourth constructor generates a four-vector from the single-precision four-vectorv1
. The final constructor generates a four-vector with value (0.0, 0.0, 0.0, 0.0).Methods
public final float length() public final float lengthSquared()The
length
method computes the vector length of the vectorthis
and returns its length as a single-precision floating-point number. ThelengthSquared
method computes the square of the vector length of the vectorthis
and returns its length as a single-precision floating-point number.public final float dot(Vector4f v1)The
dot
method computes the dot product between this vector and the vectorv1
and returns the resulting value.public final void normalize(Vector4f v1) public final void normalize()The first
normalize
method sets the value of this vector to the normalization of vectorv1
. The secondnormalize
method normalizes this vector in place.public final float angle(Vector4f v1)This method returns the (four-space) angle in radians between this vector and the vector
v1
parameter. The return value is constrained to the range [0,PI].A.1.7.4 Quat4f Class
The Quat4f class extends Tuple4f. The Quat4f is a four-element quaternion represented by single-precision floating point x, y, z, and w values.
Constructors
public Quat4f(float x, float y, float z, float w) public Quat4f(float[] q) public Quat4f(Quat4d q1) public Quat4f(Quat4f q1) public Quat4f()These five constructors each return a new Quat4f. The first constructor generates a quaternion from four floating-point numbers
x
,y
,z
, andw
. The second constructor generates a quaternion from the four floating-point numbers of arrayq
of length four. The third constructor generates a quaternion from the double-precision quaternionv1
. The fourth constructor generates a quaternion from the single-precision quaternionv1
. The final constructor generates a quaternion with value (0.0, 0.0, 0.0, 0.0).Methods
public final void conjugate(Quat4f q1) public final void conjugate()The first
conjugate
method sets the value of this quaternion to the conjugate of quaternionq1
. The secondconjugate
method negates the value of each of this quaternion's x, y, and z coordinates in place.public final void mul(Quat4f q1, Quat4f q2) public final void mul(Quat4f q1)The first
mul
method sets the value of this quaternion to the quaternion product of quaternionsq1
andq2
(this = q1 · q2). Note that this is safe for aliasing (e.g., this can be q1 or q2). The secondmul
method sets the value of this quaternion to the quaternion product of itself andq1
(this = this · q1).public final void mulInverse(Quat4f q1, Quat4f q2) public final void mulInverse(Quat4f q1)The first
mulInverse
method multiplies quaternionq1
by the inverse of quaternionq2
and places the value into this quaternion. The value of both argument quaternions is preserved (this = q1 · q2-1). The secondmulInverse
method multiplies this quaternion by the inverse of quaternionq1
and places the value into this quaternion. The value of the argument quaternion is preserved (this = this · q1-1).public final void inverse(Quat4f q1) public final void inverse()The first
inverse
method sets the value of this quaternion to the quaternion inverse of quaternionq1
. The secondinverse
method sets the value of this quaternion to the quaternion inverse of itself.public final void normalize(Quat4f q1) public final void normalize()The first
normalize
method sets the value of this quaternion to the normalized value of quaternionq1
. The secondnormalize
method normalizes the value of this quaternion in place.public final void set(Matrix4f m1) public final void set(Matrix4d m1) public final void set(Matrix3f m1) public final void set(Matrix3d m1) public final void set(AxisAngle4f a) public final void set(AxisAngle4d a)These
set
methods set the value of this quaternion to the rotational component of the passed matrix.public final void interpolate(Quat4f q1, float alpha) public final void interpolate(Quat4f q1, Quat4f q2, float alpha)The first method performs a great circle interpolation between this quaternion and the quaternion parameter and places the result into this quaternion. The second method performs a great circle interpolation between quaternion
q1
and quaternionq2
and places the result into this quaternion.A.1.8 AxisAngle4d Class
The AxisAngle4d class represents a four-element value consisting of double-precision floating point x, y, and z coordinates and an angle of rotation in radians. The AxisAngle4d class is used for axis-angle representation.
Variables
The component values of an AxisAngle4d are directly accessible through the public variables
x
,y
,z
, andw
. To access the x component of an AxisAngle4d called upperLeftCorner, a programmer would writeupperLeftCorner.x
. The programmer would access they
,z
, andangle
components similarly.public double x public double y public double z public double angleThe x, y, and z coordinates and the rotational angle, respectively. The rotation angle is expressed in radians.
Constructors
public AxisAngle4d(double x, double y, double z, double angle) public AxisAngle4d(double[] a) public AxisAngle4d(AxisAngle4d a1) public AxisAngle4d(AxisAngle4f a1) public AxisAngle4d()These five constructors each return a new AxisAngle4d. The first constructor generates an axis-angle from four floating point numbers
x
,y
,z
, andangle
. The second constructor generates an axis-angle from the first four elements of arraya
. The third constructor generates an axis-angle from the double-precision axis-anglea1
. The fourth constructor generates an axis-angle from the single-precision axis-anglea1
. The final constructor generates an axis-angle with value (0.0, 0.0, 0.0, 0.0).Methods
public final void set(double x, double y, double z, double angle) public final void set(double[] a) public final void set(Matrix4f m1) public final void set(Matrix4d m1) public final void set(Matrix3f m1) public final void set(Matrix3d m1) public final void set(AxisAngle4d a1) public final void set(AxisAngle4f a1) public final void set(Quat4f q1) public final void set(Quat4d q1) public final void get(double[] a)The first
set
method sets the value of this axis angle to the specifiedx
,y
,z
, andangle
coordinates. The secondset
method sets the value of this axis angle to the specified x,y,z angle. The next four set methods set the value of this axis angle to the rotational component of the passed matrixm1
. The next twoset
methods set the value of this axis angle to the value of axis anglea1
. The last twoset
methods set the value of this axis angle to the value of the passed quaternionq1
. Theget
method retrieves the value of this axis angle and places it into the arraya
of length four in x,y,z,angle order.public String toString()This method returns a string that contains the values of this AxisAngle4d. The form is (x,y,z,angle).
public boolean equals(AxisAngle4d v1)This method returns true if all of the data members of AxisAngle4d
v1
are equal to the corresponding data members in this axis angle.public boolean epsilonEquals(AxisAngle4d a1, double epsilon)This method returns true if the L-infinite distance between this axis-angle and axis-angle
a1
is less than or equal to the epsilon parameter. Otherwise, this method returns false. The L-infinite distance is equal to MAX[abs(x1 - x2), abs(y1 - y2), abs(z1 - z2), abs(angle1 - angle2)].public int hashCode()This method returns a hash number based on the data values in this object. Two different AxisAngle4d objects with identical data values (i.e., returns true for
equals(AxisAngle4d)
) will return the same hash number. Two vectors with different data members may return the same hash value, although this is not likely.A.1.9 AxisAngle4f Class
The AxisAngle4f class represents a four-element value consisting of single-precision floating point x, y, and z coordinates and an angle of rotation in radians. The AxisAngle4d class is used for axis-angle representation.
Variables
The component values of a AxisAngle4f are directly accessible through the public variables
x
,y
,z
, andw
. To access the x component of a AxisAngle4f called upperLeftCorner, a programmer would writeupperLeftCorner.x
. The programmer would access they
,z
, andangle
components similarly.public double x public double y public double z public double angleThe x, y, and z coordinates and the rotational angle, respectively. The rotation angle is expressed in radians.
Constructors
public AxisAngle4f(float x, float y, float z, float angle) public AxisAngle4f(float[] a) public AxisAngle4f(AxisAngle4f a1) public AxisAngle4f(AxisAngle4d a1) public AxisAngle4f()These five constructors each return a new AxisAngle4f. The first constructor generates an axis-angle from four floating point numbers
x
,y
,z
, andangle
. The second constructor generates an axis-angle from the first four elements of arraya
. The third constructor generates an axis-angle from the single-precision axis-anglea1
. The fourth constructor generates an axis-angle from the double-precision axis-anglea1
. The final constructor generates an axis-angle with value (0.0, 0.0, 0.0, 0.0).Methods
public final void set(float x, float y, float z, float angle) public final void set(float[] a) public final void set(Matrix4f m1) public final void set(Matrix4d m1) public final void set(Matrix3f m1) public final void set(Matrix3d m1) public final void set(AxisAngle4f a1) public final void set(AxisAngle4d a1) public final void set(Quat4f q1) public final void set(Quat4d q1) public final void get(float[] a)The first
set
method sets the value of this axis angle to the specifiedx
,y
,z
, andangle
coordinates. The secondset
method sets the value of this axis angle to the specified coordinates in the arraya
. The next four set methods set the value of this axis angle to the rotational component of the passed matrixm1
. The next twoset
methods set the value of this axis angle to the value of axis anglea1
. The last twoset
methods set the value of this axis angle to the value of the passed quaternionq1
. Theget
method retrieves the value of this axis angle and places it into the arraya
of length four in x,y,z,angle order.public String toString()This method returns a string that contains the values of this axis angle. The form is (x,y,z,angle).
public boolean equals(AxisAngle4f a1)This method returns true if all of the data members of axis angle
a1
are equal to the corresponding data members in this axis angle.public boolean epsilonEquals(AxisAngle4f a1, float epsilon)This method returns true if the L-infinite distance between this axis-angle and axis-angle
a1
is less than or equal to the epsilon parameter. Otherwise, this method returns false. The L-infinite distance is equal to MAX[abs(x1 - x2), abs(y1 - y2), abs(z1 - z2), abs(angle1 - angle2)].public int hashCode()This method returns a hash number based on the data values in this object. Two different AxisAngle4f objects with identical data values (i.e., returns true for
equals(AxisAngle4f)
) will return the same hash number. Two vectors with different data members may return the same hash value, although this is not likely.A.1.10 GVector Class
The GVector class represents a general, dynamically-resizeable, one-dimension vector class. Index numbering begins with zero.
Constructors
public GVector(int length) public GVector(double[] vector) public GVector(GVector vector) public GVector(Tuple2f tuple) public GVector(Tuple3f tuple) public GVector(Tuple3d tuple) public GVector(Tuple4f tuple) public GVector(Tuple4d tuple)These seven constructors each return a new GVector. The first constructor generates a generalized mathematical vector with zero elements -
length
represents the number of elements in the vector. The second and third constructors generate a generalized mathematical vector and copy the initial value from the parametervector
. The last four constructors generate a generalized mathematical vector and copy the initial value from the tuple.Methods
public final void add(GVector vector) public final void add(GVector vector1, GVector vector2) public final void sub(GVector vector) public final void sub(GVector vector1, GVector vector2)The first
add
method computes the element-by-element sum of this GVector and GVectorv1
and places the result inthis
. The secondadd
method computes the element-by-element sum of GVectorsv1
andv2
and places the result inthis
. The firstsub
method performs the element-by-element subtraction of GVectorv1
from this GVector and places the result inthis
(this = this - v1). The secondsub
method performs the element-by-element subtraction of GVectorv2
from GVectorv1
and places the result inthis
(this = v1 - v2).public final void mul(GMatrix m1, GVector v1) public final void mul(GVector v1, GMatrix m1)The first
mul
method multiplies matrix m1 times vector v1 and places the result into this vector (this = m1 · v1). The secondmul
method multiplies the transpose of vectorv1
(i.e.,v1
becomes a row vector with respect to the multiplication) times matrixm1
and places the result into this vector (this = transpose(v1) · m1). The result is technically a row vector, but the GVector class only knows about column vectors, so the result is stored as a column vector.public final void negate()This method negates the vector
this
and places the resulting unit vector back intothis
.public final void zero()This method sets all the values in this vector to zero.
public final void setSize(int length) public final void int getSize()This method changes the size of this vector dynamically. If the size is increased, no data values are lost. If the size is decreased, only those data values whose vector positions were eliminated are lost.
public final void set(double[] vector) public final void set(GVector vector) public final void set(Tuple2f tuple) public final void set(Tuple3f tuple) public final void set(Tuple3d tuple) public final void set(Tuple4f tuple) public final void set(Tuple4d tuple)The first
set
method sets the value of this vector to the values found in the arrayvector
- the array should be at least equal in length to the number of elements in the vector. The secondset
method sets the value of this vector to the values in the vectorvector
. The last fiveset
methods set the value of this vector to the values intuple
.public final double getElement(int index) public final void setElement(int index, double value)These methods set and retrieve the specified index value of this vector.
public final double norm() public final double normSquared()The
norm
method returns the square root of the sum of the squares of this vector (its length in n-dimensional space). ThenormSquared
method returns the sum of the squares of this vector (its length in n-dimensional space).public final void normalize(GVector v1) public final void normalize()The first
normalize
method sets the value of this vector to the normalization of vectorv1
. The secondnormalize
method normalizes this vector in place.public final void scale(double s, GVector v1) public final void scale(double s) public final void scaleAdd(double s, GVector v1, GVector v2)The first
scale
method sets the value of this vector to the scalar multiplication of the scale factors
with the vectorv1
. The secondscale
method scales this vector by the scale factors
.public String toString()This method returns a string that contains the values of this vector.
public int hashCode()This method returns a hash number based on the data values in this object. Two different GVector objects with identical data values (i.e., returns true for
equals(GVector)
) will return the same hash number. Two objects with different data members may return the same hash value, although this is not likely.public boolean equals(GVector vector1)This method returns true if all of the data members of GVector
vector1
are equal to the corresponding data members in this GVector.public boolean epsilonEquals(GVector v1, double epsilon)This method returns true if the L-infinite distance between this vector and vector
v1
is less than or equal to the epsilon parameter. Otherwise, this method returns false. The L-infinite distance is equal to MAX[abs(x1 - x2), abs(y1 - y2), ...].public final double dot(GVector v1)This method returns the dot product of this vector and vector
v1
.public final void SVDBackSolve(GMatrix U, GMatrix W, GMatrix V, GVector x) public final void LUDBackSolve(GMatrix LU, GVector x, GVector permutation)The first method solves for b in b = Ax, where b is this vector (mx1), A is mxn, and A = U · W · transpose(V); U, W, and V must be precomputed and can be found by taking the singular value decomposition (SVD) of A. The second method takes the LU matrix and the permutation vector produced by the GMatrix method LUD and solves the equation this = (LU) · x by placing the solution to the set of linear equations into this vector.
public final double angle(GVector v1)This method returns the (n-space) angle in radians between this vector and the vector parameter; the return value is constrained to the range [0,PI].
public final void interpolate(GVector v1, GVector v2, float alpha) public final void interpolate(GVector v1, float alpha)The first method linearly interpolates between vectors v1 and v2 and places the result into this tuple: this = alpha · v1 + (1-alpha) · v2. The second method linearly interpolates between this vector and vector v1 and places the result into this tuple: this = alpha · this + (1-alpha) · v1.
A.2 Matrix Objects
Java 3D uses the matrix objects to represent rotations and full 3D transforms. The matrix classes (as well as the associated Tuple and AxisAngle classes) include code for accessing, manipulating, and updating the matrix, vector, and AxisAngle classes. Java 3D further subdivides the matrix classes into 3 x 3 matrices (mainly to store rotations) and 4 x 4 matrices (mainly to store more complex 3D transforms). These two classes in turn provide support for both single-precision floating-point representations and for double-precision floating-point representations.
Matrix operations try to minimize gratuitous allocation of memory, thus all matrix operations update an existing object. To multiply two matrices together and store the result in a third, a Java 3D application or applet would write
matrix3.mul(matrix1, matrix2)
. Herematrix3
receives the results of multiplyingmatrix1
withmatrix2
.A.2.1 Matrix3f Class
The Matrix3f class serves to contain 3 x 3 matrices mainly for storing and manipulating 3D rotation matrices. The class includes three different constructors for creating matrices and several operators for manipulating these matrices.
Variables
The component values of a matrix3f are directly accessible through the public variables
m00
,m01
,m02
,m10
,m11
,m12
,m20
,m21
, andm22
. To access the element in row 2 and column zero of matrix rotate, a programmer would writerotate.m20
. A programmer would access the other values similarly.public float m00The matrix element that maps x into x'.
public float m01The matrix element that maps y into x'.
public float m02The matrix element that maps z into x'.
public float m10The matrix element that maps x into y'.
public float m11The matrix element that maps y into y'.
public float m12The matrix element that maps z into y'.
public float m20The matrix element that maps x into z'.
public float m21The matrix element that maps y into z'.
public float m22The matrix element that maps z into z'.
Constructors
public Matrix3f(float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22) public Matrix3f(float[] v) public Matrix3f(Matrix3d m1) public Matrix3f(Matrix3f m1) public Matrix3f()These three constructors each return a new Matrix3f. The first constructor generates a 3 x 3 matrix from the nine values provided. The second constructor generates a 3 x 3 matrix from the first nine values in the array
v
. The third and fourth constructors generate a new matrix with the same values as the passed matrixm1
. The final constructor generates a 3 x 3 matrix with all values equal to 0.0.Methods
public final void set(Matrix4d m1) public final void set(Matrix4f m1)These two
set
methods set the value of the matrixthis
to the float value of the rotational components of the passed matrixm1
).public final void set(Quat4d q1) public final void set(Quat4f q1)These two
set
methods set the value of the matrixthis
to the matrix conversion of the quaternion argumentq1
.public final void set(AxisAngle4d a1) public final void set(AxisAngle4f a1)These two
set
methods set the value of the matrixthis
to the matrix conversion of the axis and angle argumenta1
.public final void set(float scale) public final void set(float[] m)The first method sets the value of this matrix to a scale matrix with the passed scale amount. The second method sets the values of this matrix to the row-major array parameter (i.e., the first three elements of the array are copied into the first row of this matrix, etc.).
public final void identity() public final void scale(float scale)The
identity
method sets the matrixthis
to the identity matrix (all zeros except for ones along the main diagonal). Thescale
method sets the value of this matrix to a scale matrix with the passed scale amount.public final void setElement(int row, int column, float value) public final float getElement(int row, int column)The
setElement
andgetElement
methods provide a means for accessing a single element within a 3 x 3 matrix using indices. This is not a preferred method of accessing but Java 3D provides these functions for functional completeness. ThesetElement
method takes a row indexrow
(where a value of 0 represents the first row and a value of 2 represents the third row), a column indexcolumn
(where a value of 0 represents the first column and a value of 2 represents the third column), and a valuevalue
. It sets the corresponding element in matrixthis
to the specified value. ThegetElement
method also takes a row indexrow
and, a column indexcolumn
. It returns the element at the corresponding locations as a floating-point value.public final void setRow(int row, float x, float y, float z) public final void setRow(int row, Vector3f v) public final void setRow(int row, float v[])These three
setRow
methods provide a means for constructing a 3 x 3 matrix on a row basis. The row parameterrow
determines which row the method invocation affects. A row value of 0 represents the first row and a value of 2 represents the third row. The firstsetRow
method specifies the three new values as independent floating-point values. The secondsetRow
method uses the values in the Vector3fv
to update the matrix. The thirdsetRow
method uses the first three values in the arrayv
to update the matrix. In all three cases the matrix affected is the matrixthis
.public final void setColumn(int column, float x, float y, float z) public final void setColumn(int column, Vector3f v) public final void setColumn(int column, float v[])These three
setColumn
methods provide a means for constructing a 3 x 3 matrix on a column basis. Thecolumn
parameter determines which column the method invocation affects. A column value of 0 represents the first column and a value of 2 represents the third column. The firstsetColumn
method specifies the three new values as independent floating-point values. The secondsetColumn
method uses the values in the Vector3fv
to update the matrix. The thirdsetColumn
method uses the first three values in the arrayv
to update the matrix. In all three cases the matrix affected is the matrixthis
.public final void setZero()This method sets this matrix to all zeros.
public final void setIdentity()This method sets this Matrix3f to identity.
public final void add(Matrix3f m1, Matrix3f m2) public final void add(Matrix3f m1) public final void sub(Matrix3f m1, Matrix3f m2) public final void sub(Matrix3f m1)The first
add
method adds the matrixm1
to the matrixm2
and places the result into the matrixthis
. The secondadd
method adds the matrixthis
to the matrixm1
and places the result into the matrixthis
. The firstsub
method performs an element-by-element subtraction of matrixm2
from matrixm1
and places the result into the matrixthis
. The secondsub
method performs an element-by-element subtraction of the matrixm1
from the matrixthis
and places the result into the matrixthis
.public final void transpose(Matrix3f m1) public final void transpose()The first
transpose
method transposes the matrixm1
and places the result into the matrixthis
. The secondtranspose
method transposes the matrixthis
and places the transpose back into the matrixthis
.public final void invert() public final void invert(Matrix3f m1) public final void invertOrthogonal() public final void invertOrthogonal(Matrix3f m1)The
invert
methods have two forms. In the first form, without an argument, they invert the matrixthis
and replacethis
with the inverted value. In the second form, with an argument, the methods invert the matrixm1
and replace the matrixthis
with the inverted value. The first two methods perform a full inversion computation. The next two methods assume the matrix is an orthogonal matrix. The last two methods assume the matrix they invert is ortho-normal.public final float determinant()The
determinant
method computes the determinant of the matrixthis
and returns the computed value.public final void rotX(float angle) public final void rotY(float angle) public final void rotZ(float angle)The three
rot
methods construct rotation matrices that rotate in a clockwise direction around the axis specified as the last letter of the method name. The constructed matrix replaces the value of the matrixthis
.public final void mul(Matrix3f m1, Matrix3f m2) public final void mul(Matrix3f m1)The first
mul
method multiplies matrixm1
with matrixm2
and places the result into the matrixthis
. The secondmul
method multiplies the matrixthis
with the matrixm1
and places the result into matrixthis
.public final void mulNormalize(Matrix3f m1) public final void mulNormalize(Matrix3f m1, Matrix3f m2)The first
mulNormalize
method multiplies this matrix by matrixm1
, performs an SVD normalization of the result, and places the result back into this matrix (this = SVDnorm(this · m1)). The secondmulNormalize
method multiplies matrix m1 by matrix m2, performs an SVD normalization of the result, and places the result into this matrix (this = SVDnorm(m1 · m2)).public final void mulTransposeBoth(Matrix3f m1, Matrix3f m2) public final void mulTransposeRight(Matrix3f m1, Matrix3f m2) public final void mulTransposeLeft(Matrix3f m1, Matrix3f m2)The
mulTransposeBoth
method multiplies the transpose of matrixm1
(left) times the transpose of matrixm2
(right) and places the result into this matrix. ThemulTransposeRight
method multiplies matrixm1
times the transpose of matrixm2
and places the result back into this matrix. ThemulTransposeLeft
method multiplies the transpose of matrixm1
times matrixm2
and places the result into this matrix.public final void normalize() public final void normalize(Matrix3f m1)The first
normalize
method performs a singular value decomposition normalization of this matrix. The secondnormalize
method performs a singular value decomposition normalization of matrixm1
and places the normalized values intothis
.public final void normalizeCP() public final void normalizeCP(Matrix3f m1)The first
normalizeCP
method performs a cross product normalization of this matrix. The secondnormalizeCP
method performs a cross product normalization of matrixm1
and places the normalized values intothis
.public boolean equals(Matrix3f m1)The
equals
method returns true if all of the data members of Matrix3fm1
are equal to the corresponding data members in this Matrix3f.public boolean epsilonEquals(Matrix3f m1, float epsilon)This method returns true if the L-infinite distance between this axis-angle and axis-angle
a1
is less than or equal to the epsilon parameter. Otherwise, this method returns false. The L-infinite distance is equal to MAX[i = 0,1,2, ... n; j = 0,1,2,... n; abs(this.m(i,j) - m1.m(i,j)].public final void negate() public final void negate(Matrix3f m1)The first method negates the value of this matrix (this = -this). The second negate method sets the value of this matrix equal to the negation of the Matrix3f parameter.
public int hashCode()The
hashCode
method returns a hash number based on the data values in this object. Two different Matrix3f objects with identical data values (i.e., returns true forequals(Matrix3f)
) will return the same hash number. Two vectors with different data members may return the same hash value, although this is not likely.public String toString()The
toString
method returns a string that contains the values of this Matrix3f.A.2.2 Matrix3d Class
The Matrix3d class serves to contain 3 x 3 matrices mainly for storing and manipulating 3D rotation matrices. The class includes three different constructors for creating matrices and several operators for manipulating these matrices.
Variables
The component values of a matrix3d are directly accessible through the public variables
m00
,m01
,m02
,m10
,m11
,m12
,m20
,m21
, andm22
. To access the element in row two and column zero of the matrix named rotate, a programmer would writerotate.m20
. Other matrix values are accessed similarly.public double m00The matrix element that maps x into x'.
public double m01The matrix element that maps y into x'.
public double m02The matrix element that maps z into x'.
public double m10The matrix element that maps x into y'.
public double m11The matrix element that maps y into y'.
public double m12The matrix element that maps z into y'.
public double m20The matrix element that maps x into z'.
public double m21The matrix element that maps y into z'.
public double m22The matrix element that maps z into z'.
Constructors
public Matrix3d(double m00, double m01, double m02, double m10, double m11, double m12, double m20, double m21, double m22) public Matrix3d(double[] v) public Matrix3d() public Matrix3d(Matrix3d m1) public Matrix3d(Matrix3f m1)These constructors each return a new Matrix3d. The first constructor generates a 3 x 3 matrix from the nine values provided. The second constructor generates a 3 x 3 matrix from the first nine values in the array
v
. The third constructor generates a 3 x 3 matrix with all values equal to 0.0. The fourth and fifth constructors generate a 3 x 3 matrix with the same values as the matrixm1
parameter.Methods
public final void set(Matrix3f m1)This method sets the value of the matrix
this
to the float value of the rotational components of the passed matrixm1
.public final void set(double scale) public final void set(double[] m)These methods set the value of the matrix
this
to a scale matrix with the passed scale amount.public final void set(AxisAngle4d a1) public final void set(AxisAngle4f a1)These two
set
methods set the value of the matrixthis
to the matrix conversion of the axis and angle argumenta1
.public final void set(Quat4d q1) public final void set(Quat4f q1)These two
set
methods set the value of the matrixthis
to the matrix conversion of the quaternion argumentq1
.public final void identity() public final void scale(double scale)The
identity
method sets the matrixthis
to the identity matrix (all zeros except for ones along the main diagonal). Thescale
method sets the value of this matrix to a scale matrix with the passed scale amount.public final void setElement(int row, int column, double value) public final double getElement(int row, int column)The
setElement
andgetElement
methods provide a means for accessing a single element within a 3 x 3 matrix using indices. This is not a preferred method of accessing but Java 3D provides these functions for functional completeness. ThesetElement
method takes a row indexrow
(where a value of 0 represents the first row and a value of 2 represents the third row), a column indexcolumn
(where a value of 0 represents the first column and a value of 2 represents the third column), and a valuevalue
. It sets the corresponding element in matrixthis
to the specified value. ThegetElement
method also takes a row indexrow
and, a column indexcolumn
and returns the element at the corresponding locations as a floating-point value.public final void setRow(int row, double x, double y, double z) public final void setRow(int row, Vector3d v) public final void setRow(int row, double v[])These three
setRow
methods provide a means for constructing a 3 x 3 matrix on a row basis. Therow
parameter determines which row the method invocation affects. A row value of 0 represents the first row and a value of 2 represents the third row. The firstsetRow
method specifies the three new values as independent floating-point values. The secondsetRow
method uses the values in the Vector3dv
to update the matrix. The thirdsetRow
method uses the first three values in the arrayv
to update the matrix. In all three cases the matrix affected is the matrixthis
.public final void setColumn(int column, double x, double y, double z) public final void setColumn(int column, Vector3d v) public final void setColumn(int column, double v[])These three
setColumn
methods provide a means for constructing a 3 x 3 matrix on a column basis. Thecolumn
parameter determines which column the method invocation affects. A column value of 0 represents the first column and a value of 2 represents the third column. The firstsetColumn
method specifies the three new values as independent floating-point values. The secondsetColumn
method uses the values in the Vector3dv
to update the matrix. The thirdsetColumn
method uses the first three values in the arrayv
to update the matrix. In all three cases the matrix affected is the matrixthis
.public final void add(Matrix3d m1, Matrix3d m2) public final void add(Matrix3d m1) public final void sub(Matrix3d m1, Matrix3d m2) public final void sub(Matrix3d m1)The first
add
method adds the matrixm1
to the matrixm2
and places the result into the matrixthis
. The secondadd
method adds the matrixthis
to the matrixm1
and places the result into the matrixthis
. The firstsub
method performs an element-by-element subtraction of matrixm2
from matrixm1
and places the result into the matrixthis
. The secondsub
method performs an element-by-element subtraction of the matrixm1
from the matrixthis
and places the result into the matrixthis
.public final void transpose(Matrix3d m1) public final void transpose()The first
transpose
method transposes the matrixm1
and places the result into the matrixthis
. The secondtranspose
method transposes the matrixthis
and places the transpose back into the matrixthis
.public final void invert() public final void invert(Matrix3d m1) public final void invertOrthogonal() public final void invertOrthogonal(Matrix3d m1)The
invert
methods have two forms. In the first form, without an argument, they invert the matrixthis
and replacethis
with the inverted value. In the second form, with an argument, the methods invert the matrixm1
and replace the matrixthis
with the inverted value. The first two methods perform a full inversion computation. The next two methods assume the matrix is an orthogonal matrix.public final double determinant()The
determinant
method computes the determinant of the matrixthis
and returns the computed value.public final void rotX(double angle) public final void rotY(double angle) public final void rotZ(double angle)The three
rot
methods construct rotation matrices that rotate in a clockwise direction around the axis specified by the final letter of the method name. The constructed matrix replaces the value of the matrixthis
.public final void mul(Matrix3d m1, Matrix3d m2) public final void mul(Matrix3d m1)The first
mul
method multiplies matrixm1
with matrixm2
and places the result into the matrixthis
. The secondmul
method multiplies matrixthis
with matrixm1
and places the result into the matrixthis
.public final void mulNormalize(Matrix3d m1) public final void mulNormalize(Matrix3d m1, Matrix3d m2)The first
mulNormalize
method multiplies this matrix by matrixm1
, performs an SVD normalization of the result, and places the result back into this matrix (this = SVDnorm(this · m1)). The secondmulNormalize
method multiplies matrix m1 by matrix m2, performs an SVD normalization of the result, and places the result into this matrix (this = SVDnorm(m1 · m2)).public final void mulTransposeBoth(Matrix3d m1, Matrix3d m2) public final void mulTransposeRight(Matrix3d m1, Matrix3d m2) public final void mulTransposeLeft(Matrix3d m1, Matrix3d m2)The
mulTransposeBoth
method multiplies the transpose of matrixm1
(left) times the transpose of matrixm2
(right) and places the result into this matrix. ThemulTransposeRight
method multiplies matrixm1
times the transpose of matrixm2
and places the result back into this matrix. ThemulTransposeLeft
method multiplies the transpose of matrixm1
times matrixm2
and places the result into this matrix.public final void normalize() public final void normalize(Matrix3d m1)The first
normalize
method performs a singular value decomposition normalization of this matrix. The secondnormalize
method performs a singular value decomposition normalization of matrixm1
and places the normalized values intothis
.public final void normalizeCP() public final void normalizeCP(Matrix3d m1)The first
normalizeCP
method performs a cross product normalization of this matrix. The secondnormalizeCP
method performs a cross product normalization of matrixm1
and places the normalized values intothis
.public boolean equals(Matrix3d m1)The
equals
method returns true if all of the data members of Matrix3dm1
are equal to the corresponding data members in this Matrix3d.public boolean epsilonEquals(Matrix3d m1, double epsilon)This method returns true if the L-infinite distance between this axis-angle and axis-angle
a1
is less than or equal to the epsilon parameter. Otherwise, this method returns false. The L-infinite distance is equal to MAX[i = 0,1,2,; j = 0,1,2,; abs(this.m(i,j) - m1.m(i,j)].public final void negate() public final void negate(Matrix3d m1)The first method negates the value of this matrix (this = -this). The second negate method sets the value of this matrix equal to the negation of the Matrix3d parameter.
public final void setZero()This method sets this matrix to all zeros.
public final void setIdentity()This method sets this Matrix3d to identity.
public int hashCode()The
hashCode
method returns a hash number based on the data values in this object. Two different Matrix3d objects with identical data values (i.e., returns true forequals(Matrix3d)
) will return the same hash number. Two vectors with different data members may return the same hash value, although this is not likely.public String toString()The
toString
method returns a string that contains the values of this Matrix3d.A.2.3 Matrix4f Class
The Matrix4f class serves to contain 4 x 4 matrices mainly for storing and manipulating 3D transform matrices. The class includes three different constructors for creating matrices and several operators for manipulating these matrices.
Variables
The component values of a matrix4f are directly accessible through the public variables
m00
,m01
,m02
,m03
,m10
,m11
,m12
,m13
,m20
,m21
,m22
,m23
,m30
,m31
,m32
, andm33
. To access the element in row 2 and column zero of matrix rotate, a programmer would write rotate.m20. A programmer would access the other values similarly.public float m00The matrix element that maps x into x'.
public float m01The matrix element that maps y into x'.
public float m02The matrix element that maps z into x'.
public float m03The matrix element that is the translational component of x'.
public float m10The matrix element that maps x into y'.
public float m11The matrix element that maps y into y'.
public float m12The matrix element that maps z into y'.
public float m13The matrix element that is the translational component of y'.
public float m20The matrix element that maps x into z'.
public float m21The matrix element that maps y into z'.
public float m22The matrix element that maps z into z'.
public float m23The matrix element that is the translational component of z'.
public float m30Unused matrix element, except for perspective mapping of x to w'.
public float m31Unused matrix element, except for perspective mapping of y to w'.
public float m32Unused matrix element, except for perspective mapping of z to w'.
public float m33Unused matrix element, except for perspective mapping, in which case it must be unity.
Constructors
public Matrix4f(float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33) public Matrix4f(float[] v) public Matrix4f(Quat4f q1, Vector3f t1, float s) public Matrix4f(Matrix4d m1) public Matrix4f(Matrix4f m1) public Matrix4f(Matrix3f m1, Vector3f t1, float s) public Matrix4f()These three constructors each return a new Matrix4f. The first constructor generates a 4 x 4 matrix from the 16 values provided. The second constructor generates a 4 x 4 matrix from the first 16 values in the array
v
. The third constructor generates a 4 x 4 matrix from the quaternion, translation, and scale values; the scale is applied only to the rotational components of the matrix (upper 3x3) and not to the translational components. The fourth and fifth constructors generate a 4 x 4 matrix with the same values as the passed matrixm1
. The sixth constructor generates a 4 x 4 matrix from the rotation matrix, translation, and scale values; the scale is applied only to the rotational components of the matrix (upper 3 x 3) and not to the translational components of the matrix. The final constructor generates a 4 x 4 matrix with all values equal to 0.0.Methods
public final void set(Quat4f q1) public final void set(Quat4d q1) public final void set(Quat4f q1, Vector3f t1, float s) public final void set(Quat4d q1, Vector3d t1, double s) public final void set(Matrix4d m1) public final void set(Matrix4f m1) public final void set(AxisAngle4f a1) public final void set(AxisAngle4d a1)The first two
set
methods set the value of this matrix to the matrix conversion of the quaternion argumentq1
. The next twoset
methods set the value of this matrix from the rotation expressed by the quaternionq1
, the translationt1
, and the scales
. The next twoset
methods set the value of this matrix to a copy of the passed matrixm1
. The last two set methods set the value of this matrix to the matrix conversion of the axis and angle argumenta1
.public final void set(Matrix3f m1) public final void set(Matrix3d m1)These methods set the rotational component (upper 3 x 3) of this matrix to the matrix values in the
m1
argument. The other elements of this matrix are initialized as if this were an identity matrix (i.e., affine matrix with no translational component).public final void set(float scale) public final void set(float[] m)The first method sets the value of this matrix to a scale matrix with the passed scale amount. The second method sets the value of this matrix to the row-major array parameter (i.e., the first four elements of the array are copied into the first row of this matrix, etc.).
public final void set(Vector3f v1)This method sets the value of this matrix to a translate matrix with the passed translation value.
public final void set(float scale, Vector3f t1) public final void set(Vector3f t1, float scale)These methods set the value of this transform to a scale and translation matrix. In the first method, the scale is not applied to the translation and all of the matrix values are modified. In the second method the translation is scaled by the scale factor and all of the matrix values are modified.
public final void set(Matrix3f m1, Vector3f t1, float scale) public final void set(Matrix3d m1, Vector3d t1, double scale)These two methods set the value of this matrix from the rotation expressed by the rotation matrix m1, the translation t1, and the scale s. The translation is not modified by the scale.
public final void get(Matrix3d m1) public final void get(Matrix3f m1) public final float get(Matrix3f m1, Vector3f t1) public final void get(Quat4f q1) public final void get(Vector3f trans)The first two methods perform an SVD normalization of this matrix in order to acquire the normalized rotational component. The values are placed into the matrix parameter
m1
. The third method performs an SVD normalization of this matrix to calculate the rotation as a 3 x 3 matrix, the translation, and the scale. None of the matrix values are modified. The fourth method performs an SVD normalization of this matrix to acquire the normalized rotational component. The values are placed into the Quat4f parameter. The final method retrieves the translational components of this matrix.public final void identity() public final void scale(float scale) public final void translate(Vector3f v1) public final void translate(float x, float y, float z) public final void scaleTranslate(float scale, Vector3f t1) public final void scaleTranslate(float scale, float x, float y, float z) public final void translateScale(Vector3f t1, float scale) public final void translateScale(float x, float y, float z, float scale)The
identity
method sets the matrixthis
to the identity matrix (all zeros except for ones on the main diagonal). Thescale
method sets the value of this matrix to a scale matrix with the passed scale amount. Thetranslate
methods construct translate matrices with an identity rotational/scale component and a translational component either set tot1
or the vector constructed fromx
,y
, andz
. ThetranslateScale
andscaleTranslate
methods construct a scale-translate matrix with a scale component set toscale
and a translation component either set tot1
or the vector constructed fromx
,y
, andz
.public final void setElement(int row, int column, float value) public final float getElement(int row, int column)The
setElement
andgetElement
methods provide a means for accessing a single element within a 4 x 4 matrix using indices. This is not a preferred method of accessing matrix elements but Java 3D provides these functions for functional completeness. ThesetElement
method takes a row indexrow
(where a value of 0 represents the first row and a value of 3 represents the fourth row), a column indexcolumn
(where a value of 0 represents the first column and a value of 3 represents the fourth column), and a valuevalue
. It sets the corresponding element in matrixthis
to the specified value. ThegetElement
method also takes a row indexrow
and, a column indexcolumn
and returns the element at the corresponding locations as a floating-point value.public final void getRotationScale(Matrix3f m1)This method retrieves the upper 3 x 3 values of this matrix and places them into the matrix
m1
.public final void setRow(int row, float x, float y, float z, float w) public final void setRow(int row, Vector4f v) public final void setRow(int row, float v[])These three
setRow
methods provide a means for constructing a 4 x 4 matrix on a row basis. The row parameterrow
determines which row the method invocation affects. A row value of 0 represents the first row and a value of 3 represents the fourth row. The firstsetRow
method specifies the four new values as independent floating-point values. The secondsetRow
method uses the values in the Vector4fv
to update the matrix. The thirdsetRow
method uses the first four values in the arrayv
to update the matrix. In all three cases the matrix affected is the matrixthis
.public final void setColumn(int column, float x, float y, float z, float w) public final void setColumn(int column, Vector4f v) public final void setColumn(int column, float v[])These three
setColumn
methods provide a means for constructing a 4 x 4 matrix on a column basis. Thecolumn
parameter determines which column the method invocation affects. A column value of 0 represents the first column and a value of 3 represents the fourth column. The firstsetColumn
method specifies the four new values as independent double-precision floating-point values. The secondsetColumn
method uses the values in the Vector4fv
to update the matrix. The thirdsetColumn
method uses the first four values in the arrayv
to update the matrix. In all three cases the matrix affected is the matrixthis
.public final void setRotation(Matrix3d m1) public final void setRotation(Matrix3f m1) public final void setRotation(Quat4f q1) public final void setRotation(Quat4d q1) public final void setRotation(AxisAngle4f a1)These methods set the rotational component (upper 3 x 3) of this matrix to the matrix values in the passed argument; the other elements of this matrix are unchanged. In the first two methods, a singular value decomposition is performed on this object's upper 3 x 3 matrix to factor out the scale, then this object's upper 3 x 3 matrix components are replaced by the passed rotation components, and then the scale is reapplied to the rotational components. In the next two methods, a singular value decomposition is performed on this object's upper 3 x 3 matrix to factor out the scale, then this object's upper 3 x 3 matrix components are replaced by the matrix equivalent of the quaternion, and then the scale is reapplied to the rotational components. In the last method, a singular value decomposition is performed on this object's upper 3 x 3 matrix to factor out the scale, then this object's upper 3 x 3 matrix components are replaced by the matrix equivalent of the axis-angle, and then the scale is reapplied to the rotational components.
public final void setRotationScale(Matrix3f m1)This method replaces the upper 3 x 3 matrix values of this matrix with the values in the matrix m1.
public final void setTranslation(Vector3f trans)This method modifies the translational components of this matrix to the values of the Vector3f argument; the other values of this matrix are not modified.
public final void setIdentity()This method sets this Matrix4f to identity.
public final void setZero()This method sets this matrix to all zeros.
public final void add(Matrix4f m1, Matrix4f m2) public final void add(Matrix4f m1) public final void sub(Matrix4f m1, Matrix4f m2) public final void sub(Matrix4f m1)The first
add
method adds the matrixm1
to the matrixm2
and places the result into the matrixthis
. The secondadd
method adds the matrixthis
to the matrixm1
and places the result into the matrixthis
. The firstsub
method performs an element-by-element subtraction of matrixm2
from matrixm1
and places the result into the matrixthis
. The secondsub
method performs an element-by-element subtraction of the matrixm1
from the matrixthis
and places the result into the matrixthis
.public final void transpose(Matrix4f m1) public final void transpose()The first
transpose
method transposes the matrixm1
and places the result into the matrixthis
. The secondtranspose
method transposes the matrixthis
and places the result back into the matrixthis
.public final void transform(Point3f point) public final void transform(Point3f point, Point3f pointOut)The first
transform
method premultiplies this Matrix4d by thepoint
value and places the result back intopoint
. The multiply treats the three-vectorpoint
as if its fourth element were one. The secondtransform
method transforms this Matrix4d by thepoint
argument and places the value intopointOut
.public final void transform(Vector3f normal) public final void transform(Vector3f normal, Vector3f normalOut)The first
transform
method transforms this matrix by thenormal
argument and places the value back intonormal
. The multiply treats the three-vectornormal
as if its fourth element were zero. The secondtransform
method premultiplies this matrix by the vectornormal
and places the value intonormalOut
.public final void transform(Tuple4f vec) public final void transform(Tuple4f vec, Tuple4f vecOut)The first
transform
method transforms this matrix by the tuplevec
and places the value back intovec
. The secondtransform
method premultiplies this matrix by the tuplevec
and places the value intovecOut
.public final void negate() public final void negate(Matrix4f m1)The first method negates the value of this matrix (this = -this). The second method sets the value of this matrix equal to the negation of the Matrix4f parameter.
public final void invert() public final void invert(Matrix4f m1)The first method inverts the matrix
this
and replacesthis
with the inverted value. The second method inverts the matrixm1
and replaces the matrixthis
with the inverted value.public final float determinant()The
determinant
method computes the determinant of the matrixthis
and returns the computed value.public final void rotX(float angle) public final void rotY(float angle) public final void rotZ(float angle)The three
rot
methods construct rotation matrices that rotate in a clockwise direction around the axis specified as the last letter of the method name. The constructed matrix replaces the value of the matrixthis
.public final void mul(Matrix4f m1, Matrix4f m2) public final void mul(Matrix4f m1)The first
mul
method multiplies matrixm1
with matrixm2
and places the result into the matrixthis
. The secondmul
method multiplies the matrixthis
with matrixm1
and places the result in matrixthis
.public final void mulTransposeBoth(Matrix4f m1, Matrix4f m2) public final void mulTransposeRight(Matrix4f m1, Matrix4f m2) public final void mulTransposeLeft(Matrix4f m1, Matrix4f m2)The
mulTransposeBoth
method multiplies the transpose of matrixm1
(left) times the transpose of matrixm2
(right) and places the result into this matrix. ThemulTransposeRight
method multiplies matrixm1
times the transpose of matrix m2 and places the result back into this matrix. ThemulTransposeLeft
method multiplies the transpose of matrixm1
times matrixm2
and places the result into this matrix.public boolean equals(Matrix4f m1)The
equals
method returns true if all of the data members of Matrix4fm1
are equal to the corresponding data members in this Matrix4f.public boolean epsilonEquals(Matrix4f m1, float epsilon)This method returns true if the L-infinite distance between this axis-angle and axis-angle
a1
is less than or equal to the epsilon parameter. Otherwise, this method returns false. The L-infinite distance is equal to MAX[i = 0,1,2,3; j = 0,1,2,3; abs(this.m(i,j) - m1.m(i,j)].public int hashCode()The
hashCode
method returns a hash number based on the data values in this object. Two different Matrix4f objects with identical data values (i.e., returns true forequals(Matrix4f)
) will return the same hash number. Two vectors with different data members may return the same hash value, although this is not likely.public String toString()The
toString
method returns a string that contains the values of this Matrix4f.A.2.4 Matrix4d Class
The Matrix4d class serves to contain 4 x 4 matrices mainly for storing and manipulating 3D transform matrices. The class includes three different constructors for creating matrices and several operators for manipulating these matrices.
Variables
The component values of a matrix4d are directly accessible through the public variables
m00
,m01
,m02
,m03
,m10
,m11
,m12
,m13
,m20
,m21
,m22
,m23
,m30
,m31
,m32
, andm33
. To access the element in row 2 and column zero of matrix rotate, a programmer would writerotate.m20
. A programmer would access the other values similarly.public double m00The matrix element that maps x into x'.
public double m01The matrix element that maps y into x'.
public double m02The matrix element that maps z into x'.
public double m03The matrix element that is the translational component of x'.
public double m10The matrix element that maps x into y'.
public double m11The matrix element that maps y into y'.
public double m12The matrix element that maps z into y'.
public double m13The matrix element that is the translational component of y'.
public double m20The matrix element that maps x into z'.
public double m21The matrix element that maps y into z'.
public double m22The matrix element that maps z into z'.
public double m23The matrix element that is the translational component of z'.
public double m30Unused matrix element, except for perspective mapping of x to w'.
public double m31Unused matrix element, except for perspective mapping of y to w'.
public double m32Unused matrix element, except for perspective mapping of z to w'.
public double m33Unused matrix element, except for perspective mapping, in which case it must be unity.
Constructors
public Matrix4d(double m00, double m01, double m02, double m03, double m10, double m11, double m12, double m13, double m20, double m21, double m22, double m23, double m30, double m31, double m32, double m33) public Matrix4d(double[] v) public Matrix4d(Quat4d q1, Vector3d t1, double s) public Matrix4d(Quat4f q1, Vector3d t1, double s) public Matrix4d(Matrix3f m1, Vector3d t1, double s) public Matrix4d(Matrix3d m1, Vector3d t1, double s) public Matrix4d(Matrix4d m1) public Matrix4d(Matrix4f m1) public Matrix4d()These three constructors each return a new Matrix4d. The first constructor generates a 4 x 4 matrix from the 16 values provided. The second constructor generates a 4 x 4 matrix from the first 16 values in the array
v
. The third through sixth constructors generates a 4 x 4 matrix from the quaternion, translation, and scale values; the scale is applied only to the rotational components of the matrix (upper 3 x 3) and not to the translational components. The seventh and eighth constructors generate a 4 x 4 matrix with the same values as the passed matrix. The final constructor generates a 4 x 4 matrix with all values equal to 0.0.Methods
public final void get(Matrix3d m1) public final void get(Matrix3f m1) public final double get(Matrix3d m1, Vector3d t1) public final double get(Matrix3f m1, Vector3d t1) public final void get(Quat4f q1) public final void get(Quat4d q1) public final void get(Vector3d trans)The first two methods perform an SVD normalization of this matrix in order to acquire the normalized rotational component. The values are placed into the passed parameter. The next two methods perform an SVD normalization of this matrix to calculate the rotation as a 3 x 3 matrix, the translation, and the scale. None of the matrix values are modified. The next two methods perform an SVD normalization of this matrix to acquire the normalized rotational component. The last two methods retrieve the translational components of this matrix.
public final void identity() public final void scale(double scale) public final void translate(Vector3d v1) public final void translate(double x, double y, double z) public final void scaleTranslate(double scale, Vector3d v1) public final void scaleTranslate(double scale, double x, double y, double z) public final void scaleTranslate(float scale, float x, float y, float z) public final void translateScale(Vector3d v1, double scale) public final void translateScale(double x, double y, double z, double scale)The
identity
method sets the matrixthis
to the identity matrix (all zeros except for ones on the main diagonal). Thescale
method sets the value of this matrix to a scale matrix with the passed scale amount. Thetranslate
methods construct translate matrices with an identity rotational/scale component and a translational component either set tov1
or the vector constructed fromx
,y
, andz
. ThetranslateScale
andscaleTranslate
methods construct a scale-translate matrix with a scale component set toscale
and a translation component either set tot1
or the vector constructed fromx
,y
, andz
.public final void setElement(int row, int column, double value) public final double getElement(int row, int column)The
setElement
andgetElement
methods provide a means for accessing a single element within a 4 x 4 matrix using indices. This is not a preferred method of accessing matrix elements but Java 3D provides these functions for functional completeness. ThesetElement
method takes a row indexrow
(where a value of 0 represents the first row and a value of 3 represents the fourth row), a column indexcolumn
(where a value of 0 represents the first column and a value of 3 represents the fourth column), and a valuevalue
. It sets the corresponding element in matrixthis
to the specified value. ThegetElement
method also takes a row indexrow
and a column indexcolumn
and returns the element at the corresponding locations as a floating-point value.public final void setRow(int row, double x, double y, double z, double w) public final void setRow(int row, Vector4d v) public final void setRow(int row, double v[])These three
setRow
methods provide a means for constructing a 4 x 4 matrix on a row basis. Therow
parameter determines which row the method invocation affects. A row value of 0 represents the first row and a value of 3 represents the fourth row. The firstsetRow
method specifies the four new values as independent floating-point values. The secondsetRow
method uses the values in the Vector4dv
to update the matrix. The thirdsetRow
method uses the first four values in the arrayv
to update the matrix. In all three cases the matrix affected is the matrixthis
.public final void setColumn(int column, double x, double y, double z, double w) public final void setColumn(int column, Vector4d v) public final void setColumn(int column, double v[])These three
setColumn
methods provide a means for constructing a 4 x 4 matrix on a column basis. Thecolumn
parameter determines which column the method invocation affects. A column value of 0 represents the first column and a value of 3 represents the fourth column. The firstsetColumn
method specifies the four new values as independent double-precision floating-point values. The secondsetColumn
method uses the values in the Vector4dv
to update the matrix. The thirdsetColumn
method uses the first four values in the arrayv
to update the matrix. In all three cases the matrix affected is the matrixthis
.public final void setRotation(Matrix3d m1) public final void setRotation(Matrix3d m1)These methods set the rotational component (upper 3 x 3) of this matrix to the matrix values in the passed argument; the other elements of this matrix are unchanged. A singular value decomposition is performed on this object's upper 3 x 3 matrix to factor out the scale, then this object's upper 3 x 3 matrix components are replaced by the passed rotation components, and then the scale is reapplied to the rotational components.
public final void setRotation(Quat4f q1) public final void setRotation(Quat4d q1)These methods set the rotational component (upper 3 x 3) of this matrix to the matrix values in the passed argument; the other elements of this matrix are unchanged. A singular value decomposition is performed on this object's upper 3 x 3 matrix to factor out the scale, then this object's upper 3 x 3 matrix components are replaced by the matrix equivalent of the quaternion, and then the scale is reapplied to the rotational components.
public final void setRotation(AxisAngle4d a1)This method sets the rotational component (upper 3 x 3) of this matrix to the equivalent values in the passed argument; the other elements of this matrix are unchanged. A singular value decomposition is performed on this object's upper 3 x 3 matrix to factor out the scale, then this object's upper 3 x 3 matrix components are replaced by the matrix equivalent of the axis-angle, and then the scale is reapplied to the rotational components.
public final void getRotationScale(Matrix3f m1) public final void getRotationScale(Matrix3d m1) public final void setRotationScale(Matrix3d m1) public final void setRotationScale(Matrix3f m1)The two get methods retrieve the upper 3 x 3 values of this matrix and place them into the matrix
m1
. The two set methods replace the upper 3 x 3 matrix values of this matrix with the values in the matrixm1
.public final void setTranslation(Vector3d trans)This method modifies the translational components of this matrix to the values of the Vector3d argument. The other values of this matrix are not modified.
public final void add(Matrix4d m1, Matrix4d m2) public final void add(Matrix4d m1) public final void sub(Matrix4d m1, Matrix4d m2) public final void sub(Matrix4d m1)The first
add
method adds the matrixm1
to the matrixm2
and places the result into the matrixthis
. The secondadd
method adds the matrixthis
to the matrixm1
and places the result into the matrixthis
. The firstsub
method performs an element-by-element subtraction of matrixm2
from matrixm1
and places the result into the matrixthis
. The secondsub
method performs an element-by-element subtraction of the matrixm1
from the matrixthis
and places the result into the matrixthis
.public final void set(double[] m)This method sets the value of this matrix to the row-major array parameter (i.e., the first four elements of the array will be copied into the first row of this matrix, etc.).
public final void set(Matrix3f m1) public final void set(Matrix3d m1)These methods set the rotational component (upper 3 x 3) of this matrix to the matrix values in the matrix argument; the other elements of this matrix are initialized as if this were an identity matrix (i.e., affine matrix with no translational component).
public final void set(Matrix4f m1) public final void set(Matrix4d m1)These methods set the value of this matrix to the value of the passed matrix
m1
.public final void set(Quat4d q1) public final void set(Quat4f q1)These methods set the value of this matrix to the matrix conversion of the quaternion argument.
public final void set(AxisAngle4d a1) public final void set(AxisAngle4f a1)These methods set the value of this matrix to the matrix conversion of the axis and angle argument.
public final void set(Vector3d v1)This method sets the value of this matrix to a translate matrix by the passed translation value.
public final void set(Quat4d q1, Vector3d t1, double s) public final void set(Quat4f q1, Vector3d t1, double s) public final void set(Quat4f q1, Vector3f t1, float s)These methods set the value of this matrix from the rotation expressed by the quaternion
q1
, the translationt1
, and the scales
.public final void set(double scale)This method sets the value of this matrix to a scale matrix with the passed scale amount.
public final void set(double scale, Vector3d v1)This method sets the value of this transform to a scale and translation matrix; the scale is not applied to the translation and all of the matrix values are modified.
public final void set(Vector3d v1, double scale)This method sets the value of this transform to a scale and translation matrix; the translation is scaled by the scale factor and all of the matrix values are modified.
public final void set(Matrix3f m1, Vector3f t1, float scale) public final void set(Matrix3f m1, Vector3f t1, float scale)These methods set the value of this matrix from the rotation expressed by the rotation matrix
m1
, the translationt1
, and the scales
.public final void negate(Matrix4d m1) public final void negate()The first
negate
method sets the value of this matrix to the negation of them1
parameter. The secondnegate
method negates the value of this matrix (this = -this).public final void transpose(Matrix4d m) public final void transpose()The first
transpose
method transposes the matrixm
and places the result into the matrixthis
. The secondtranspose
method transposes the matrixthis
and places the result back into the matrixthis
.public final void transform(Tuple4d vec) public final void transform(Tuple4f vec) public final void transform(Tuple4d vec, Tuple4d vecOut) public final void transform(Tuple4f vec, Tuple4f vecOut)The first two
transform
methods premultiply the matrixthis
by the tuplevec
and place the result back intovec
. The second twotransform
methods premultiply the matrixthis
by the tuplevec
and place the result intovecOut
.public final void transform(Point3d point) public final void transform(Point3f point) public final void transform(Point3d point, Point3d pointOut) public final void transform(Point3f point, Point3f pointOut)The first two
transform
methods premultiply this Matrix4d by thepoint
and place the result back intopoint
. The multiply treats the three-vectorpoint
as if its fourth element were one. The second twotransform
methods transform this Matrix4d by thepoint
argument and place the value intopointOut
.public final void transform(Vector3d normal) public final void transform(Vector3f normal) public final void transform(Vector3d normal, Vector3d normalOut) public final void transform(Vector3f normal, Vector3f normalOut)The first two
transform
methods transform this matrix by thenormal
argument and place the value back intonormal
. The multiply treats the three-vectornormal
as if its fourth element were zero. The last twotransform
methods premultiply this matrix by the vectornormal
and place the value intonormalOut
.public final void invert() public final void invert(Matrix4d m1)The first
invert
method inverts the matrixthis
and replacesthis
with the inverted value. The secondinvert
method inverts the matrixm1
and replaces the matrixthis
with the inverted value.public final double determinant()The
determinant
method computes the determinant of the matrixthis
and returns the computed value.public final void rotX(double angle) public final void rotY(double angle) public final void rotZ(double angle)The
rot
methods construct rotation matrices that rotate in a clockwise direction around the axis specified as the last letter of the method name. The constructed matrix replaces the value of the matrixthis
.public final void mul(Matrix4d m1, Matrix4d m2) public final void mul(Matrix 4d m1)The first
mul
method multiplies matrixm1
with matrixm2
and places the result into the matrixthis
. The secondmul
method multiplies matrixthis
with matrixm1
and places the result into the matrixthis
.public final void mulTransposeBoth(Matrix4d m1, Matrix4d m2) public final void mulTransposeRight(Matrix4d m1, Matrix4d m2) public final void mulTransposeLeft(Matrix4d m1, Matrix4d m2)The
mulTransposeBoth
method multiplies the transpose of matrixm1
(left) times the transpose of matrixm2
(right) and places the result into this matrix. ThemulTransposeRight
method multiplies matrixm1
times the transpose of matrix m2 and places the result back into this matrix. ThemulTransposeLeft
method multiplies the transpose of matrixm1
times matrixm2
and places the result into this matrix.public final void setZero()This method sets this matrix to all zeros.
public final void setIdentity()This method sets this Matrix4d to identity.
public boolean equals(Matrix4d m1)The
equals
method returns true if all of the data members of Matrix4dm1
are equal to the corresponding data members in this Matrix4d.public boolean epsilonEquals(Matrix4d m1, float epsilon)This method returns true if the L - infinite distance between this axis-angle and axis-angle
a1
is less than or equal to the epsilon parameter. Otherwise, this method returns false. The L -infinite distance is equal to MAX[i = 0,1,2,3; j = 0,1,2,3; abs(this.m(i,j) - m1.m(i,j)].public int hashCode()The
hashCode
method returns a hash number based on the data values in this object. Two different Matrix4d objects with identical data values (i.e., returns true forequals(Matrix4d)
) will return the same hash number. Two vectors with different data members may return the same hash value, although this is not likely.public String toString()The
toString
method returns a string that contains the values of this Matrix4d.A.2.5 GMatrix Class
The GMatrix class serves to contain a double-precision, general, and dynamically resizeable M x N matrix. Row and column numbering begins with zero. The representation is row major.
The GMatrix data members are not public to allow efficient implementations of sparse matrices. However, the data members can be modified through public accessors.
Constructors
public GMatrix(int nRow, int nCol) public GMatrix(int nRow, int nCol, double[] matrix) public GMatrix(GMatrix matrix)These constructors each return a new GMatrix. The first constructor generates an
nRow
bynCol
identity matrix. The second constructor generates annRow
bynCol
matrix initialized to the values in the arraymatrix
. The last constructor generates a new GMatrix and copies the initial values from the parametermatrix
argument.Methods
public final void mul(GMatrix m1, GMatrix m2) public final void mul(GMatrix m1)The first
mul
method multiplies matrixm1
with matrixm2
and places the result intothis
. The secondmul
method multiplies this matrix with matrixm1
and places the result intothis
.public final void add(GMatrix m1) public final void add(GMatrix m1, GMatrix m2) public final void sub(GMatrix m1) public final void sub(GMatrix m1, GMatrix m2)The first
add
method adds this matrix to matrixm1
and places the result back intothis
. The secondadd
method adds matricesm1
andm2
and places the result intothis
. The firstsub
method subtracts matrixm1
from the matrixthis
and places the result intothis
. The secondsub
method subtracts matrixm2
from matrixm1
and places the result into the matrixthis
.public final void negate() public final void negate(GMatrix m1)The first method negates the value of this matrix (this = -this). The second method sets the value of this matrix to the negation of the GMatrix parameter.
public final void invert() public final void invert(GMatrix m1)The first method inverts this matrix in place. The second method inverts matrix
m1
and places the new values into this matrix; Matrixm1
is not modified.public final void identity()This method sets this GMatrix to the identity matrix.
public final void zero()This method sets all the values in this matrix to zero.
public final void identityMinus()This method subtracts this matrix from the identity matrix and puts the values back into
this
(this = I - this).public final void copySubMatrix(int rowSource, int colSource, int numRow, int numCol, int rowDest, int colDest, GMatrix target)This method copies a sub-matrix derived from this matrix into the target matrix. The
rowSource
andcolSource
parameters define the upper left of the sub-matrix. ThenumRow
andnumCol
parameters define the number of rows and columns in the sub-matrix. The sub-matrix is copied into the target matrix starting at (rowDest
,colDest
). Thetarget
parameter is the matrix into which the sub-matrix will be copied.public final void setSize(int nRow, int nCol)This method changes the size of this matrix dynamically. If the size is increased, no data values will be lost. If the size is decreased, only those data values whose matrix positions were eliminated will be lost.
public final void set(double[] matrix) public final void set(GMatrix m1) public final void set(Matrix3f m1) public final void set(Matrix3d m1) public final void set(Matrix4f m1) public final void set(Matrix4d m1)The first
set
method sets the value of this matrix to the values found in thematrix
parameter. The values are copied in one row at a time, in row major fashion. The array should be at least equal in length to the number of matrix rows times the number of matrix columns in this matrix. The secondset
method sets the value of this matrix to the values found in matrixm1
. The last fourset
methods set the value of this matrix to the values found in matrixm1
.public final void get(Matrix3d m1) public final void get(Matrix3f m1) public final void get(Matrix4d m1) public final void get(Matrix4f m1) public final void get(GMatrix m1)The first two methods place the values in the upper 3 x 3 of this GMatrix into the matrix m1. The next two methods place the values in the upper 4 x 4 of this GMatrix into the matrix m1. The final method places the values in the this GMatrix into the matrix m1; m1 should be at least as large as this GMatrix.
public final int getNumRow() public final int getNumCol()The
getNumRow
method returns the number of rows in this matrix. ThegetNumCol
method returns the number of columns in this matrix.public final void setElement(int row, int column, double value) public final double getElement(int row, int column)These methods set and retrieve the value at the specified
row
andcolumn
of this matrix.public final void setRow(int row, double[] array) public final void setRow(int row, GVector vector) public final void getRow(int row, double[] array) public final void getRow(int row, GVector vector) public final void setColumn(int col, double[] array) public final void setColumn(int col, GVector vector) public final void getColumn(int col, double[] array) public final void getColumn(int col, GVector vector)The
setRow
methods copy the values from the array into the specified row of this matrix. ThegetRow
methods place the values of the specified row into the array or vertex. ThesetColumn
methods copy the values from the array into the specified column of this matrix or vector. ThegetColumn
methods place the values of the specified column into the array or vector.public final void setScale(double scale)This method sets this matrix to a uniform scale matrix; all of the values are reset.
public final void setIdentity()This method sets this GMatrix to identity.
public final void setZero()Sets all the values in this matrix to zero.
public final void mulTransposeBoth(GMatrix m1, GMatrix m2) public final void mulTransposeRight(GMatrix m1, GMatrix m2) public final void mulTransposeLeft(GMatrix m1, GMatrix m2)The
mulTransposeBoth
method multiplies the transpose of matrixm1
(left) times the transpose of matrixm2
(right) and places the result into this matrix. ThemulTransposeRight
method multiplies matrixm1
times the transpose of matrix m2 and places the result back into this matrix. ThemulTransposeLeft
method multiplies the transpose of matrixm1
times matrixm2
and places the result into this matrix.public final void transpose() public final void transpose(GMatrix m1)The first
transpose
method transposes this matrix in place. The secondtranspose
method places the matrix values of the transpose of matrixm1
into this matrix.public String toString()This method returns a string that contains the values of this GMatrix.
public int hashCode()This method returns a hash number based on the data values in this object. Two different
GMatrix
objects with identical data values (i.e., returns true forequals(GMatrix)
) will return the same hash number. Two objects with different data members may return the same hash value, although this is not likely.public boolean equals(GMatrix m1)This method returns true if all of the data members of GMatrix
m1
are equal to the corresponding data members in this GMatrix.public boolean epsilonEquals(GMatrix m1, float epsilon)This method returns true if the L - infinite distance between this axis-angle and axis-angle
a1
is less than or equal to the epsilon parameter. Otherwise, this method returns false. The L-infinite distance is equal to MAX[i = 0,1,2, ... n; j = 0,1,2,... n; abs(this.m(i,j) - m1.m(i,j)].public final double trace()This method returns the trace of this matrix.
public final int SVD(GMatrix U, GMatrix W, GMatrix V)The SVD method finds the singular value decomposition (SVD) of this matrix such that this = U · W · transpose(V) and returns the rank of this matrix. The values of
U
,W
, andV
are all overwritten. Note that the matrixV
is output as V and not transpose(V). If this matrix is m x n, thenU
is m x m,W
is a diagonal matrix that is m x n, andV
is n x n. Using the notation W = diag(w), the inverse of this matrix is: inverse(this) = V · diag(1/w) · transpose(U), where diag(1/w) is the same matrix asW
except that the reciprocal of each of the diagonal components is used.public final int LUD(GMatrix LU, GVector permutation)The LUD method performs an LU decomposition. This matrix must be a square matrix; the
LU
parameter must be the same size as this matrix. The diagonal elements of L (unity) are not stored. Thepermutation
parameter records the row permutation affected by the partial pivoting, and is used as a parameter to the GVectorLUDBackSolve
method to solve sets of linear equations. This method returns ±1 depending on whether the number of row interchanges was even or odd, respectively.
Java 3D API Specification
Copyright © 1997, Sun Microsystems, Inc. All rights reserved.