edu.umd.cfar.lamp.viper.geometry
Class Component

java.lang.Object
  extended byedu.umd.cfar.lamp.viper.geometry.Component
Direct Known Subclasses:
Pnt

public class Component
extends java.lang.Object

Represents a homogonous vector. Represented as Rationals.


Field Summary
 Rational t
          The homogonizing scalar.
 Rational x
          The first scalar in the vector, representing the x dimension.
 Rational y
          The second scalar in the vector, representing the y dimension.
 
Constructor Summary
Component()
          Constructs a new Component.
Component(Component C)
          Constructs a new Component from the given Component.
Component(int X, int Y, int T)
          Constructs a new Component with the given coordinates.
Component(Rational X, Rational Y, Rational T)
          Constructs a new Component with the given coordinates in Rationals.
 
Method Summary
static Rational dot(Component a, Component b)
          Returns the dot product of the two input vectors.
 boolean equals(java.lang.Object o)
          Tests the equality of this with another Component.
 int hashCode()
          Generates a hash code for this object.
 double length()
          Determine the length of the Component as a double.
 Component minus(Component C)
          Subtract another Component from this Component.
 Component plus(Component C)
          Add another Component to this.
 Component set(Component C)
          Sets this component to the given value.
 java.lang.String toString()
          Get a String representing this component.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

x

public Rational x
The first scalar in the vector, representing the x dimension.


y

public Rational y
The second scalar in the vector, representing the y dimension.


t

public Rational t
The homogonizing scalar.

Constructor Detail

Component

public Component()
Constructs a new Component.


Component

public Component(Rational X,
                 Rational Y,
                 Rational T)
Constructs a new Component with the given coordinates in Rationals.

Parameters:
X - The x coordinate.
Y - The y coordinate.
T - The homogonous coordinate.

Component

public Component(int X,
                 int Y,
                 int T)
Constructs a new Component with the given coordinates.

Parameters:
X - The x coordinate.
Y - The y coordinate.
T - The homogonous coordinate.

Component

public Component(Component C)
Constructs a new Component from the given Component. Acts as a copy constructor.

Parameters:
C - The Component to copy.
Method Detail

set

public Component set(Component C)
Sets this component to the given value.

Parameters:
C - The value to set this to.
Returns:
A reference to this Rational.

equals

public boolean equals(java.lang.Object o)
Tests the equality of this with another Component.

Parameters:
o - The object to test against this Component.
Returns:
true if these are equal.

hashCode

public int hashCode()
Generates a hash code for this object.

Returns:
A hash code for use in HashMaps and so on.

dot

public static Rational dot(Component a,
                           Component b)
Returns the dot product of the two input vectors. A dot product is:
    a.x * b.x + a.y * b.y
 

Parameters:
a - A Component to do some math on.
b - A component to do some math on.
Returns:
The dot product of the components.

minus

public Component minus(Component C)
Subtract another Component from this Component.

Parameters:
C - A Component to subtract from this.
Returns:
The result of the subtraction.

plus

public Component plus(Component C)
Add another Component to this.

Parameters:
C - The Component to add to this.
Returns:
The sum of the two.
Throws:
java.lang.ArithmeticException - if you try to add two points or something.

length

public double length()
Determine the length of the Component as a double.

Returns:
The length of the vector or the distance from origin.

toString

public java.lang.String toString()
Get a String representing this component. It doean't display T.

Returns:
(x, y)