fi.utu.cs.physics
Class Tuple2

java.lang.Object
  |
  +--fi.utu.cs.physics.Tuple2
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
Point2, Vector2

public abstract class Tuple2
extends java.lang.Object
implements java.lang.Cloneable

A two-element tuple of double-precision floating point values.


Constructor Summary
protected Tuple2(double v1, double v2)
          Creates a new two-element tuple with the given values.
 
Method Summary
protected  void add(double v1, double v2)
          Adds values to the elements.
protected  void add(Tuple2 other)
          Adds the values of other to the elements.
 java.lang.Object clone()
          Creates and returns a copy of this tuple.
 boolean equals(java.lang.Object o)
          Returns true if o is of the type Tuple2 and the elements of o are equal to the corresponding elements in this tuple.
protected  double getFirstElement()
          Returns the first element.
protected  double getSecondElement()
          Returns the second element.
 int hashCode()
          Returns a hash code value based on the elements of this tuple.
 double max()
          Returns the maximum of the elements.
protected  double min()
          Returns the minimum of the elements.
protected  void negate()
          Negates the elements.
protected  void negateFirstElement()
          Negates the first element.
protected  void negateSecondElement()
          Negates the second element.
protected  void set(double v1, double v2)
          Sets the elements.
protected  void set(Tuple2 other)
          Sets the elements to the same values as in other.
protected  void setFirstElement(double v)
          Sets the first element to the value v.
protected  void setSecondElement(double v)
          Sets the second element to the value v.
protected  void swap()
          Swaps the elements.
 java.lang.String toString()
          Returns a string that contains the values of the elements.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Tuple2

protected Tuple2(double v1,
                 double v2)
Creates a new two-element tuple with the given values.
Method Detail

getFirstElement

protected double getFirstElement()
Returns the first element.

getSecondElement

protected double getSecondElement()
Returns the second element.

setFirstElement

protected void setFirstElement(double v)
Sets the first element to the value v.

setSecondElement

protected void setSecondElement(double v)
Sets the second element to the value v.

set

protected void set(double v1,
                   double v2)
Sets the elements.
Parameters:
v1 - The value of the first element.
v2 - The value of the second element.
See Also:
set(Tuple2)

set

protected void set(Tuple2 other)
Sets the elements to the same values as in other.

add

protected void add(double v1,
                   double v2)
Adds values to the elements.
Parameters:
v1 - The value added to the first element.
v2 - The value added to the second element.
See Also:
add(Tuple2)

add

protected void add(Tuple2 other)
Adds the values of other to the elements.

negate

protected void negate()
Negates the elements.

negateFirstElement

protected void negateFirstElement()
Negates the first element.

negateSecondElement

protected void negateSecondElement()
Negates the second element.

swap

protected void swap()
Swaps the elements.

min

protected double min()
Returns the minimum of the elements.

max

public double max()
Returns the maximum of the elements.

equals

public boolean equals(java.lang.Object o)
Returns true if o is of the type Tuple2 and the elements of o are equal to the corresponding elements in this tuple.
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Returns a hash code value based on the elements of this tuple.
Overrides:
hashCode in class java.lang.Object

clone

public java.lang.Object clone()
Creates and returns a copy of this tuple.
Overrides:
clone in class java.lang.Object

toString

public java.lang.String toString()
Returns a string that contains the values of the elements.
Overrides:
toString in class java.lang.Object