Class com.oroinc.math.geometry.Tuple
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.oroinc.math.geometry.Tuple

java.lang.Object
   |
   +----com.oroinc.math.geometry.Tuple

public class Tuple
extends Object
implements Cloneable
A base class for representing points and vectors in homogeneous coordinates. Only tuples with dimensions between 1 and 4 are supported.

Copyright © 1996, 1997 Original Reusable Objects, Inc. All rights reserved.

Author:
Daniel F. Savarese

Variable Index

 o _dimension_
 o _elements_

Constructor Index

 o Tuple(float, float)
Creates a two dimensional Tuple with the given coordinates.
 o Tuple(float, float, float)
Creates a three dimensional Tuple with the given coordinates.
 o Tuple(int)
Creates a Tuple of a given dimension and initizlies all of its coordinates to 0.
 o Tuple(Tuple)
The Tuple copy constructor.

Method Index

 o _assign_(Tuple)
This is the assignment operator for Tuples.
 o add(Tuple, Tuple)
Add two tuples and return the result.
 o addTo(Tuple)
This method is the equivalent of the += operator.
 o clone()
Returns a deep copy of the Tuple.
 o dimension()
Returns the dimension of the Tuple.
 o divide(float)
This method divides the Tuple by a scalar and returns a new Tuple containing the result.
 o divideBy(float)
This method is the equivalent of the /= operator.
 o element(int)
Serves the function of a read only [] operator.
 o inverse()
This method is the equivalent of the unary - operator.
 o multiply(float)
This method multiplies the Tuple by a scalar and returns a new Tuple containing the result.
 o multiply(SquareMatrix)
This method multiplies the Tuple by a SquareMatrix and returns a new Tuple containing the result.
 o multiplyBy(float)
This method is the equivalent of the *= operator.
 o multiplyBy(SquareMatrix)
This method is the equivalent of the *= operator.
 o setDimension(int)
Sets the dimension of the tuple.
 o setElement(int, float)
Assigns a value to the Tuple element at the indicated index..
 o subtract(Tuple, Tuple)
Subtract two tuples and return the result.
 o subtractFrom(Tuple)
This method is the equivalent of the -= operator.
 o toString()
Returns a string representation of the tuple including the homogeneous coordinate.
 o zero()
Zeroes the elements of the tuple, preserving homogeneous coordinates.

Variables

 o _elements_
  protected float _elements_[]
 o _dimension_
  protected int _dimension_

Constructors

 o Tuple
  public Tuple(Tuple tuple)
The Tuple copy constructor. Creates a new Tuple instance that is a deep copy of the argument.

Parameters:
tuple - The Tuple used to initialize the new Tuple.
 o Tuple
  public Tuple(int dimension)
Creates a Tuple of a given dimension and initizlies all of its coordinates to 0. Only dimensions 1 to 4 are supported and no check is made to ensure a valid argument was passed. It is the programmer's responsibility to use valid arguments.

Parameters:
dimension - The dimension of the new Tuple.
 o Tuple
  public Tuple(float x,
               float y)
Creates a two dimensional Tuple with the given coordinates.

Parameters:
x - The first Tuple value.
y - The second Tuple value.
 o Tuple
  public Tuple(float x,
               float y,
               float z)
Creates a three dimensional Tuple with the given coordinates.

Parameters:
x - The first Tuple value.
y - The second Tuple value.
z - The third Tuple value.

Methods

 o add
  public final static Tuple add(Tuple tuple1,
                                Tuple tuple2)
Add two tuples and return the result.

Parameters:
tuple1 - The first addition operand.
tuple2 - The second addition operand.
Returns:
A new Tuple instance containing the sum of the two operands.
 o subtract
  public final static Tuple subtract(Tuple tuple1,
                                     Tuple tuple2)
Subtract two tuples and return the result.

