Package javax.vecmath
Class Tuple2d
- java.lang.Object
-
- javax.vecmath.Tuple2d
-
- All Implemented Interfaces:
java.io.Serializable
public abstract class Tuple2d extends java.lang.Object implements java.io.Serializable
A generic 2 element tuple that is represented by double precision floating point x,y coordinates.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Tuple2d()
Constructs and initializes a Tuple2d to (0,0).Tuple2d(double[] t)
Constructs and initializes a Tuple2d from the specified array.Tuple2d(double x, double y)
Constructs and initializes a Tuple2d from the specified xy coordinates.Tuple2d(Tuple2d t1)
Constructs and initializes a Tuple2d from the specified Tuple2d.Tuple2d(Tuple2f t1)
Constructs and initializes a Tuple2d from the specified Tuple2f.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
absolute()
Sets each component of this tuple to its absolute value.void
absolute(Tuple2d t)
Sets each component of the tuple parameter to its absolute value and places the modified values into this tuple.void
add(Tuple2d t1)
Sets the value of this tuple to the vector sum of itself and tuple t1.void
add(Tuple2d t1, Tuple2d t2)
Sets the value of this tuple to the vector sum of tuples t1 and t2.void
clamp(double min, double max)
Clamps this tuple to the range [low, high].void
clamp(double min, double max, Tuple2d t)
Clamps the tuple parameter to the range [low, high] and places the values into this tuple.void
clampMax(double max)
Clamps the maximum value of this tuple to the max parameter.void
clampMax(double max, Tuple2d t)
Clamps the maximum value of the tuple parameter to the max parameter and places the values into this tuple.void
clampMin(double min)
Clamps the minimum value of this tuple to the min parameter.void
clampMin(double min, Tuple2d t)
Clamps the minimum value of the tuple parameter to the min parameter and places the values into this tuple.boolean
epsilonEquals(Tuple2d t1, double epsilon)
Returns true if the L-infinite distance between this tuple and tuple t1 is less than or equal to the epsilon parameter, otherwise returns false.boolean
equals(java.lang.Object o1)
Returns true if the Object o1 is of type Tuple2d and all of the data members of t1 are equal to the corresponding data members in this Tuple2d.boolean
equals(Tuple2d t1)
Returns true if all of the data members of Tuple2d t1 are equal to the corresponding data members in thisvoid
get(double[] t)
Copies the value of the elements of this tuple into the array t[].int
hashCode()
Returns a hash number based on the data values in this object.void
interpolate(Tuple2d t1, double alpha)
Linearly interpolates between this tuple and tuple t1 and places the result into this tuple: this = (1-alpha)*this + alpha*t1.void
interpolate(Tuple2d t1, Tuple2d t2, double alpha)
Linearly interpolates between tuples t1 and t2 and places the result into this tuple: this = (1-alpha)*t1 + alpha*t2.void
negate()
Negates the value of this vector in place.void
negate(Tuple2d t1)
Sets the value of this tuple to the negation of tuple t1.void
scale(double s)
Sets the value of this tuple to the scalar multiplication of itself.void
scale(double s, Tuple2d t1)
Sets the value of this tuple to the scalar multiplication of tuple t1.void
scaleAdd(double s, Tuple2d t1)
Sets the value of this tuple to the scalar multiplication of itself and then adds tuple t1 (this = s*this + t1).void
scaleAdd(double s, Tuple2d t1, Tuple2d t2)
Sets the value of this tuple to the scalar multiplication of tuple t1 and then adds tuple t2 (this = s*t1 + t2).void
set(double[] t)
Sets the value of this tuple from the 2 values specified in the array.void
set(double x, double y)
Sets the value of this tuple to the specified xy coordinates.void
set(Tuple2d t1)
Sets the value of this tuple to the value of the Tuple2d argument.void
set(Tuple2f t1)
Sets the value of this tuple to the value of the Tuple2f argument.void
sub(Tuple2d t1)
Sets the value of this tuple to the vector difference of itself and tuple t1 (this = this - t1).void
sub(Tuple2d t1, Tuple2d t2)
Sets the value of this tuple to the vector difference of tuple t1 and t2 (this = t1 - t2).java.lang.String
toString()
Returns a string that contains the values of this Tuple2d.
-
-
-
Constructor Detail
-
Tuple2d
public Tuple2d(double x, double y)
Constructs and initializes a Tuple2d from the specified xy coordinates.- Parameters:
x
- the x coordinatey
- the y coordinate
-
Tuple2d
public Tuple2d(double[] t)
Constructs and initializes a Tuple2d from the specified array.- Parameters:
t
- the array of length 2 containing xy in order
-
Tuple2d
public Tuple2d(Tuple2d t1)
Constructs and initializes a Tuple2d from the specified Tuple2d.- Parameters:
t1
- the Tuple2d containing the initialization x y data
-
Tuple2d
public Tuple2d(Tuple2f t1)
Constructs and initializes a Tuple2d from the specified Tuple2f.- Parameters:
t1
- the Tuple2d containing the initialization x y data
-
Tuple2d
public Tuple2d()
Constructs and initializes a Tuple2d to (0,0).
-
-
Method Detail
-
set
public final void set(double x, double y)
Sets the value of this tuple to the specified xy coordinates.- Parameters:
x
- the x coordinatey
- the y coordinate
-
set
public final void set(double[] t)
Sets the value of this tuple from the 2 values specified in the array.- Parameters:
t
- the array of length 2 containing xy in order
-
set
public final void set(Tuple2d t1)
Sets the value of this tuple to the value of the Tuple2d argument.- Parameters:
t1
- the tuple to be copied
-
set
public final void set(Tuple2f t1)
Sets the value of this tuple to the value of the Tuple2f argument.- Parameters:
t1
- the tuple to be copied
-
get
public final void get(double[] t)
Copies the value of the elements of this tuple into the array t[].- Parameters:
t
- the array that will contain the values of the vector
-
add
public final void add(Tuple2d t1, Tuple2d t2)
Sets the value of this tuple to the vector sum of tuples t1 and t2.- Parameters:
t1
- the first tuplet2
- the second tuple
-
add
public final void add(Tuple2d t1)
Sets the value of this tuple to the vector sum of itself and tuple t1.- Parameters:
t1
- the other tuple
-
sub
public final void sub(Tuple2d t1, Tuple2d t2)
Sets the value of this tuple to the vector difference of tuple t1 and t2 (this = t1 - t2).- Parameters:
t1
- the first tuplet2
- the second tuple
-
sub
public final void sub(Tuple2d t1)
Sets the value of this tuple to the vector difference of itself and tuple t1 (this = this - t1).- Parameters:
t1
- the other tuple
-
negate
public final void negate(Tuple2d t1)
Sets the value of this tuple to the negation of tuple t1.- Parameters:
t1
- the source vector
-
negate
public final void negate()
Negates the value of this vector in place.
-
scale
public final void scale(double s, Tuple2d t1)
Sets the value of this tuple to the scalar multiplication of tuple t1.- Parameters:
s
- the scalar valuet1
- the source tuple
-
scale
public final void scale(double s)
Sets the value of this tuple to the scalar multiplication of itself.- Parameters:
s
- the scalar value
-
scaleAdd
public final void scaleAdd(double s, Tuple2d t1, Tuple2d t2)
Sets the value of this tuple to the scalar multiplication of tuple t1 and then adds tuple t2 (this = s*t1 + t2).- Parameters:
s
- the scalar valuet1
- the tuple to be multipledt2
- the tuple to be added
-
scaleAdd
public final void scaleAdd(double s, Tuple2d t1)
Sets the value of this tuple to the scalar multiplication of itself and then adds tuple t1 (this = s*this + t1).- Parameters:
s
- the scalar valuet1
- the tuple to be added
-
hashCode
public int hashCode()
Returns a hash number based on the data values in this object. Two different Tuple2d objects with identical data values (ie, returns true for equals(Tuple2d) ) will return the same hash number. Two vectors with different data members may return the same hash value, although this is not likely.- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(Tuple2d t1)
Returns true if all of the data members of Tuple2d t1 are equal to the corresponding data members in this- Parameters:
t1
- the vector with which the comparison is made.
-
equals
public boolean equals(java.lang.Object o1)
Returns true if the Object o1 is of type Tuple2d and all of the data members of t1 are equal to the corresponding data members in this Tuple2d.- Overrides:
equals
in classjava.lang.Object
- Parameters:
o1
- the object with which the comparison is made.
-
epsilonEquals
public boolean epsilonEquals(Tuple2d t1, double epsilon)
Returns true if the L-infinite distance between this tuple and tuple t1 is less than or equal to the epsilon parameter, otherwise returns false. The L-infinite distance is equal to MAX[abs(x1-x2), abs(y1-y2)].- Parameters:
t1
- the tuple to be compared to this tupleepsilon
- the threshold value
-
toString
public java.lang.String toString()
Returns a string that contains the values of this Tuple2d. The form is (x,y).- Overrides:
toString
in classjava.lang.Object
- Returns:
- the String representation
-
clamp
public final void clamp(double min, double max, Tuple2d t)
Clamps the tuple parameter to the range [low, high] and places the values into this tuple.- Parameters:
min
- the lowest value in the tuple after clampingmax
- the highest value in the tuple after clampingt
- the source tuple, which will not be modified
-
clampMin
public final void clampMin(double min, Tuple2d t)
Clamps the minimum value of the tuple parameter to the min parameter and places the values into this tuple.- Parameters:
min
- the lowest value in the tuple after clampingt
- the source tuple, which will not be modified
-
clampMax
public final void clampMax(double max, Tuple2d t)
Clamps the maximum value of the tuple parameter to the max parameter and places the values into this tuple.- Parameters:
max
- the highest value in the tuple after clampingt
- the source tuple, which will not be modified
-
absolute
public final void absolute(Tuple2d t)
Sets each component of the tuple parameter to its absolute value and places the modified values into this tuple.- Parameters:
t
- the source tuple, which will not be modified
-
clamp
public final void clamp(double min, double max)
Clamps this tuple to the range [low, high].- Parameters:
min
- the lowest value in this tuple after clampingmax
- the highest value in this tuple after clamping
-
clampMin
public final void clampMin(double min)
Clamps the minimum value of this tuple to the min parameter.- Parameters:
min
- the lowest value in this tuple after clamping
-
clampMax
public final void clampMax(double max)
Clamps the maximum value of this tuple to the max parameter.- Parameters:
max
- the highest value in the tuple after clamping
-
absolute
public final void absolute()
Sets each component of this tuple to its absolute value.
-
interpolate
public final void interpolate(Tuple2d t1, Tuple2d t2, double alpha)
Linearly interpolates between tuples t1 and t2 and places the result into this tuple: this = (1-alpha)*t1 + alpha*t2.- Parameters:
t1
- the first tuplet2
- the second tuplealpha
- the alpha interpolation parameter
-
interpolate
public final void interpolate(Tuple2d t1, double alpha)
Linearly interpolates between this tuple and tuple t1 and places the result into this tuple: this = (1-alpha)*this + alpha*t1.- Parameters:
t1
- the first tuplealpha
- the alpha interpolation parameter
-
-