mfc.vector
Class Real3

java.lang.Object
  extended bymfc.vector.Real3
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class Real3
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

This class represents a real 3-vector (x, y, z).

All methods avoid the creation of temporarily used objects in their internal computations unless stated in their descriptions.

See Also:
Serialized Form

Field Summary
static double EPSILON
          Threashold for zero tests.
 double x
          The x-component.
 double y
          The y-component.
 double z
          The zcomponent.
 
Constructor Summary
Real3()
          Create the zero vector.
Real3(double theX, double theY, double theZ)
          Create a vector with given entries.
Real3(Real3 v)
          Create a copy of the given vector.
 
Method Summary
 void assign(double newX, double newY, double newZ)
          Assign this with the given entries.
 void assign(Real3 v)
          Assign this this with the given vector.
 void assignCrossProduct(Real3 v, Real3 w)
          Assign this with cross product of two vectors.
 void assignDivide(double a)
          Divide by a scalar.
 void assignLinearCombination(double a, Real3 v, double b, Real3 w)
          Assign this with a linear combination of two vectors.
 void assignMinus(Real3 v)
          Subtract a vector.
 void assignPlus(Real3 v)
          Add a vector.
 void assignTimes(double a)
          Multiply by a scalar.
 void assignZero()
          Assign this with zero.
 Real3 copy()
          Create a copy of this and return it.
static double dotProduct(Real3 v, Real3 w)
          Return dot product of two vectors.
 double getX()
          Get the value of x.
 double getY()
          Get the value of y.
 double getZ()
          Get the value of z.
 double norm()
          Return the length of this.
 void normalize()
          Normalize this.
 double normSquared()
          Return the square length of this.
 void projectTo(ComplexProjective1 cp)
          Project a point on the unit sphere stereographically from the north pole to complex projective space.
 void setX(double v)
          Set the value of x.
 void setY(double v)
          Set the value of y.
 void setZ(double v)
          Set the value of z.
 java.lang.String toString()
          Return a String representation of this.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EPSILON

public static final double EPSILON
Threashold for zero tests. Default is 1.0e-14.

See Also:
Constant Field Values

x

public double x
The x-component.


y

public double y
The y-component.


z

public double z
The zcomponent.

Constructor Detail

Real3

public Real3()
Create the zero vector.


Real3

public Real3(double theX,
             double theY,
             double theZ)
Create a vector with given entries.


Real3

public Real3(Real3 v)
Create a copy of the given vector.

Method Detail

getX

public double getX()
Get the value of x.

Returns:
value of x

setX

public void setX(double v)
Set the value of x.

Parameters:
v - value to assign to x

getY

public double getY()
Get the value of y.

Returns:
value of y

setY

public void setY(double v)
Set the value of y.

Parameters:
v - value to assign to y

getZ

public double getZ()
Get the value of z.

Returns:
value of z

setZ

public void setZ(double v)
Set the value of z.

Parameters:
v - value to assign to z

copy

public Real3 copy()
Create a copy of this and return it.

Returns:
a copy of this

assignZero

public void assignZero()
Assign this with zero.


assign

public void assign(double newX,
                   double newY,
                   double newZ)
Assign this with the given entries.


assign

public void assign(Real3 v)
Assign this this with the given vector.


assignPlus

public void assignPlus(Real3 v)
Add a vector.

Parameters:
v - the vector to add

assignMinus

public void assignMinus(Real3 v)
Subtract a vector.

Parameters:
v - the vector to subtract

assignTimes

public void assignTimes(double a)
Multiply by a scalar.

Parameters:
a - the scalar

assignDivide

public void assignDivide(double a)
Divide by a scalar.

Parameters:
a - the scalar

assignLinearCombination

public void assignLinearCombination(double a,
                                    Real3 v,
                                    double b,
                                    Real3 w)
Assign this with a linear combination of two vectors.

Parameters:
a - a double, the factor of v
v - a Real3
b - a double, the factor of w
w - a Real3

assignCrossProduct

public void assignCrossProduct(Real3 v,
                               Real3 w)
Assign this with cross product of two vectors.

Parameters:
v - first factor in cross product.
w - second factor in cross product.

dotProduct

public static final double dotProduct(Real3 v,
                                      Real3 w)
Return dot product of two vectors.

Parameters:
v - a Real3
w - a Real3
Returns:
v.x * w.x + v.y * w.y + v.z * w.z

normSquared

public double normSquared()
Return the square length of this.

Returns:
dotProduct(this, this)
See Also:
norm(), normalize()

norm

public double norm()
Return the length of this.

Returns:
&sqrt;(x * x + y * y + z * z)
See Also:
normSquared(), normalize()

normalize

public void normalize()

Normalize this.

Divide this by norm().

See Also:
normSquared(), norm(), normalize()

projectTo

public void projectTo(ComplexProjective1 cp)
               throws java.lang.IllegalArgumentException

Project a point on the unit sphere stereographically from the north pole to complex projective space.

(0, 0, 1) is projected to the point with homogeneous coordinates (1, 0).
(0, 0, -1) is projected to the point with homogenous coordinates (0, 1).

Parameters:
cp - the ComplexProjective1 used to hand over the result. Must not be null.
Throws:
java.lang.IllegalArgumentException - if normSquared() differs from 1.0 by more than EPSILON

toString

public java.lang.String toString()
Return a String representation of this.

Returns:
a String representation of this