Parameters:
tuple1 - The first addition operand.
tuple2 - The second addition operand.
Returns:
A new Tuple instance containing tuple1 - tuple2.
 o _assign_
  protected final void _assign_(Tuple tuple)
This is the assignment operator for Tuples. Assigns the value of the argument to the calling Tuple. It is the responsibility of the programmer to never assign a vector to a point or a point to a vector.

Parameters:
tuple - The value to assign to the Tuple.
 o clone
  public Object clone()
Returns a deep copy of the Tuple. Essentially just returns
new Tuple(this);
Tuple implements the Cloneable interface principally as a convenience.

Returns:
A deep copy of the Tuple.
Overrides:
clone in class Object
 o dimension
  public final int dimension()
Returns the dimension of the Tuple.

Returns:
The dimensions of the Tuple.
 o element
  public final float element(int index)
Serves the function of a read only [] operator. Returns the value of the appropriate Tuple element. No boundary checking is done, so the programmer must be sure to use a valid index.

Parameters:
The - index of the element to return.
Returns:
The element at the specified index of the Tuple.
 o setElement
  public void setElement(int index,
                         float scalar)
Assigns a value to the Tuple element at the indicated index..

Parameters:
index - The index of the element to change.
scalar - The new value to assign.
 o setDimension
  public void setDimension(int dimension)
Sets the dimension of the tuple. Only dimensions 1 to 4 are supported and no check is made to ensure a valid argument was passed. It is the programmer's responsibility to use valid arguments.

Parameters:
dimension - The dimension of the new Tuple.
 o zero
  public final void zero()
Zeroes the elements of the tuple, preserving homogeneous coordinates. In other words, if the object is a vector it becomes the zero vector, and if it is a point, it becomes the origin of the Cartesian coordinate system.
 o addTo
  public final void addTo(Tuple tuple)
This method is the equivalent of the += operator. It adds the argument to the calling Tuple.

Parameters:
tuple - The value to add to the Tuple.
 o subtractFrom
  public final void subtractFrom(Tuple tuple)
This method is the equivalent of the -= operator. It subtracts the argument from the calling Tuple.

Parameters:
tuple - The value to subtract from the Tuple.
 o multiplyBy
  public final void multiplyBy(float scalar)
This method is the equivalent of the *= operator. It multiplies the Tuple by the argument.

Parameters:
scalar - The value by which to multiply the Tuple.
 o multiplyBy
  public final void multiplyBy(SquareMatrix matrix)
This method is the equivalent of the *= operator. It multiplies the Tuple by the argument, a SquareMatrix.

Parameters:
matrix - The value by which to multiply the Tuple.
 o divideBy
  public final void divideBy(float scalar)
This method is the equivalent of the /= operator. It divides the Tuple by the argument.

Parameters:
scalar - The value by which to divide the Tuple.
 o multiply
  public final Tuple multiply(float scalar)
This method multiplies the Tuple by a scalar and returns a new Tuple containing the result.

Parameters:
scalar - The value by which to multiply the Tuple.
Returns:
The product of the Tuple and the scalar.
 o multiply
  public final Tuple multiply(SquareMatrix matrix)
This method multiplies the Tuple by a SquareMatrix and returns a new Tuple containing the result.

Parameters:
matrix - The value by which to multiply the Tuple.
Returns:
The product of the Tuple and the SquareMatrix.
 o divide
  public final Tuple divide(float scalar)
This method divides the Tuple by a scalar and returns a new Tuple containing the result.

Parameters:
scalar - The value by which to divide the Tuple.
Returns:
The result of the division of the Tuple by the scalar.
 o inverse
  public final Tuple inverse()
This method is the equivalent of the unary - operator. It returns the inverse (i.e., -1 times the argument) of the Tuple.

Returns:
The new Tuple equal to the inverse of the caller.
 o toString
  public final String toString()
Returns a string representation of the tuple including the homogeneous coordinate.

Returns:
A string representation of the tuple.
Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index