The Java 3D API Specification |
A P P E N D I X A |
Math Objects |
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, which is why Java 3D defines them as a separate
javax.vecmath
package. Figure A-1 shows the math object hierarchy.
A.1
Java 3D uses tuple objects to represent and manipulate two-, three-, and four-element values.Tuple Objects
A.1.1
The Tuple2d class is used for points and vectors. This class is a two-element tuple that is represented by double-precision floating-point x,y coordinates.Tuple2d Class
Variables
The component values of a Tuple2d are directly accessible through the public variablesx and y
. To access thex
component of a Tuple2d calledupperLeftCorner
, a programmer would writeupperLeftCorner.x
. The programmer would access they
component similarly.
Figure A-1 Math Object Hierarchy
public double x Public double yThe x and y coordinates, respectively.public Tuple2d(double x, double y) public Tuple2d(double[] t) public Tuple2d(Tuple2d t1) public Tuple2d(Tuple2f t1) public Tuple2d()Each of these five constructors returns a new Tuple2d. The first constructor generates a Tuple2d from two double-precision floating-point numbers x and y. The second constructor generates a Tuple2d from the first two elements of arrayt
. The third and fourth constructors generate a Tuple2d from the tuplet1
. The final constructor generates a Tuple2d with the value of (0.0, 0.0).public final void set(double x, double y) public final void set(double[] t) public final void set(Tuple2d t1) public final void set(Tuple2f t1) public final void get(double[] t)The firstset
method sets the value of this tuple to the specified xy coordinates. The secondset
method sets the value of this tuple from the two values specified in the arrayt
. The third and fourthset
methods set the value of this tuple to the value of the tuplet1
. Theget
method copies the value of the elements of this tuple into the arrayt
.public final void add(Tuple2d t1, Tuple2d t2) public final void add(Tuple2d t1) public final void sub(Tuple2d t1, Tuple2d t2) public final void sub(Tuple2d t1)The firstadd
method sets the value of this tuple to the vector sum of tuplesv1
andv2
. The secondadd
method sets the value of this tuple to the vector sum of itself and tuplet1
. The firstsub
method sets the value of this tuple to the vector difference of tuplet1
andt2
(this = t1 - t2). The secondsub
method sets the value of this tuple to the vector difference of itself and tuplet1
(this = this - t1).public final void negate(Tuple2d t1) public final void negate()The firstnegate
method sets the value of this tuple to the negation of tuplet1
. The second method negates the value of this vector in place.public final void scale(double s, Tuple2d t1) public final void scale(double s) public final void scaleAdd(double s, Tuple2d t1) public final void scaleAdd(double s, Tuple2d t1, Tuple2d t2)The firstscale
method multiplies each element of the tuplet1
by the scale factors
and places the resulting scaled tuple intothis
. The second method multiplies each element of this tuple by the scale factors
and places the resulting scaled tuple intothis
. The firstscaleAdd
method scales this tuple by the scale factors
, adds the result to tuplet1
, and places the result into the tuplethis
(this = s*this + t1). The secondscaleAdd
method scales tuplet1
by the scale factors
, adds the result to tuplet1
, then places the result into the tuplethis
(this = s*t1 + t2).public final void absolute(Tuple2d t)This method sets each component of the tuple parameter to its absolute value and places the modified values into this tuple.public final void clamp(double min, double max) public final void clamp(double min, double max, Tuple2d t) public final void clampMin(double min) public final void clampMin(double min, Tuple2d t) public final void clampMax(double max) public final void clampMax(double max, Tuple2d t)The firstclamp
method clamps this tuple to the range [min
,max
]. The secondclamp
method clamps the values from tuplet
to the range [min
,max
] and assigns these clamped values to this tuple. The firstclampMin
method clamps each value of this tuple to themin
parameter. The secondclampMin
method clamps each value of the tuplet
and assigns these clamped values to this tuple. The firstclampMax
method clamps each value of this tuple to themax
parameter. The secondclampMax
method clamps each value of tuplet
to themax
parameter and assigns these clamped values to this tuple. In each method the values of tuplet
remain unchanged.public final void interpolate(Tuple2d t1, Tuple2d t2, double alpha) public final void interpolate(Tuple2d t1, double alpha)The first method linearly interpolates between tuplest1
andt2
and places the result into this tuple (this = (1 - alpha) * t1 + alpha * t2). The second method linearly interpolates between this tuple and tuplet1
and places the result into this tuple (this = (1 - alpha) * this + alpha * t1).public boolean equals(Tuple2d t1) public boolean equals(Object t1)The first method returnstrue
if all of the data members of tuplet1
are equal to the corresponding data members in this tuple. The second method returns true if the Objectt1
is of type Tuple2d and all of the data members oft1
are equal to the corresponding data members in this Tuple2d.public boolean epsilonEquals(Tuple2d t1, double epsilon)This method returnstrue
if the L distance between this tuple and tuplet1
is less than or equal to theepsilon
parameter. Otherwise, this method returnsfalse
. The L distance is equal to
public int hashCode()ThehashCode
method returns a hash number based on the data values in this object. Two Tuple2d objects with identical data values (that is,equals(Tuple2d)
returnstrue
) will return the same hash number. Two objects 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 Tuple2d.
A.1.1.1
The Point2d class extends Tuple2d. The Point2d is a two-element point represented by double-precision floating-point x,y coordinates.Point2d Class public Point2d(double x, double y) public Point2d(double p[]) public Point2d(Point2d p1) public Point2d(Point2f p1) public Point2d(Tuple2d t1) public Point2d(Tuple2f t1) public Point2d()Each of these seven constructors returns a new Point2d. The first constructor generates a Point2d from two double-precision floating-point numbers x and y. The second constructor generates a Point2d from the first two elements of arrayp
. The third and fourth constructors generate a Point2d from the pointp1
. The fifth and sixth constructors generate a Point2d from the tuplet1
. The final constructor generates a Point2d with the value of (0.0, 0.0).public final double distanceSquared(Point2d p1) public final double distance(Point2d p1)ThedistanceSquared
method computes the square of the Euclidean distance between this point and pointp1
and returns the result. Thedistance
method computes the Euclidean distance between this point and pointp1
and returns the result.public final double distanceL1(Point2d p1)This method computes the L1 (Manhattan) distance between this point and pointp1
. The L1 distance is equal to
public final double distanceLinf(Point2d p1)This method computes the L distance between this point and pointp1
. The L distance is equal to
A.1.1.2
The Vector2d class extends Tuple2d. The Vector2f is a two-element vector represented by double-precision floating-point x,y coordinates.Vector2d Class public Vector2d(double x, double y) public Vector2d(double v[]) public Vector2d(Vector2d v1) public Vector2d(Vector2f v1) public Vector2d(Tuple2d t1) public Vector2d(Tuple2f t1) public Vector2d()Each of these seven constructors returns a new Vector2d. The first constructor generates a Vector2d from two floating-point numbersx
andy
. The second constructor generates a Vector2d from the first two elements of arrayv
. The third and fourth constructors generate a Vector2d from the vectorv1
. The fifth and sixth constructors generate a Vector2d from the specified tuplet1
. The final constructor generates a Vector2d with the value of (0.0, 0.0).public final double dot(Vector2d v1)Thedot
method computes the dot product between this vector and vectorv1
and returns the resulting value.public final double lengthSquared() public final double length()ThelengthSquared
method computes the square of the length of the vectorthis
and returns its length as a double-precision floating-point number. Thelength
method computes the length of the vectorthis
and returns its length as a double-precision floating-point number.public final void normalize(Vector2d v1) public final void normalize()The firstnormalize
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(Vector2d v1)This method returns the angle, in radians, between this vector and vectorv1
. The return value is constrained to the range [0, ].
A.1.2
The Tuple2f class is a generic two-element tuple used mostly for specifying points and vectors made up of single-precision floating-point x,y coordinates.Tuple2f Class
Variables
The component values of a Tuple2f are directly accessible through the public variablesx
andy
. To access thex
component of a Tuple2f calledupperLeftCorner
, a programmer would writeupperLeftCorner.x
. The programmer would access they
component similarly.public float x public float yThe x and y coordinates, respectively.public Tuple2f(float x, float y) public Tuple2f(float t[]) public Tuple2f(Tuple2f t1) public Tuple2f(Tuple2d t1) public Tuple2f()Each of these five constructors returns a new Tuple2f. The first constructor generates a Tuple2f from two floating-point numbers x and y. The second constructor generates a Tuple2f from the first two elements of arrayt
. The third and fourth constructors generate a Tuple2f from the tuplet1
. The final constructor generates a Tuple2f with the value of (0.0, 0.0).public final void set(float x, float y) public final void set(float t[]) public final void set(Tuple2f t1) punlic final void set(Tiple2d t1) public final void get(float t[])Theset
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 t2) public final void add(Tuple2f t1) public final void sub(Tuple2f t1, Tuple2f t2) public final void sub(Tuple2f t1)The firstadd
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 firstnegate
method sets the values of this tuple to the negative of the values from tuplet1
. 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) public final void scaleAdd(float s, Tuple2f t1, Tuple2f t2)The firstscale
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 firstscaleAdd
method scales this tuple by the scale factors
, adds the result to tuplet1
, and places the result into the tuplethis
(this = s*this + t1). The secondscaleAdd
method scales tuplet1
by the scale factors
, adds the result to tuplet2
, then places the result into the tuplethis
(this = s*t1 + t2).public final void absolute() public final void absolute(Tuple2f t)The firstabsolute
method sets each component of this tuple to its absolute value. The secondabsolute
method sets each component of this tuple to the absolute value of the corresponding component in tuplet
.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) public final void clampMax(float max, Tuple2f t)The firstclamp
method clamps this tuple to the range [min
,max
]. The secondclamp
method clamps the values from tuplet
to the range [min
,max
] and assigns these clamped values to this tuple. The firstclampMin
method clamps each value of this tuple to themin
parameter. The secondclampMin
method clamps each value of the tuplet
and assigns these clamped values to this tuple. The firstclampMax
method clamps each value of this tuple to themax
parameter. The secondclampMax
method clamps each value of tuplet
to themax
parameter and assigns these clamped values to this tuple. In each method the values of tuplet
remain unchanged.public final void interpolate(Tuple2f t1, Tuple2f t2, float alpha) public final void interpolate(Tuple2f t1, float alpha)The first method linearly interpolates between tuplest1
andt2
and places the result into this tuple (this = (1 - alpha) * t1 + alpha * t2). The second method linearly interpolates between this tuple and tuplet1
and places the result into this tuple (this = (1 - alpha) * this + alpha * t1).public boolean equals(Tuple2f t1) public boolean equals(Object t1)The first method returnstrue
if all of the data members of tuplet1
are equal to the corresponding data members in this tuple. The second method returns true if the Objectt1
is of type Tuple2f and all of the data members oft1
are equal to the corresponding data members in this Tuple2f.public boolean epsilonEquals(Tuple2f t1, float epsilon)This method returnstrue
if the L distance between this tuple and tuplet1
is less than or equal to theepsilon
parameter. Otherwise, this method returnsfalse
. The L distance is equal to
public int hashCode()ThehashCode
method returns a hash number based on the data values in this object. Two Tuple2f objects with identical data values (that is,equals(Tuple2f)
returnstrue
) will return the same hash number. Two objects 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.2.1
The Point2f class extends Tuple2f. The Point2f is a two-element point represented by single-precision floating-point x,y coordinates.Point2f Class public Point2f(float x, float y) public Point2f(float p[]) public Point2f(Point2f p1) public Point2f(Point2d p1) public Point2f(Tuple2f t1) public Point2f(Tuple2f t1) public Point2f()Each of these seven constructors returns a new Point2f. The first constructor generates a Point2f from two floating-point numbers x and y. The second constructor generates a Point2f from the first two elements of arrayp
. The third and fourth constructors generate a Point2f from the pointp1
. The fifth and sixth constructors generate a Point2f from the tuplet1
. The final constructor generates a Point2f with the value of (0.0, 0.0).public final float distanceSquared(Point2f p1) public final float distance(Point2f p1)ThedistanceSquared
method computes the square of the Euclidean distance between this point and pointp1
and returns the result. Thedistance
method computes the Euclidean distance between this point and pointp1
and returns the result.public final float distanceL1(Point2f p1)This method computes the L1 (Manhattan) distance between this point and pointp1
. The L1 distance is equal to
public final float distanceLinf(Point2f p1)This method computes the L distance between this point and pointp1
. The L distance is equal to
A.1.2.2
The Vector2f class extends Tuple2f. The Vector2f is a two-element vector represented by single-precision floating-point x,y coordinates.Vector2f Class public Vector2f(float x, float y) public Vector2f(float v[]) public Vector2f(Vector2f v1) public Vector2f(Vector2d v1) public Vector2f(Tuple2f t1) public Vector2f(Tuple2d t1) public Vector2f()Each of these seven constructors returns a new Vector2f. The first constructor generates a Vector2f from two floating-point numbersx
andy
. The second constructor generates a Vector2f from the first two elements of arrayv
. The third and fourth constructors generate a Vector2f from the vectorv1
. The fifth and sixth constructors generate a Vector2f from the specified tuplet1
. The final constructor generates a Vector2f with the value of (0.0, 0.0).public final float dot(Vector2f v1)Thedot
method computes the dot product between this vector and vectorv1
and returns the resulting value.public final float lengthSquared() public final float length()ThelengthSquared
method computes the square of the length of the vectorthis
and returns its length as a single-precision floating-point number. Thelength
method computes the 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 firstnormalize
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 vectorv1
. The return value is constrained to the range [0, ].
A.1.2.3
The TexCoord2f class is a subset of Tuple2f. The TexCoord2f is a two-element vector represented by single-precision floating-point x,y coordinates.TexCoord2f Class public TexCoord2f(float x, float y) public TexCoord2f(float v[]) public TexCoord2f(TexCoord2f v1) public TexCoord2f(Tuple2f t1) public TexCoord2f()Each of these five constructors returns a new TexCoord2f. The first constructor generates a TexCoord2f from two floating-point numbersx
andy
. The second constructor generates a TexCoord2f from the first two elements of arrayv
. The third constructor generates a TexCoord2f from the TexCoord2fv1
. The fourth constructor generates a TexCoord2f from the Tuple2ft1
. The final constructor generates a TexCoord2f with the value of (0.0, 0.0).
A.1.3
The Tuple3b class is used for colors. This class represents a three-byte tuple. Note that Java defines a byte as a signed integer in the range [-128, 127]. However, colors are more typically represented by values in the range [0, 255]. Java 3D recognizes this and, in those cases where Tuple3b is used to represent color, treats the bytes as if the range were [0, 255]-in other words, as if the bytes were unsigned. Values greater than 127 can be assigned to a byte variable using a type cast. For example,Tuple3b Class byteVariable = (byte) intValue; // intValue can be > 127IfintValue
is greater than 127, thenbyteVariable
will be negative. The correct value will be extracted when it is used (by masking off the upper bits).
Variables
The component values of a Tuple3b are directly accessible through the public variablesx
,y
, andz
. To access thex
(red) component of a Tuple3b calledmyColor
, a programmer would writemyColor.x
. The programmer would access they
(green) andz
(blue) components similarly.public byte x public byte y public byte zThe red, green, and blue values, respectively.public Tuple3b(byte b1, byte b2, byte b3) public Tuple3b(byte t[]) public Tuple3b(Tuple3b t1) public Tuple3b()Each of these four constructors returns a new Tuple3b. The first constructor generates a Tuple3b from three bytesb1
,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 the value of (0.0, 0.0, 0.0).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 firstset
method sets the values 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 values of the x, y, and z data members of this Tuple3b to the values in 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) public boolean equals(Object t1)The first method returnstrue
if all of the data members of Tuple3bt1
are equal to the corresponding data members in this tuple. The second method returns true if the Objectt1
is of type Tuple3b and all of the data members oft1
are equal to the corresponding data members in this Tuple3b.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 (that is,equals(Tuple3b)
returnstrue
) 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.3.1
The Color3b class extends Tuple3b and represents three-byte color values.Color3b Class public Color3b(byte c1, byte c2, byte c3) public Color3b(byte c[]) public Color3b(Color3b c1) public Color3b(Tuple3b t1) public Color3b(Color color) public Color3b()Each of these five constructors returns a new Color3b. The first constructor generates a Color3b from three bytesc1
,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 fourth constructor generates a Color3b from the tuplet1
. The fifth constructor generates a Color3b from the specified AWT Color object. The final constructor generates a Color3b with the value of (0.0, 0.0, 0.0).public final void set(Color color) public final Color get()Theset
method sets the R,G,B values of this Color3b object to those of the specified AWT Color object. Theget
method returns a new AWT Color object initialized with the R,G,B values of this Color3b object.
A.1.4
The Tuple3d class is a generic three-element tuple represented by double-precision floating-point x, y, and z coordinates.Tuple3d Class
Variables
The component values of a Tuple3d are directly accessible through the public variablesx
,y
, andz
. To access thex
component of a Tuple3d calledupperLeftCorner
, a programmer would writeupperLeftCorner.x
. The programmer would access they
andz
components similarly.public double x public double y public double zThe x, y, and z coordinates, respectively.public Tuple3d(double x, double y, double z) public Tuple3d(double t[]) public Tuple3d(Tuple3d t1) public Tuple3d(Tuple3f t1) public Tuple3d()Each of these five constructors returns a new Tuple3d. The first constructor generates a Tuple3d from three floating-point numbersx
,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 the value of (0.0, 0.0, 0.0).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 fourset
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 firstadd
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 tuplet1
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 firstnegate
method sets the values of this tuple to the negative of the values from tuplet1
. The secondnegate
method negates the tuplethis
and places the resulting tuple back intothis
.public final void scaleAdd(double s, Tuple3f t1)A deprecated method. See method below.public final void scale(double s, Tuple3d t1) public final void scale(double s) public final void scaleAdd(double s, Tuple3d t1) public final void scaleAdd(double s, Tuple3d t1, Tuple3d t2)The firstscale
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
. The firstscaleAdd
method scales this tuple by the scale factors
, adds the result to tuplet1
, and places the result into tuplethis
(this = s*this + t1). The secondscaleAdd
method scales the tuplet1
by the scale factors
, adds the result to the tuplet2
, and places the result into the tuplethis
(this = s*t1 + t2).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 (that is,equals(Tuple3d)
returnstrue
) 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) public boolean equals(Object t1)The first method returnstrue
if all of the data members of Tuple3dv1
are equal to the corresponding data members in this Tuple3d. The second method returns true if the Objectt1
is of type Tuple3d and all of the data members oft1
are equal to the corresponding data members in this Tuple3d.public boolean epsilonEquals(Tuple3d t1, double epsilon)This method returnstrue
if the L distance between this tuple and tuplet1
is less than or equal to theepsilon
parameter. Otherwise, this method returnsfalse
. The L distance is equal to
public final void absolute() public final void absolute(Tuple3d t)The firstabsolute
method sets each component of this tuple to its absolute value. The secondabsolute
method sets each component of this tuple to the absolute value of the corresponding component in tuplet
.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, Tuple3d t)Deprecated methods. See the next six methods.public final void clamp(double min, double max) public final void clamp(double min, double max, Tuple3d t) public final void clampMin(double min) public final void clampMin(double min, Tuple3d t) public final void clampMax(double max) public final void clampMax(double max, Tuple3d t)The firstclamp
method clamps this tuple to the range [min
,max
]. The secondclamp
method clamps the values from tuplet
to the range [min
,max
] and assigns these clamped values to this tuple. The firstclampMin
method clamps each value of this tuple to themin
parameter. The secondclampMin
method clamps each value of the tuplet
and assigns these clamped values to this tuple. The firstclampMax
method clamps each value of this tuple to themax
parameter. The secondclampMax
method clamps each value of tuplet
to themax
parameter and assigns these clamped values to this tuple. In each method, the values of tuplet
remain unchanged.public final void interpolate(Tuple3d t1, Tuple3d t2, float alpha) public final void interpolate(Tuple3d t1, float alpha)Deprecated methods. See the next two methods.public final void interpolate(Tuple3d t1, Tuple3d t2, double alpha) public final void interpolate(Tuple3d t1, double alpha)The firstinterpolate
method linearly interpolates between tuplest1
andt2
and places the result into this tuple (this = (1 - alpha) * t1 + alpha * t2). The secondinterpolate
method linearly interpolates between this tuple and tuplet1
and places the result into this tuple (this = (1 - alpha) * this + alpha * t1).
A.1.4.1
The Point3d class extends Tuple3d. The Point3d is a three-element point represented by double-precision floating-point x, y, and z coordinates.Point3d Class public Point3d(double x, double y, double z) public Point3d(double p[]) public Point3d(Point3d p1) public Point3d(Point3f p1) public Point3d(Tuple3d t1) public Point3d(Tuple3f t1) public Point3d()Each of these seven constructors returns a new Point3d. The first constructor generates a Point3d from three floating-point numbersx
,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 fifth and sixth constructors generate a Point3d from the tuplet1
. The final constructor generates a Point3d with the value of (0.0, 0.0, 0.0).public final double distanceSquared(Point3d p1) public final double distance(Point3d p1)ThedistanceSquared
method computes the square of the Euclidean distance between this Point3d and the Point3dp1
and returns the result. Thedistance
method computes the Euclidean distance between this Point3d and the Point3dp1
and returns the result.public final double distanceL1(Point3d p1)This method computes the L1 (Manhattan) distance between this point and pointp1
. The L1 distance is equal to
public final double distanceLinf(Point3d p1)This method computes the L distance between this point and pointp1
. The L distance is equal to
public final void project(Point4d p1)This method multiplies each of thex
,y
, andz
components of the Point4d parameterp1
by 1/w
and places the projected values into this point.
A.1.4.2
The Vector3d class extends Tuple3d. The Vector3d is a three-element vector represented by double-precision floating-point x, y, and z coordinates. If this value represents a normal, it should be normalized.Vector3d Class public Vector3d(double x, double y, double z) public Vector3d(double v[]) public Vector3d(Vector3d v1) public Vector3d(Vector3f v1) public Vector3d(Tuple3d t1) public Vector3d(Tuple3f t1) public Vector3d()Each of these seven constructors returns a new Vector3d. The first constructor generates a Vector3d from three floating-point numbersx
,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 fifth and sixth constructors generate a Vector3d from the tuplet1
. The final constructor generates a Vector3d with the value of (0.0, 0.0, 0.0).public final void cross(Vector3d v1, Vector3d v2)Thecross
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 firstnormalize
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)Thedot
method returns the dot product of this vector and vectorv1
.public final double lengthSquared() public final double length()ThelengthSquared
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 vectorv1
parameter. The return value is constrained to the range [0, ].
A.1.5
The Tuple3f class is a generic three-element tuple represented by single-precision floating-point x, y, and z coordinates.Tuple3f Class
Variables
The component values of a Tuple3f are directly accessible through the public variablesx
,y
, andz
. To access thex
component of a Tuple3f calledupperLeftCorner
, a programmer would writeupperLeftCorner.x
. The programmer would access they
andz
components similarly.public float x public float y public float zThe x, y, and z coordinates, respectively.public Tuple3f(float x, float y, float z) public Tuple3f(float t[]) public Tuple3f(Tuple3d t1) public Tuple3f(Tuple3f t1) public Tuple3f()Each of these five constructors returns a new Tuple3f. The first constructor generates a Tuple3f from three floating-point numbersx
,y
, andz
. The second constructor generates a Tuple3f from the first three elements of arrayt
. The third constructor generates a Tuple3f from the double-precision Tuple3dt1
. The fourth constructor generates a Tuple3f from the single-precision Tuple3ft1
. The final constructor generates a Tuple3f with the value of (0.0, 0.0, 0.0).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 fourset
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 firstadd
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 tuplet2
from tuplet1
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 intothis
(this = this - t1).public final void negate(Tuple3f t1) public final void negate()The firstnegate
method sets the values of this tuple to the negative of the values from tuplet1
. The secondnegate
method negates the vectorthis
and places the resulting tuple back intothis
.public final void scale(float s, Tuple3f t1) public final void scale(float s) public final void scaleAdd(float s, Tuple3f t1) public final void scaleAdd(float s, Tuple3f t1, Tuple3f t2)The firstscale
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. The firstscaleAdd
method scales this tuple by the scale factors
, adds the result to tuplet1
, and places the result into tuplethis
(this = s*this + t1). The secondscaleAdd
method scales the tuplet1
by the scale factors
, adds the result to the tuplet2
, and places the result into the tuplethis
(this = s*t1 + t2).public boolean equals(Tuple3f t1) public boolean equals(Object t1)The first method returnstrue
if all of the data members of tuplet1
are equal to the corresponding data members in this Tuple3f. The second method returns true if the Objectt1
is of type Tuple3f and all of the data members oft1
are equal to the corresponding data members in this Tuple3f.public boolean epsilonEquals(Tuple3f t1, float epsilon)This method returnstrue
if the L distance between this tuple and tuplet1
is less than or equal to theepsilon
parameter. Otherwise, this method returnsfalse
. The L distance is equal to
public final void absolute() public final void absolute(Tuple3f t)The firstabsolute
method sets each component of this tuple to its absolute value. The secondabsolute
method sets each component of this tuple to the absolute value of the corresponding component in tuplet
.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) public final void clampMax(float max, Tuple3f t)The firstclamp
method clamps this tuple to the range [min
,max
]. The secondclamp
method clamps the values from tuplet
to the range [min
,max
] and assigns these clamped values to this tuple. The firstclampMin
method clamps each value of this tuple to themin
parameter. The secondclampMin
method clamps each value of the tuplet
and assigns these clamped values to this tuple. The firstclampMax
method clamps each value of this tuple to themax
parameter. The secondclampMax
method clamps each value of tuplet
to themax
parameter and assigns these clamped values to this tuple. In each method the values of tuplet
remain unchanged.public final void interpolate(Tuple3f t1, Tuple3f t2, float alpha) public final void interpolate(Tuple3f t1, float alpha)The first method linearly interpolates between tuplest1
andt2
and places the result into this tuple (this = (1 - alpha) * t1 + alpha * t2). The second method linearly interpolates between this tuple and tuplet1
and places the result into this tuple (this = (1-alpha) * this + alpha * t1).public int hashCode()This method returns a hash number based on the data values in this object. Two different Tuple3f objects with identical data values (that is,equals(Tuple3f)
returnstrue
) 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.5.1
The Point3f class extends Tuple3f. The Point3f is a three-element point represented by single-precision floating-point x, y, and z coordinates.Point3f Class public Point3f(float x, float y, float z) public Point3f(float p[]) public Point3f(Point3d p1) public Point3f(Point3f p1) public Point3f(Tuple3d t1) public Point3f(Tuple3f t1) public Point3f()Each of these seven constructors returns a new Point3f. The first constructor generates a point from three floating-point numbersx
,y
, andz
. The second constructor (Point3f(float p[]
) generates a point from the first three elements of arrayp
. The third constructor generates a point from the double-precision pointp1
. The fourth constructor generates a point from the single-precision pointp1
. The fifth and sixth constructors generate a Point3f from the tuplet1
. The final constructor generates a point with the value of (0.0, 0.0, 0.0).public final float distance(Point3f p1) public final float distanceSquared(Point3f p1)Thedistance
method computes the Euclidean distance between this point and the pointp1
and returns the result. ThedistanceSquared
method computes the square of the Euclidean distance between this point and the pointp1
and returns the result.public final float distanceL1(Point3f p1)This method computes the L1 (Manhattan) distance between this point and pointp1
. The L1 distance is equal to
public final float distanceLinf(Point3f p1)This method computes the L distance between this point and pointp1
. The L distance is equal to
public final void project(Point4f p1)This method multiplies each of thex
,y
, andz
components of the Point4f parameterp1
by 1/w
and places the projected values into this point.
A.1.5.2
The Vector3f class extends Tuple3f. The Vector3f is a three-element vector represented by single-precision floating-point x, y, and z coordinates.Vector3f Class public Vector3f(float x, float y, float z) public Vector3f(float v[]) public Vector3f(Vector3d v1) public Vector3f(Vector3f v1) public Vector3f(Tuple3d t1) Public Vector3f(Tuple3f t1) public Vector3f()Each of these seven constructors returns a new Vector3f. The first constructor generates a Vector3f from three floating-point numbersx
,y
, andz
. The second constructor generates a Vector3f from the first three elements of arrayv
. The third constructor generates a Vector3f from the double-precision Vector3dv1
. The fourth constructor generates a Vector3f from the single-precision Vector3fv1
. The fifth and sixth constructors generate a Vector3f from the tuplet1
. The final constructor generates a Vector3f with the value of (0.0, 0.0, 0.0).public final float length() public final float lengthSquared()Thelength
method computes the length of the vectorthis
and returns its length as a single-precision floating-point number. ThelengthSquared
method computes the square of the length of the vectorthis
and returns its length as a single-precision floating-point number.public final void cross(Vector3f v1, Vector3f v2)Thecross
method computes the vector cross-product ofv1
andv2
and places the result inthis
.public final float dot(Vector3f v1)Thedot
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 firstnormalize
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, ].
A.1.5.3
The TexCoord3f class extends Tuple3f. The TexCoord3f is a three-element texture coordinate represented by single-precision floating-point x, y, and z coordinates.TexCoord3f Class public TexCoord3f(float x, float y, float z) public TexCoord3f(float v[]) public TexCoord3f(TexCoord3f v1) public TexCoord3f(Tuple3d t1) public TexCoord3f(Tuple3f t1) public TexCoord3f()Each of these six constructors returns a new TexCoord3f. The first constructor generates a texture coordinate from three floating-point numbersx
,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 TexCoord3fv1
. The fourth and fifth constructors generate a texture coordinate from tuplet1
. The final constructor generates a texture coordinate with the value of (0.0, 0.0, 0.0).
A.1.5.4
The Color3f class extends Tuple3f. The Color3f is a three-element color value represented by single-precision floating-point x, y, and z values. The x, y, and z values represent the red, blue, and green color values, respectively. Color components should be in the range [0.0, 1.0].Color3f Class public Color3f(float x, float y, float z) public Color3f(float v[]) public Color3f(Color3f v1) public Color3f(Tuple3d t1) public Color3f(Tuple3f t1) public Color3f(Color color) public Color3f()Each of these six constructors returns a new Color3f. The first constructor generates a Color3f from three floating-point numbersx
,y
, andz
. The second constructor (Color3f(float v[]
) generates a Color3f from the first three elements of arrayv
. The third constructor generates a Color3f from the single-precision colorv1
. The fourth and fifth constructors generate a Color3f from the tuplet1
. The sixth constructor generates a Color3f from the specified AWT Color object. The final constructor generates a Color3f with the value of (0.0, 0.0, 0.0).public final void set(Color color) public final Color get()Theset
method sets the R,G,B values of this Color3f object to those of the specified AWT Color object. Theget
method returns a new AWT Color object initialized with the R,G,B values of this Color3f object.
A.1.6
The Tuple3i class is a generic three-element tuple represented by signed integer x,y,z coordinates.Tuple3i Class
Variables
The component values of a Tuple3i are directly accessible through the public variablesx
,y
, andz
. To access thex
component of a Tuple3i calledupperLeftCorner
, a programmer would writeupperLeftCorner.x
. The programmer would access they
andz
components similarly.public int x public int y public int zThe x, y, and z coordinates, respectively.public Tuple3i(int x, int y, int z) public Tuple3i(int[] t) public Tuple3i(Tuple3i t1) public Tuple3i()Each of these four constructors returns a new Tuple3i. The first constructor generates a Tuple3i from the specified x, y, and z coordinates. The second constructor generates a Tuple3i from the array of length 3. The third constructor generates a Tuple3i from the specified Tuple3i. The final constructor generates a Tuple3i with the value of (0,0,0).public String toString()This method returns a string that contains the values of this Tuple3i.public final void set(int x, int y, int z) public final void set(int[] t) public final void set(Tuple3i t1) public final void get(int[] t) public final void get(Tuple3i t)The firstset
method sets the value of this tuple to the specified x, y, and z coordinates. The secondset
method sets the value of this tuple to the specified coordinates in the array of length 3. The thirdset
method sets the value of this tuple to the value of tuplet1
. The firstget
method copies the values of this tuple into the arrayt
. The secondget
method copies the values of this tuple into the tuplet
.public final void add(Tuple3i t1, Tuple3i t2) public final void add(Tuple3i t1)The first method sets the value of this tuple to the sum of tuplest1
andt2
. The second method sets the value of this tuple to the sum of itself andt1
.public final void sub(Tuple3i t1, Tuple3i t2) public final void sub(Tuple3i t1)The first method sets the value of this tuple to the difference of tuplest1
andt2
(this = t1 - t2). The second method sets the value of this tuple to the difference of itself and t1 (this = this - t1).public final void negate(Tuple3i t1) public final void negate()The first method sets the value of this tuple to the negation of tuplet1
. The second method negates the value of this tuple in place.public final void scale(int s, Tuple3i t1) public final void scale(int s)The first method sets the value of this tuple to the scalar multiplication of tuplet1
. The second method sets the value of this tuple to the scalar multiplication of the scale factor with this.public final void scaleAdd(int s, Tuple3i t1, Tuple3i t2) public final void scaleAdd(int s, Tuple3i t1)The first method sets the value of this tuple to the scalar multiplication of tuplet1
plus tuplet2
(this = s*t1 + t2). The second method sets the value of this tuple to the scalar multiplication of itself and then adds tuplet1
(this = s*this + t1).public boolean equals(Object t1)This method returns true if the Objectt1
is of type Tuple3i and all of the data members oft1
are equal to the corresponding data members in this Tuple3i.public final void clamp(int min, int max, Tuple3i t) public final void clamp(int min, int max)The first method clamps the tuple parameter to the range [low
,high
] and places the values into this tuple. The second method clamps this tuple to the range [low
,high
].public final void clampMin(int min, Tuple3i t) public final void clampMin(int min) public final void clampMax(int max, Tuple3i t) public final void clampMax(int max)The first method clamps the minimum value of the tuple parameter to themin
parameter and places the values into this tuple. The second method clamps the minimum value of this tuple to themin
parameter. The third method clamps the maximum value of the tuple parameter to themax
parameter and places the values into this tuple. The final method clamps the maximum value of this tuple to themax
parameter.public final void absolute(Tuple3i t) public final void absolute()The first method sets each component of the tuple parameter to its absolute value and places the modified values into this tuple. The second method sets each component of this tuple to its absolute value.public int hashCode()This method returns a hash code value based on the data values in this object. Two different Tuple3i objects with identical data values (that is, Tuple3i.equals returns true) will return the same hash code value. Two objects with different data members may return the same hash value, although this is not likely.
A.1.6.1
The Point3i class extends Tuple3i. The Point3i is a three-element point represented by signed integer x,y,z coordinates.Point3i Class public Point3i(int x, int y, int z) public Point3i(int[] t) public Point3i(Tuple3i t1 public Point3i()Each of these four constructors returns a new Point3i. The first constructor generates a Point3i from the specified x, y, and z coordinates. The second constructor generates a Point3i from the array of length 3. The third constructor generates a Point3i from the specified Tuple3i. The final constructor generates a Point3i with the value of (0,0,0).
A.1.7
The Tuple4b class represents four-byte tuples. Note that Java defines a byte as a signed integer in the range [-128, 127]. However, colors are more typically represented by values in the range [0, 255]. Java 3D recognizes this and, in those cases where Tuple4b is used to represent color, treats the bytes as if the range were [0, 255]-in other words, as if the bytes were unsigned. Values greater than 127 can be assigned to a byte variable using a type cast. For example,Tuple4b Class byteVariable = (byte) intValue; // intValue can be > 127IfintValue
is greater than 127, thenbyteVariable
will be negative. The correct value will be extracted when it is used (by masking off the upper bits).
Variables
The component values of a Tuple4b are directly accessible through the public variablesx
,y
,z
, andw
. Thex
,y
,z
, andw
values represent the red, green, blue, and alpha values, respectively. To access thex
(red) component of a Tuple4b calledbackgroundColor
, a programmer would writebackgroundColor.x
. The programmer would access they
(green),z
(blue), andw
(alpha) components similarly.public byte x public byte y public byte z public byte wThe red, green, blue, and alpha values, respectively.public Tuple4b(byte b1, byte b2, byte b3, byte b4) public Tuple4b(byte t[]) public Tuple4b(Tuple4b t1) public Tuple4b()Each of these four constructors returns a new Tuple4b. The first constructor generates a Tuple4b from four bytesb1
,b2
,b3
, andb4
. The second constructor (Tuple4b(byte t[]
) 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 the value of (0.0, 0.0, 0.0, 0.0).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 firstset
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 values of thex
,y
,z
, andw
components of this Tuple4b into the byte arrayb
. The secondget
method places the values of thex
,y
,z
, andw
components of this Tuple4b into the Tuple4bt1
.public boolean equals(Tuple4b t1) public boolean equals(Object t1)The first method returnstrue
if all of the data members of Tuple4bt1
are equal to the corresponding data members in this Tuple4b. The second method returns true if the Objectt1
is of type Tuple4b and all of the data members oft1
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 (that is,equals(Tuple4b)
returnstrue
) will return the same hash number. Two Tuple4b objects with different data members may return the same hash value, although this is not likely.
A.1.7.1
The Color4b class extends Tuple4b. The Color4b is a four-byte color value (red, green, blue, and alpha).Color4b Class public Color4b(byte b1, byte b2, byte b3, byte b4) public Color4b(byte c[]) public Color4b(Color4b c1) public Color4b(Tuple4b t1) public Color4b(Color color) public Color4b()Each of these five constructors returns 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 fourth constructor generates a Color4b from the tuplet1
. The fifth constructor generates a Color4b from the specified AWT Color object. The final constructor generates a Color4b with the value of (0.0, 0.0, 0.0, 0.0).public final void set(Color color) public final Color get()Theset
method sets the R,G,B,A values of this Color4b object to those of the specified AWT Color object. Theget
method returns a new AWT Color object initialized with the R,G,B,A values of this Color4b object.
A.1.8
The Tuple4d class represents a four-element tuple represented by double-precision floating-point x, y, z, and w coordinates.Tuple4d Class
Variables
The component values of a Tuple4d are directly accessible through the public variablesx
,y
,z
, andw
. To access thex
component of a Tuple4d calledupperLeftCorner
, 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.public Tuple4d(double x, double y, double z, double w) public Tuple4d(double t[]) public Tuple4d(Tuple4d t1) public Tuple4d(Tuple4f t1) public Tuple4d()Each of these five constructors returns a new Tuple4d. The first constructor generates a Tuple4d from four floating-point numbersx
,y
,z
, andw
. The second constructor (Tuple4d(double t[]
) 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 the value of (0.0, 0.0, 0.0, 0.0).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(Tuple4f t1) public final void get(double t[]) public final void get(Tuple4d t)These methods set the value of the tuplethis
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 secondget
method retrieves the value of this tuple and places it 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 firstadd
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 firstnegate
method sets the values of this tuple to the negative of the values from tuplet1
. The secondnegate
method negates the tuplethis
and places the resulting tuple back intothis
.public final void scaleAdd(float s, Tuple4d t1)Deprecated method. See the following method.public final void scale(double s, Tuple4d t1) public final void scale(double s) public final void scaleAdd(double s, Tuple4d t1) public final void scaleAdd(double s, Tuple4d t1, Tuple4d t2)The firstscale
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
and replacesthis
with the scaled value. The firstscaleAdd
method scales this tuple by the scale factors
, adds the result to tuplet1
, and places the result into tuplethis
(this = s*this + t1). The secondscaleAdd
method scales the tuplet1
by the scale factors
, adds the result to the tuplet2
, and places the result into the tuplethis
(this = s*t1 + t2).public void interpolate(Tuple4d t1, Tuple4d t2, float alpha) public void interpolate(Tuple4d t1, float alpha)Deprecated methods. See the following two methods.public void interpolate(Tuple4d t1, Tuple4d t2, double alpha) public void interpolate(Tuple4d t1, double alpha)The firstinterpolate
method linearly interpolates between tuplest1
andt2
and places the result into this tuple (this = (1 - alpha) * t1 + alpha * t2). The secondinterpolate
method linearly interpolates between this tuple and tuplet1
and places the result into this tuple (this = (1 - alpha) * this + 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) public boolean equals(Object t1)The first method returnstrue
if all of the data members of tuplev1
are equal to the corresponding data members in this tuple. The second method returns true if the Objectt1
is of type Tuple4d and all of the data members oft1
are equal to the corresponding data members in this Tuple4d.public boolean epsilonEquals(Tuple4d t1, double epsilon)This method returnstrue
if the L distance between this Tuple4d and Tuple4d t1
is less than or equal to theepsilon
parameter. Otherwise, this method returnsfalse
. The L distance is equal to
public final void absolute() public final void absolute(Tuple4d t)The firstabsolute
method sets each component of this tuple to its absolute value. The secondabsolute
method sets each component of this tuple to the absolute value of the corresponding component in tuplet
.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)Deprecated methods. See the following six methods.public final void clamp(double min, double max) public final void clamp(double min, double max, Tuple4d t) public final void clampMin(double min) public final void clampMin(double min, Tuple4d t) public final void clampMax(double max) public final void clampMax(double max, Tuple4d t)The firstclamp
method clamps this tuple to the range [min
,max
]. The secondclamp
method clamps this tuple to the range [min
,max
] 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 (that is,equals(Tuple4d)
returnstrue
) will return the same hash number. Two Tuple4d objects with different data members may return the same hash value, although this is not likely.
A.1.8.1
The Point4d class extends Tuple4d. The Point4d is a four-element point represented by double-precision floating-point x, y, z, and w coordinates.Point4d Class public Point4d(double x, double y, double z, double w) public Point4d(double p[]) public Point4d(Point4d p1) public Point4d(Point4f p1) public Point4d(Tuple4d t1) public Point4d(Tuple4f t1) public Point4d(Tuple3d t1) public Point4d()Each of these eight constructors returns a new Point4d. The first constructor generates a Point4d from four floating-point numbersx
,y
,z
, andw
. The second constructor (Point4d(double p[]
) 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 fifth and sixth constructors generate a Point4d from tuplet1
. The seventh constructor generates a Point4d from the specified Tuple3d-thew
component of this point is set to 1. The final constructor generates a Point4d with the value of (0.0, 0.0, 0.0, 0.0).public final void set(Tuple3d t1)This method sets thex
,y
, andz
components of this point to the corresponding components of tuplet1
. Thew
component of this point is set to 1.public final double distance(Point4d p1) public final double distanceSquared(Point4d p1)Thedistance
method computes the Euclidean distance between this point and the pointp1
and returns the result. ThedistanceSquared
method computes the square of the Euclidean distance between this point and the pointp1
and returns the result.public final double distanceL1(Point4d p1)This method computes the L1 (Manhattan) distance between this point and pointp1
. The L1 distance is equal to
public final double distanceLinf(Point4d p1)This method computes the L distance between this point and pointp1
. The L distance is equal to
public final void project(Point4d p1)This method multiplies each of the x, y, and z components of the pointp1
by , places the projected values into this point, and places a 1 into thew
parameter of this point.
A.1.8.2
The Vector4d class extends Tuple4d. The Vector4d is a four-element vector represented by double-precision floating-point x, y, z, and w coordinates.Vector4d Class public Vector4d(double x, double y, double z, double w) public Vector4d(double v[]) public Vector4d(Vector4d v1) public Vector4d(Vector4f v1) public Vector4d(Tuple4d t1) public Vector4d(Tuple4f t1) public Vector4d(Tuple3d t1) public Vector4d()Each of these eight constructors returns a new Vector4d. The first constructor generates a Vector4d from four floating-point numbersx
,y
,z
, andw
. The second constructor generates a Vector4d from the first four elements of arrayv
. The third constructor generates a Vector4d from the double-precision Vector4dv1
. The fourth constructor generates a Vector4d from the single-precision Vector4fv1
. The fifth and sixth constructors generate a Vector4d from tuplet1
. The seventh constructor generates a Vector4d from the specified Tuple3d-thew
component of this vector is set to 0. The final constructor generates a Vector4d with the value of (0.0, 0.0, 0.0, 0.0).public final void set(Tuple3d t1)This method sets thex
,y
, andz
components of this vector to the corresponding components of tuplet1
. Thew
component of this vector is set to 0.public final double length() public final double lengthSquared()Thelength
method computes the length of the vectorthis
and returns its length as a double-precision floating-point number. ThelengthSquared
method computes the square of the 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 vectorv1
.public final void normalize(Vector4d v1) public final void normalize()The firstnormalize
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 vectorv1
parameter. The return value is constrained to the range [0, ].
A.1.8.3
The Quat4d class extends Tuple4d. The Quat4d is a four-element quaternion represented by double-precision floating-point x, y, z, and w values.Quat4d Class public Quat4d(double x, double y, double z, double w) public Quat4d(double q[]) public Quat4d(Quat4d q1) public Quat4d(Quat4f q1) public Quat4d(Tuple4d t1) public Quat4d(Tuple4f t1) public Quat4d()Each of these seven constructors returns a new Quat4d. The first constructor generates a quaternion from four floating-point numbersx
,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 fifth and sixth constructors generate a Quat4d from tuplet1
. The final constructor generates a quaternion with the value of (0.0, 0.0, 0.0, 0.0).public final void conjugate(Quat4d q1) public final void conjugate()The firstconjugate
method sets the values 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 firstmul
method sets the value of this quaternion to the quaternion product of quaternionsq1
andq2
(this = q1 * q2). Note that this is safe for aliasing (that is,this
can beq1
orq2
). 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 firstmulInverse
method multiplies quaternionq1
by the inverse of quaternionq2
and places the value into this quaternion. The values of both quaternion arguments are 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 argumentq1
is preserved (this = this * q1-1).public final void inverse(Quat4d q1) public final void inverse()The firstinverse
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 firstnormalize
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)Theseset
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 quaternionq1
and quaternionq2
and places the result into this quaternion.
A.1.9
The Tuple4f class represents a four-element tuple represented by single-precision floating-point x, y, z, and w values.Tuple4f Class
Variables
The component values of a Tuple4f are directly accessible through the public variablesx
,y
,z
, andw
. To access thex
component of a Tuple4f calledupperLeftCorner
, 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.public Tuple4f(float x, float y, float z, float w) public Tuple4f(float t[]) public Tuple4f(Tuple4d t1) public Tuple4f(Tuple4f t1) public Tuple4f()Each of these five constructors returns a new Tuple4f. The first constructor generates a Tuple4f from four floating-point numbersx
,y
,z
, andw
. The second constructor (Tuple4f(float t[]
) 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 Tuple4f with the value of (0.0, 0.0, 0.0, 0.0).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 firstset
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 firstadd
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 firstnegate
method sets the values of this tuple to the negative of the values from tuplet1
. The secondnegate
method negates the tuplethis
and places the resulting 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) public final void scaleAdd(float s, Tuple4f t1, Tuple4f t2)The firstscale
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. The firstscaleAdd
method scales this tuple by the scale factors
, adds the result to tuplet1
, and places the result into tuplethis
(this = s*this + t1). The secondscaleAdd
method scales the tuplet1
by the scale factors
, adds the result to the tuplet2
, and places the result into the tuplethis
(this = s*t1 + t2).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) public boolean equals(Object t1)The first method returnstrue
if all of the data members of Tuple4ft1
are equal to the corresponding data members in this Tuple4f. The second method returns true if the Objectt1
is of type Tuple4f and all of the data members oft1
are equal to the corresponding data members in this Tuple4f.public boolean epsilonEquals(Tuple4f t1, float epsilon)This method returnstrue
if the L distance between this Tuple4f and Tuple4ft1
is less than or equal to theepsilon
parameter. Otherwise, this method returnsfalse
. The L distance is equal to
public final void absolute() public final void absolute(Tuple4f t)The firstabsolute
method sets each component of this tuple to its absolute value. The secondabsolute
method sets each component of this tuple to the absolute value of the corresponding component in tuplet
.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 firstclamp
method clamps this tuple to the range [min
,max
]. The secondclamp
method clamps this tuple to the range [min
,max
] 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 firstinterpolate
method linearly interpolates between tuplest1
andt2
and places the result into this tuple (this = (1 - alpha) * t1 + alpha * t2). The secondinterpolate
method linearly interpolates between this tuple and tuplet1
and places the result into this tuple (this = (1 - alpha) * this + 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 (that is,equals(Tuple4f)
returnstrue
) will return the same hash number. Two Tuple4f objects with different data members may return the same hash value, although this is not likely.
A.1.9.1
The Point4f class extends Tuple4f. The Point4f is a four-element point represented by single-precision floating-point x, y, z, and w coordinates.Point4f Class public Point4f(float x, float y, float z, float w) public Point4f(float p[]) public Point4f(Point4d p1) public Point4f(Point4f p1) public Point4f(Tuple4d t1) public Point4f(Tuple4f t1) public Point4f(Tuple3f t1) public Point4f()Each of these eight constructors returns a new Point4f. The first constructor generates a Point4f from four floating-point numbersx
,y
,z
, andw
. The second constructor (Point4f(float p[]
) 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 Point4f from the single-precision pointp1
. The fifth and sixth constructors generate a Point4f from tuplet1
. The seventh constructor generates a Point4f from the specified Tuple3f-thew
component of this point is set to 1. The final constructor generates a Point4f with the value of (0.0, 0.0, 0.0, 0.0).public final void set(Tuple3f t1)This method sets thex
,y
, andz
components of this point to the corresponding components of tuplet1
. Thew
component of this point is set to 1.public final float distanceSquared(Point4f p1) public final float distance(Point4f p1)ThedistanceSquared
method computes the square of the Euclidean distance between this point and the pointp1
and returns the result. Thedistance
method computes the Euclidean distance between this point and the pointp1
and returns the result.public final float distanceL1(Point4f p1)This method computes the L1 (Manhattan) distance between this point and pointp1
. The L1 distance is equal to
public final float distanceLinf(Point4f p1)This method computes the L distance between this point and pointp1
. The L distance is equal to
public final void project(Point4f p1)This method multiplies each of thex
,y
, andz
components of the pointp1
by , places the projected values into this point, and places a 1 into thew
parameter of this point.
A.1.9.2
The Color4f class extends Tuple4f. The Color4f is a four-element color value represented by single-precision floating-point x, y, z, and w values. The x, y, z, and w values represent the red, blue, green, and alpha color values, respectively. Color and alpha components should be in the range [0.0, 1.0].Color4f Class public Color4f(float x, float y, float z, float w) public Color4f(float c[]) public Color4f(Color4f c1) public Color4f(Tuple4d t1) public Color4f(Tuple4f t1) public Color4f(Color color) public Color4f()Each of these seven constructors returns a new Color4f. The first constructor generates a Color4f from four floating-point numbersx
,y
,z
, andw
. The second constructor generates a Color4f from the first four elements of arrayc
. The third constructor generates a Color4f from the single-precision colorc1
. The fourth and fifth constructors generate a Color4f from tuplet1
. The sixth constructor generates a Color4f from the specified AWT Color object. The final constructor generates a Color4f with the value of (0.0, 0.0, 0.0, 0.0).public final void set(Color color) public final Color get()Theset
method sets the R,G,B,A values of this Color4f object to those of the specified AWT Color object. Theget
method returns a new AWT Color object initialized with the R,G,B,A values of this Color4f object.
A.1.9.3
The Vector4f class extends Tuple4f. The Vector4f is a four-element vector represented by single-precision floating-point x, y, z, and w coordinates.Vector4f Class public Vector4f(float x, float y, float z, float w) public Vector4f(float v[]) public Vector4f(Vector4d v1) public Vector4f(Vector4f v1) public Vector4f(Tuple4d t1) public Vector4f(Tuple4f t1) public Vector4f(Tuple3f t1) public Vector4f()Each of these eight constructors returns a new Vector4f. The first constructor generates a Vector4f from four floating-point numbersx
,y
,z
, andw
. The second constructor generates a Vector4f from the first four elements of arrayv
. The third constructor generates a Vector4f from the double-precision Vector4dv1
. The fourth constructor generates a Vector4f from the single-precision Vector4fv1
. The fifth and sixth constructors generate a Vector4f from tuplet1
. The seventh constructor generates a Vector4f from the specified Tuple3f-thew
component of this vector is set to 0. The final constructor generates a Vector4f with the value of (0.0, 0.0, 0.0, 0.0).public final void set(Tuple3f t1)This method sets thex
,y
, andz
components of this vector to the corresponding components of tuplet1
. Thew
component of this vector is set to 0.public final float length() public final float lengthSquared()Thelength
method computes the length of the vectorthis
and returns its length as a single-precision floating-point number. ThelengthSquared
method computes the square of the length of the vectorthis
and returns its length as a single-precision floating-point number.public final float dot(Vector4f v1)Thedot
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 firstnormalize
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 vectorv1
parameter. The return value is constrained to the range [0, ].
A.1.9.4
The Quat4f class extends Tuple4f. The Quat4f is a four-element quaternion represented by single-precision floating-point x, y, z, and w coordinates.Quat4f Class public Quat4f(float x, float y, float z, float w) public Quat4f(float q[]) public Quat4f(Quat4d q1) public Quat4f(Quat4f q1) public Quat4f(Tuple4d t1) public Quat4f(Tuple4f t1) public Quat4f()Each of these seven constructors returns a new Quat4f. The first constructor generates a quaternion from four floating-point numbersx
,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 quaternionq1
. The fourth constructor generates a quaternion from the single-precision quaternionq1
. The fifth and sixth constructors generate a quaternion from tuplet1
. The final constructor generates a quaternion with the value of (0.0, 0.0, 0.0, 0.0).public final void conjugate(Quat4f q1) public final void conjugate()The firstconjugate
method sets the value of this quaternion to the conjugate of quaternionq1
. The secondconjugate
method sets the value of this quaternion to the conjugate of itself.public final void mul(Quat4f q1, Quat4f q2) public final void mul(Quat4f q1)The firstmul
method sets the value of this quaternion to the quaternion product of quaternionsq1
andq2
(this = q1 * q2). Note that this is safe for aliasing (that is,this
can beq1
orq2
). 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 firstmulInverse
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 firstinverse
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 firstnormalize
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)Theseset
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 quaternionq1
and places the result into this quaternion. The second method performs a great circle interpolation between quaternionq1
and quaternionq2
and places the result into this quaternion.
A.1.10
The Tuple4i class represents a four-element tuple represented by signed integer x, y, z, and w coordinates.Tuple4i Class
Variables
The component values of a Tuple4i are directly accessible through the public variablesx
,y
,z
, andw
. To access thex
component of a Tuple4i calledupperLeftCorner
, a programmer would writeupperLeftCorner.x
. The programmer would access they
,z
, andw
components similarly.public int x public int y public int z public int wThe x, y, z, and w values, respectively.public Tuple4i(int x, int y, int z, int w) public Tuple4i(int[] t) public Tuple4i(Tuple4i t1) public Tuple4i()Each of these four constructors returns a new Tuple4i. The first constructor generates a Tuple4i from the specifiedx
,y
,z
, andw
coordinates. The second constructor generates a Tuple4i from the array of length 4. The third constructor generates a Tuple4i from the specified Tuple4i. The final constructor generates a Tuple4i with the value of (0,0,0,0).public final void set(int x, int y, int z, int w) public final void set(int[] t) public final void set(Tuple4i t1) public final void get(int[] t) public final void get(Tuple4i t)The firstset
method sets the value of this tuple to the specifiedx
,y
,z
, andw
coordinates. The secondset
method sets the value of this tuple to the specified coordinates in the array of length 4. The thirdset
method sets the value of this tuple to the value of tuple t1. The firstget
method copies the values of this tuple into the arrayt
. The secondget
method copies the values of this tuple into the tuplet
.public final void add(Tuple4i t1, Tuple4i t2) public final void add(Tuple4i t1)The first method sets the value of this tuple to the sum of tuplest1
andt2
. The second method sets the value of this tuple to the sum of itself andt1
.
public final void sub(Tuple4i t1, Tuple4i t2) public final void sub(Tuple4i t1)The first method sets the value of this tuple to the difference of tuplest1
andt2
(this = t1 - t2). The second method sets the value of this tuple to the difference of itself andt1
(this = this - t1).public final void negate(Tuple4i t1 public final void negate()The first method sets the value of this tuple to the negation of tuplet1
. The second method negates the value of this tuple in place.public final void scale(int s, Tuple4i t1) public final void scale(int s)The first method sets the value of this tuple to the scalar multiplication of tuplet1
. The second method sets the value of this tuple to the scalar multiplication of the scale factor with this.public final void scaleAdd(int s, Tuple4i t1, Tuple4i t2) public final void scaleAdd(int s, Tuple4i t1)The first method sets the value of this tuple to the scalar multiplication of tuplet1
plus tuplet2
(this = s*t1 + t2). The second method sets the value of this tuple to the scalar multiplication of itself and then adds tuplet1
(this = s*this + t1).public final void clamp(int min, int max, Tuple4i t) public final void clamp(int min, int max)The first method clamps the tuple parameter to the range [low, high] and places the values into this tuple. The second method clamps this tuple to the range [low, high].public final void clampMin(int min, Tuple4i t) public final void clampMin(int min)The first method clamps the minimum value of the tuple parameter to themin
parameter and places the values into this tuple. The second method clamps the minimum value of this tuple to themin
parameter.public final void clampMax(int max, Tuple4i t) public final void clampMax(int max)The first method clamps the maximum value of the tuple parameter to themax
parameter and places the values into this tuple. The second method clamps the maximum value of this tuple to themax
parameter.public final void absolute(Tuple4i t) public final void absolute()The first method sets each component of the tuple parameter to its absolute value and places the modified values into this tuple. The second method sets each component of this tuple to its absolute value.public String toString()This method returns a string that contains the values of this Tuple4i.public boolean equals(Object t1)This method returns true if the Objectt1
is of type Tuple4i and all of the data members oft1
are equal to the corresponding data members in this Tuple4i.public int hashCode()This method returns a hash code value based on the data values in this object. Two different Tuple4i objects with identical data values (that is, Tuple4i.equals returns true) will return the same hash code value. Two objects with different data members may return the same hash value, although this is not likely.
A.1.10.1
The Point4i class extends Tuple4i. The Point4i is a four-element point represented by signed integer x, y, z, and w coordinates.Point4i Class public Point4i(int x, int y, int z, int w) public Point4i(int[] t) public Point4i(Tuple4i t1) public Point4i()Each of these four constructors returns a Point4i. The first constructor generates a Point4i from the specified x, y, z, and w coordinates. The second constructor generates a Point4i from the array of length 4. The third constructor generates a Point4i from the specified Tuple4i. The final constructor generates a Point4i with the value of (0,0,0,0).
A.1.11
The AxisAngle4d class represents a four-element axis-angle represented by double-precision floating-point x, y, z coordinates and an angle of rotation in radians. An axis-angle is a rotation ofAxisAngle4d Class angle
radians about the vectorx
,y
,z
.
Variables
The component values of an AxisAngle4d are directly accessible through the public variablesx
,y
,z
, andangle
. To access thex
component of an AxisAngle4d calledmyRotation
, a programmer would writemyRotation.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.public AxisAngle4d(double x, double y, double z, double angle) public AxisAngle4d(double a[]) public AxisAngle4d(AxisAngle4d a1) public AxisAngle4d(AxisAngle4f a1) public AxisAngle4d(Vector3d axis, double angle) public AxisAngle4d()Each of these six constructors returns a new AxisAngle4d. The first constructor generates an axis-angle from four floating-point numbersx
,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 fifth constructor generates an axis-angle from the specified axis and angle. The final constructor generates an axis-angle with the value of (0.0, 0.0, 1.0, 0.0).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(AxisAngle4f a1) public final void set(AxisAngle4d a1) public final void set(Quat4f q1) public final void set(Quat4d q1) public final void set(Vector3d axis, double angle) public final void get(double a[])The firstset
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 fourset
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 next twoset
methods set the value of this axis-angle to the value of the passed quaternionq1
. The last set method sets the value of this axis-angle to the specified axis and angle. Theget
method retrieves the value of this axis-angle and places it into the arraya
of length four inx
,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) public boolean equals(Object o1)The first method returnstrue
if all of the data members of AxisAngle4dv1
are equal to the corresponding data members in this axis-angle. The second method returns true if the Objecto1
is of type AxisAngle4d and all of the data members ofo1
are equal to the corresponding data members in this AxisAngle4d.public boolean epsilonEquals(AxisAngle4d a1, double epsilon)This method returnstrue
if the L distance between this axis-angle and axis-anglea1
is less than or equal to theepsilon
parameter. Otherwise, this method returnsfalse
. The L distance is equal to
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 (that is,equals(AxisAngle4d)
returnstrue
) will return the same hash number. Two AxisAngle4d objects with different data members may return the same hash value, although this is not likely.
A.1.12
The AxisAngle4f class represents a four-element axis-angle represented by single-precision floating-point x, y, and z coordinates and an angle of rotation in radians. An axis-angle is a rotation ofAxisAngle4f Class angle
radians about the vectorx
,y
,z
.
Variables
The component values of an AxisAngle4f are directly accessible through the public variablesx
,y
,z
, andangle
. To access thex
component of an AxisAngle4f calledmyRotation
, a programmer would writemyRotation.x
. The programmer would access they
,z
, andangle
components similarly.public float x public float y public float z public float angleThe x, y, and z coordinates and the rotational angle, respectively. The rotation angle is expressed in radians.public AxisAngle4f(float x, float y, float z, float angle) public AxisAngle4f(float a[]) public AxisAngle4f(AxisAngle4f a1) public AxisAngle4f(AxisAngle4d a1) public AxisAngle4f(Vector3f axis, float angle) public AxisAngle4f()Each of these six constructors returns a new AxisAngle4f. The first constructor generates an axis-angle from four floating-point numbersx
,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 fifth constructor generates an axis-angle from the specified axis and angle. The final constructor generates an axis-angle with the value of (0.0, 0.0, 1.0, 0.0).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 set(Vector3f axis, float angle) public final void get(float a[])The firstset
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 fourset
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 next twoset
methods set the value of this axis-angle to the value of the passed quaternionq1
. The lastset
method sets the value of this axis-angle to the specified axis and angle. Theget
method retrieves the value of this axis-angle and places it into the arraya
of length four inx
,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) public boolean equals(Object o1)The first method returnstrue
if all of the data members of axis-anglea1
are equal to the corresponding data members in this axis-angle. The second method returns true if the Objecto1
is of type AxisAngle4f and all of the data members ofo1
are equal to the corresponding data members in this AxisAngle4f.public boolean epsilonEquals(AxisAngle4f a1, float epsilon)This method returnstrue
if the L distance between this axis-angle and axis-anglea1
is less than or equal to theepsilon
parameter. Otherwise, this method returnsfalse
. The L distance is equal to
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 (that is,equals(AxisAngle4f)
returnstrue
) will return the same hash number. Two AxisAngle4f objects with different data members may return the same hash value, although this is not likely.
A.1.13
The GVector class represents a double-precision, general, dynamically resizable, one-dimensional vector class. Index numbering begins with zero.GVector Class 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) public GVector(double vector[], int length)Each of these nine constructors returns a new GVector. The first constructor generates a generalized mathematical vector with all elements set to 0.0: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 next four constructors generate a generalized mathematical vector and copy the initial value from the tuple parametertuple
. The final method generates a generalized mathematical vector by copyinglength
elements from the array parameter. The array must contain at leastlength
elements (that is,vector.length
length
). The length of this new GVector is set to the specified length.public final void add(GVector v1) public final void add(GVector v1, GVector v2) public final void sub(GVector v1) public final void sub(GVector v1, GVector v2)The firstadd
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 firstmul
method multiplies matrixm1
times vectorv1
and places the result into this vector (this = m1 * v1). The secondmul
method multiplies the transpose of vectorv1
(that is,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 knows only about column vectors, so the result is stored as a column vector.public final void negate()This method negates the vectorthis
and places the resulting 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 v[]) public final void set(GVector v) public final void set(Tuple2f t) public final void set(Tuple3f t) public final void set(Tuple3d t) public final void set(Tuple4f t) public final void set(Tuple4d t)The firstset
method sets the values of this vector to the values found in the arrayv
: The array should at least be equal in length to the number of elements in the vector. The secondset
method sets the values of this vector to the values in vectorv
. The last 5set
methods set the value of this vector to the values in tuplet
.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()Thenorm
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 firstnormalize
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 firstscale
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
. ThescaleAdd
method scales the vectorv1
by the scale factors
, adds the result to the vectorv2
, and places the result into this vector (this = s*v1 + v2).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 (that is,equals(GVector)
returnstrue
) 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) public boolean equals(Object o1)The first method returnstrue
if all of the data members of GVectorvector1
are equal to the corresponding data members in this GVector. The second method returns true if the Objecto1
is of type GMatrix and all of the data members ofo1
are equal to the corresponding data members in this GMatrix.public boolean epsilonEquals(GVector v1, double epsilon)This method returnstrue
if the L distance between this vector and vectorv1
is less than or equal to theepsilon
parameter. Otherwise, this method returnsfalse
. The L distance is equal to
public final double dot(GVector v1)This method returns the dot product of this vector and vectorv1
.public final void SVDBackSolve(GMatrix U, GMatrix W, GMatrix V, GVector x) public final void LUDBackSolve(GMatrix LU, GVector b, GVector permutation)The first method solves for x in Ax = b, where x isthis
vector (n x 1), b is an m x 1 vector, and A is an m x n matrix, defined as A = U * W * transpose(V).U
,W
, andV
must be precomputed and can be found by taking the singular value decomposition (SVD) of A. The second method takes theLU
matrix and the permutation vector produced by the GMatrix methodLUD
and solves the equation LU * x = b by placing the solution to the set of linear equations intothis
vector (x).public final double angle(GVector v1)This method returns the (n-space) angle, in radians, between this vector and the vectorv1
parameter. The return value is constrained to the range [0, ].public final void interpolate(GVector v1, GVector v2, float alpha) public final void interpolate(GVector v1, float alpha)Deprecated methods. See the following two methods.public final void interpolate(GVector v1, GVector v2, double alpha) public final void interpolate(GVector v1, double alpha)The first method linearly interpolates between vectorsv1
andv2
and places the result into this vector (this = (1 - alpha) * v1 + alpha * v2). The second method linearly interpolates between this vector and vectorv1
and places the result into this vector (this = (1 - alpha) * this + alpha * v1).
A.2
Java 3D uses matrix objects to represent rotations and full 3D transformations. 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 transformations). These two classes in turn provide support for both single-precision floating-point representations and double-precision floating-point representations.Matrix Objects The Java 3D model for 3 x 3 transformations is
The Java 3D model for 4 x 4 transformations is
Note: When transforming a Point3f or a Point3d, the input w is set to 1. When transforming a Vector3f or Vector3d, the input w is set to 0.
A.2.1
The Matrix3f class serves to contain 3 x 3 matrices mainly for storing and manipulating 3D rotation matrices. The class includes five different constructors for creating matrices and several operators for manipulating these matrices.Matrix3f Class
Variables
The component values of a Matrix3f are directly accessible through the public variablesm00
,m01
,m02
,m10
,m11
,m12
,m20
,m21
, andm22
. To access the element in row 2 and column 0 of matrixrotate
, a programmer would writerotate.m20
. A programmer would access the other values similarly.public float m00 public float m01 public float m02 public float m10 public float m11 public float m12 public float m20 public float m21 public float m22These public variables are the elements of the matrix.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()Each of these constructors returns a new Matrix3f object. 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 arrayv
. 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 nine values set to 0.0.public final void set(Quat4d q1) public final void set(Quat4f q1)These twoset
methods set the value of the matrixthis
to the matrix conversion of the quaternion argumentq1
.public final void set(Matrix3f m1) public final void set(Matrix3d m1)Sets the value of this matrix to the value of the argument.public final void set(AxisAngle4d a1) public final void set(AxisAngle4f a1)These twoset
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 passedscale
amount. The second method sets the values of this matrix to the row-major array parameter (that is, the first three elements of the array are copied into the first row of this matrix, and so forth).public final void setElement(int row, int column, float value) public final float getElement(int row, int column)ThesetElement
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 access, but Java 3D provides these methods 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 value. 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[]) public final void getRow(int row, Vector3f v) public final void getRow(int row, float v[])The threesetRow
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
. The twogetRow
methods copy the matrix values in the specified row into the vector or array parameter, respectively.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[]) public final void getColumn(int column, Vector3f v) public final void getColumn(int column, float v[])The threesetColumn
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
. The twogetColumn
methods copy the matrix values in the specified column into the vector or array parameter, respectively.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 firstadd
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 transform(Tuple3f t) public final void transform(Tuple3f t, Tuple3f result)The first method multiplies this matrix by the tuplet
and places the result back into the tuple (t = this*t). The second method multiplies this matrix by the tuplet
and places the result into the tupleresult
(result = this*t).public final void transpose() public final void transpose(Matrix3f m1)The first method transposes this matrix in place. The second method sets the value of this matrix to the transpose of the matrixm1
.public final void invert() public final void invert(Matrix3f m1)The first method inverts this matrix in place. The second method sets the value of this matrix to the inverse of the matrixm1
.public final float determinant()Thedeterminant
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 threerot
methods construct rotation matrices that rotate in a counterclockwise (right-handed) direction around the axis specified as the last letter of the method name. The constructed matrix replaces the value of the matrixthis
. The rotation angle is expressed in radians.public final void mul(Matrix3f m1, Matrix3f m2) public final void mul(Matrix3f m1)The firstmul
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 firstmulNormalize
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 matrixm1
by matrixm2
, 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)ThemulTransposeBoth
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 firstnormalize
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 firstnormalizeCP
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) public boolean equals(Object o1)The first method returnstrue
if all of the data members of Matrix3fm1
are equal to the corresponding data members in this Matrix3f. The second method returns true if the Objecto1
is of type Matrix3f and all of the data members ofo1
are equal to the corresponding data members in this Matrix3f.public boolean epsilonEquals(Matrix3f m1, float epsilon)This method returnstrue
if the L distance between this Matrix3f and Matrix3f m1
is less than or equal to theepsilon
parameter. Otherwise, this method returnsfalse
. The L 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 in place (this = -this). The second method sets the value of this matrix equal to the negation of the matrixm1
(this = -m1).public final float getScale()This method performs an SVD normalization of this matrix to calculate and return the uniform scale factor. If the matrix has nonuniform scale factors, the largest of the x, y, and z scale factors will be returned.public final void setScale(float scale)This method sets the scale component of the current matrix by factoring out the current scale (by doing an SVD) and multiplying by the new scale.public final void add(float scalar)This method adds a scalar to each component of this matrix.public final void add(float scalar, Matrix3f m1)This method adds a scalar to each component of the matrixm1
and places the result intothis
. Matrixm1
is not modified.public final void mul(float scalar, Matrix3f m1)This method multiplies each component of the matrixm1
by a scalar and places the result intothis
. Matrixm1
is not modified.public final void mul(float scalar)This method multiplies each element of this matrix by a scalar.public final void transform(Tuple3f t) public final void transform(Tuple3f t, Tuple3f result)The first method multiplies this matrix by the tuplet
and places the result back into the tuple (t
=this
*t
). The second method multiplies this matrix by the tuplet
and places the result into the tupleresult
(result =this
*t
).public int hashCode()ThehashCode
method returns a hash number based on the data values in this object. Two different Matrix3f objects with identical data values (that is,equals(Matrix3f)
returnstrue
) will return the same hash number. Two Matrix3f objects with different data members may return the same hash value, although this is not likely.public String toString()ThetoString
method returns a string that contains the values of this Matrix3f.
A.2.2
The Matrix3d class serves to contain 3 x 3 matrices mainly for storing and manipulating 3D rotation matrices. The class includes five different constructors for creating matrices and several operators for manipulating these matrices.Matrix3d Class
Variables
The component values of a Matrix3d are directly accessible through the public variablesm00
,m01
,m02
,m10
,m11
,m12
,m20
,m21
, andm22
. To access the element in row 2 and column 0 of the matrix namedrotate
, a programmer would writerotate.m20
. Other matrix values are accessed similarly.public double m00 public double m01 public double m02 public double m10 public double m11 public double m12 public double m20 public double m21 public double m22These public variables are the elements of the matrix.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)Each of these constructors returns a new Matrix3d object. 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 arrayv
. The third constructor generates a 3 x 3 matrix with all nine values set to 0.0. The fourth and fifth constructors generate a 3 x 3 matrix with the same values as the matrixm1
parameter.public final void set(Matrix3f m1) public final void set(Matrix3d m1)These methods set the value of this matrix to the value of the argument.public final void set(double scale) public final void set(double m[])These methods set the value of the matrixthis
to a scale matrix with the passed scale amount.public final void set(AxisAngle4d a1) public final void set(AxisAngle4f a1)These twoset
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 twoset
methods set the value of the matrixthis
to the matrix conversion of the quaternion argumentq1
.public final void setElement(int row, int column, double value) public final double getElement(int row, int column)ThesetElement
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 access, but Java 3D provides these methods 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 value. 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[]) public final void getRow(int row, Vector3d v) public final void getRow(int row, double v[])The threesetRow
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
. The twogetRow
methods copy the matrix values in the specified row into the array or vector parameter, respectively.
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[]) public final void getColumn(int column, Vector3d v) public final void getColumn(int column, double v[])The threesetColumn
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
. The twogetColumn
methods copy the matrix values in the specified column into the array or vector parameter, respectively.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 firstadd
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 add(double scalar)This method adds a scalar to each component of this matrix.public final void add(double scalar, Matrix3d m1)This method adds a scalar to each component of the matrixm1
and places the result intothis
. Matrixm1
is not modified.public final void transform(Tuple3d t) public final void transform(Tuple3d t, Tuple3d result)The first method multiplies this matrix by the tuplet
and places the result back into the tuple (t = this*t). The second method multiplies this matrix by the tuplet
and places the result into the tupleresult
(result = this*t).public final void transpose() public final void transpose(Matrix3d m1)The first method transposes this matrix in place. The second method sets the value of this matrix to the transpose of the matrixm1
.public final void invert() public final void invert(Matrix3d m1)The first method inverts this matrix in place. The second method sets the value of this matrix to the inverse of the matrixm1
.public final double determinant()Thedeterminant
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 threerot
methods construct rotation matrices that rotate in a counterclockwise (right-handed) direction around the axis specified by the final letter of the method name. The constructed matrix replaces the value of the matrixthis
. The rotation angle is expressed in radians.public final void mul(Matrix3d m1, Matrix3d m2) public final void mul(Matrix3d m1)The firstmul
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 firstmulNormalize
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 matrixm1
by matrixm2
, 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)ThemulTransposeBoth
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 firstnormalize
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 firstnormalizeCP
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) public boolean equals(Object t1)The first method returnstrue
if all of the data members of Matrix3dm1
are equal to the corresponding data members in this Matrix3d. The second method returns true if the Objectt1
is of type Matrix3d and all of the data members oft1
are equal to the corresponding data members in this Matrix3d.public boolean epsilonEquals(Matrix3d m1, double epsilon)This method returnstrue
if the L distance between this Matrix3d and Matrix3dm1
is less than or equal to theepsilon
parameter. Otherwise, this method returnsfalse
. The L 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 in place (this = -this). The second method sets the value of this matrix equal to the negation of the matrixm1
(this = -m1).public final double getScale()This method performs an SVD normalization of this matrix to calculate and return the uniform scale factor. If the matrix has non-uniform scale factors, the largest of the x, y, and z scale factors will be returned.public final void setScale(double scale)This method sets the scale component of the current matrix by factoring out the current scale (by doing an SVD) and multiplying by the new scale.public final void mul(double scalar, Matrix3d m1)This method multiplies each component of the matrixm1
by a scalar and places the result intothis
. Matrixm1
is not modified.public final void mul(double scalar)This method multiplies each element of this matrix by a scalar.public final void transform(Tuple3d t) public final void transform(Tuple3d t, Tuple3d result)The first method multiplies this matrix by the tuplet
and places the result back into the tuple (t
=this
*t
). The second method multiplies this matrix by the tuplet
and places the result into the tupleresult
(result
=this
*t
).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()ThehashCode
method returns a hash number based on the data values in this object. Two different Matrix3d objects with identical data values (that is,equals(Matrix3d)
returnstrue
) will return the same hash number. Two Matrix3d objects with different data members may return the same hash value, although this is not likely.public String toString()ThetoString
method returns a string that contains the values of this Matrix3d.
A.2.3
The Matrix4f class serves to contain 4 x 4 matrices mainly for storing and manipulating 3D transformation matrices. The class includes seven different constructors for creating matrices and several operators for manipulating these matrices.Matrix4f Class
Variables
The component values of a Matrix4f are directly accessible through the public variablesm00
,m01
,m02
,m03
,m10
,m11
,m12
,m13
,m20
,m21
,m22
,m23
,m30
,m31
,m32
, andm33
. To access the element in row 2 and column 0 of matrixrotate
, a programmer would writerotate.m20
. A programmer would access the other values similarly.public float m00 public float m01 public float m02 public float m03 public float m10 public float m11 public float m12 public float m13 public float m20 public float m21 public float m22 public float m23 public float m30 public float m31 public float m32 public float m33These public variables are the elements of the matrix.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()Each of these constructors returns a new Matrix4f object. 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 arrayv
. 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 3 x 3) 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 16 values set to 0.0.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 twoset
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 twoset
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 them1
argument. The other elements of this matrix are initialized as if this were an identity matrix (that is, an 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 (that is, the first four elements of the array are copied into the first row of this matrix, and so forth).public final void set(Vector3f v1)This method sets the value of this matrix to a translation 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 matrix 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 matrixm1
, the translationt1
, and the scalescale
. 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 parameterm1
. 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 in this matrix is modified. The fourth method performs an SVD normalization of this matrix to acquire the normalized rotational component. The values are placed into the quaternionq1
. The final method retrieves the translational components of this matrix and copies them into the vectortrans
.public final void setElement(int row, int column, float value) public final float getElement(int row, int column)ThesetElement
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 access, but Java 3D provides these methods 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 value. 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 matrixm1
.public final void setScale(float scale) public final float getScale()The first method sets the scale component of the current matrix by factoring out the current scale (by doing an SVD) and multiplying by the new scale. The second method performs an SVD normalization of this matrix to calculate and return the uniform scale factor. If the matrix has nonuniform scale factors, the largest of the x, y, and z scale factors will be returned.public final void add(float scalar)This method adds a scalar to each component of this matrix.public final void add(float scalar, Matrix4f m1)This method adds a scalar to each component of the matrixm1
and places the result intothis
. Matrixm1
is not modified.public final void mul(float scalar, Matrix4f m1)This method multiplies each component of the matrixm1
by a scalar and places the result intothis
. Matrixm1
is not modified.public final void mul(float scalar)This method multiplies each element of this matrix by a scalar.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[]) public final void getRow(int row, Vector4f v) public final void getRow(int row, float v[])The threesetRow
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
. The twogetRow
methods copy the matrix values in the specified row into the array or vector parameter, respectively.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[]) public final void getColumn(int column, Vector4f v) public final void getColumn(int column, float v[])The threesetColumn
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
. The twogetColumn
methods copy the matrix values in the specified column into the array or vector parameter, respectively.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 finally 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 finally 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 finally 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 matrixm1
.public final void setTranslation(Vector3f trans)This method modifies the translational components of this matrix to the values of the vectortrans
. 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 firstadd
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 firsttranspose
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 firsttransform
method postmultiplies this matrix by the Point3fpoint
and places the result back intopoint
. The multiplication treats the three-element point as if its fourth element were 1. The secondtransform
method postmultiplies this matrix by the Point3fpoint
and places the result intopointOut
.public final void transform(Vector3f normal) public final void transform(Vector3f normal, Vector3f normalOut)The firsttransform
method postmultiplies this matrix by the Vector3fnormal
and places the result back intonormal
. The multiplication treats the three-element vector as if its fourth element were 0. The secondtransform
method postmultiplies this matrix by the Vector3fnormal
and places the result intonormalOut
.public final void transform(Tuple4f vec) public final void transform(Tuple4f vec, Tuple4f vecOut)The firsttransform
method postmultiplies this matrix by the tuplevec
and places the result back intovec
. The secondtransform
method postmultiplies this matrix by the tuplevec
and places the result intovecOut
.public final void negate() public final void negate(Matrix4f m1)The first method negates the value of this matrix in place (this = -this). The second method sets the value of this matrix equal to the negation of the matrixm1
(this = -m1).public final void invert() public final void invert(Matrix4f m1)The first method inverts this matrix in place. The second method sets the value of this matrix to the inverse of the matrixm1
.public final float determinant()Thedeterminant
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 threerot
methods construct rotation matrices that rotate in a counterclockwise (right-handed) direction around the axis specified as the last letter of the method name. The constructed matrix replaces the value of the matrixthis
. The rotation angle is expressed in radians.public final void mul(Matrix4f m1, Matrix4f m2) public final void mul(Matrix4f m1)The firstmul
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)ThemulTransposeBoth
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 boolean equals(Matrix4f m1) public boolean equals(Object t1)The first method returnstrue
if all of the data members of Matrix4fm1
are equal to the corresponding data members in this Matrix4f. The second method returns true if the Objectt1
is of type Matrix4f and all of the data members oft1
are equal to the corresponding data members in this Matrix4f.public boolean epsilonEquals(Matrix4f m1, float epsilon)This method returnstrue
if the L distance between this Matrix4f and Matrix4fm1
is less than or equal to theepsilon
parameter. Otherwise, this method returnsfalse
. The L 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()ThehashCode
method returns a hash number based on the data values in this object. Two different Matrix4f objects with identical data values (that is,equals(Matrix4f)
returnstrue
) will return the same hash number. Two Matrix4f objects with different data members may return the same hash value, although this is not likely.public String toString()ThetoString
method returns a string that contains the values of this Matrix4f.
A.2.4
The Matrix4d class serves to contain 4 x 4 matrices mainly for storing and manipulating 3D transformation matrices. The class includes nine different constructors for creating matrices and several operators for manipulating these matrices.Matrix4d Class
Variables
The component values of a Matrix4d are directly accessible through the public variablesm00
,m01
,m02
,m03
,m10
,m11
,m12
,m13
,m20
,m21
,m22
,m23
,m30
,m31
,m32
, andm33
. To access the element in row 2 and column 0 of matrixrotate
, a programmer would writerotate.m20
. A programmer would access the other values similarly.public double m00 public double m01 public double m02 public double m03 public double m10 public double m11 public double m12 public double m13 public double m20 public double m21 public double m22 public double m23 public double m30 public double m31 public double m32 public double m33These public variables are the elements of the matrix.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(Matrix3d m1, Vector3d t1, double s) public Matrix4d(Matrix3f m1, Vector3d t1, double s) public Matrix4d(Matrix4d m1) public Matrix4d(Matrix4f m1) public Matrix4d()Each of these constructors returns a new Matrix4d object. 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 arrayv
. The third through sixth constructors generate 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 16 values set to 0.0.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 is 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 setElement(int row, int column, double value) public final double getElement(int row, int column)ThesetElement
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 access, but Java 3D provides these methods 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 value. 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[]) public final void getRow(int row, Vector4d v) public final void getRow(int row, double v[])The threesetRow
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
. The twogetRow
methods copy the matrix values in the specified row into the array or vector parameter, respectively.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[]) public final void getColumn(int column, Vector4d v) public final void getColumn(int column, double v[])The threesetColumn
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
. The twogetColumn
methods copy the matrix values in the specified column into the array or vector parameter, respectively.public final void setRotation(Matrix3f 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 finally 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 finally 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 finally 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 twoget
methods retrieve the upper 3 x 3 values of this matrix and place them into the matrixm1
. The twoset
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 setScale(double scale) public final double getScale()The first method sets the scale component of the current matrix by factoring out the current scale (by doing an SVD) and multiplying by the new scale. The second method performs an SVD normalization of this matrix to calculate and return the uniform scale factor. If the matrix has nonuniform scale factors, the largest of the x, y, and z scale factors will be returned.public final void add(double scalar)This method adds a scalar to each component of this matrix.public final void add(double scalar, Matrix4d m1)This method adds a scalar to each component of the matrixm1
and places the result intothis
. Matrixm1
is not modified.public final void mul(double scalar, Matrix4d m1)This method multiplies each component of the matrixm1
by a scalar and places the result intothis
. Matrixm1
is not modified.public final void mul(double scalar)This method multiplies each element of this matrix by a scalar.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 firstadd
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 (that is, the first four elements of the array will be copied into the first row of this matrix, and so forth).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 (that is, an 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 matrixm1
.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 translation 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 to the rotation expressed by the quaternionq1
, 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 matrix 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 matrix 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(Matrix3d m1, Vector3d t1, double scale)These methods set the value of this matrix from the rotation expressed by the rotation matrixm1
, the translationt1
, and the scales
.public final void negate(Matrix4d m1) public final void negate()The first method sets the value of this matrix to the negation of them1
parameter. The second method negates the value of this matrix (this = -this).public final void transpose(Matrix4d m) public final void transpose()The firsttranspose
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 twotransform
methods postmultiply this matrix by the tuplevec
and place the result back intovec
. The last twotransform
methods postmultiply this matrix 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 twotransform
methods postmultiply this matrix by the point argumentpoint
and place the result back intopoint
. The multiplication treats the three-element point as if its fourth element were 1. The last twotransform
methods postmultiply this matrix by the point argumentpoint
and place the result 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 twotransform
methods postmultiply this matrix by the vector argumentnormal
and place the result back intonormal
. The multiplication treats the three-element vector as if its fourth element were 0. The last twotransform
methods postmultiply this matrix by the vector argumentnormal
and place the result intonormalOut
.public final void invert() public final void invert(Matrix4d m1)The first method inverts this matrix in place. The second method sets the value of this matrix to the inverse of the matrixm1
.public final double determinant()Thedeterminant
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)Therot
methods construct rotation matrices that rotate in a counterclockwise (right-handed) direction around the axis specified as the last letter of the method name. The constructed matrix replaces the value of the matrixthis
. The rotation angle is expressed in radians.public final void mul(Matrix4d m1, Matrix4d m2) public final void mul(Matrix 4d m1)The firstmul
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)ThemulTransposeBoth
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 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) public boolean equals(Object t1)The first method returnstrue
if all of the data members of Matrix4dm1
are equal to the corresponding data members in this Matrix4d. The second method returns true if the Objectt1
is of type Matrix4d and all of the data members oft1
are equal to the corresponding data members in this Matrix4d.public boolean epsilonEquals(Matrix4d m1, float epsilon)Deprecated method. See the next method.public boolean epsilonEquals(Matrix4d m1, double epsilon)This method returnstrue
if the L distance between this Matrix4d and Matrix4dm1
is less than or equal to theepsilon
parameter. Otherwise, this method returnsfalse
. The L 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()ThehashCode
method returns a hash number based on the data values in this object. Two different Matrix4d objects with identical data values (that is,equals(Matrix4d)
returnstrue
) will return the same hash number. Two Matrix4d objects with different data members may return the same hash value, although this is not likely.public String toString()ThetoString
method returns a string that contains the values of this Matrix4d.
A.2.5
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.GMatrix Class public GMatrix(int nRow, int nCol) public GMatrix(int nRow, int nCol, double matrix[]) public GMatrix(GMatrix matrix)Each of these constructors returns a new GMatrix. The first constructor generates annRow
bynCol
identity matrix. Note that because row and column numbering begins with zero,nRow
andnCol
will be one larger than the maximum possible matrix index values. 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.public final void mul(GMatrix m1, GMatrix m2) public final void mul(GMatrix m1)The firstmul
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 firstadd
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 in place (this = -this). The second method sets the value of this matrix to the negation of the matrixm1
(this = -m1).public final void invert() public final void invert(GMatrix m1)The first method inverts this matrix in place. The second method sets the value of this matrix to the inverse of the matrixm1
.public final void setIdentity()This method sets this GMatrix to the identity matrix.public final void setZero()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 intothis
(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 submatrix derived from this matrix into the target matrix. TherowSource
andcolSource
parameters define the upper left of the submatrix. ThenumRow
andnumCol
parameters define the number of rows and columns in the submatrix. The submatrix is copied into the target matrix starting at (rowDest
,colDest
). Thetarget
parameter is the matrix into which the submatrix 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 firstset
method sets the values of this matrix to the values found in thematrix
array 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 values of this matrix to the values found in matrixm1
. The last fourset
methods set the values 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 matrix into the matrixm1
. The next two methods place the values in the upper 4 x 4 of this matrix into the matrixm1
. The final method places the values in this matrix into the matrixm1
. Matrixm1
should be at least as large as this matrix.public final int getNumRow() public final int getNumCol()ThegetNumRow
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 specifiedrow
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)ThesetRow
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, and all of the values are reset.public final void mulTransposeBoth(GMatrix m1, GMatrix m2) public final void mulTransposeRight(GMatrix m1, GMatrix m2) public final void mulTransposeLeft(GMatrix m1, GMatrix m2)ThemulTransposeBoth
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 transpose() public final void transpose(GMatrix m1)The firsttranspose
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 differentGMatrix
objects with identical data values (that is,equals(GMatrix)
returnstrue
) 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) public boolean equals(Object o1)The first method returnstrue
if all of the data members of GMatrixm1
are equal to the corresponding data members in this GMatrix. The second method returns true if the Objecto1
is of type GMatrix and all of the data members ofo1
are equal to the corresponding data members in this GMatrix.public boolean epsilonEquals(GMatrix m1, float epsilon)Deprecated method. See the next method.public boolean epsilonEquals(GMatrix m1, double epsilon)This method returnstrue
if the L distance between this GMatrix and GMatrixm1
is less than or equal to theepsilon
parameter. Otherwise, this method returnsfalse
. The L 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)TheSVD
method finds the singular value decomposition (SVD) of this matrix such thatthis
= U * W * VT, and returns the rank of this matrix. The values ofU
,W
, andV
are all overwritten. Note that the matrixV
is output as V and not VT. If this matrix is m x n, then U is m x m, W is a diagonal matrix that is m x n, and V is n x n. The inverse of this matrix isthis
-1 = V * W-1 * UT, where W-1 is a diagonal matrix computed by taking the reciprocal of each of the diagonal elements of matrix W.public final int LUD(GMatrix LU, GVector permutation)TheLUD
method performs an LU decomposition. This matrix must be a square matrix, and theLU
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 or -1, depending on whether the number of row interchanges was even or odd, respectively.
The Java 3D API Specification |