HOME | PROJECTS | REALITY | EMAIL

Class ReVector3D

java.lang.Object
  |
  +--ReVector3D
Direct Known Subclasses:
GfxVector3D

public class ReVector3D
extends java.lang.Object
implements java.lang.Cloneable

Name: class ReVector3D Desc: vector math

Version:
1.000 - 1997, 1998, 2000 11.97 Visnu - implemented
1.28.98 George - added methods
2000 Gary - optimized and cleaned up
Author:
Ge (Gary) Wang (www.gewang.com), George Stetten (stetten@duke.edu), Visnu Pitiyanuvath (vtp1@duke.edu)

Constructor Summary
ReVector3D()
          constructor that creates a <0,0,0> vector.
ReVector3D(double dX, double dY)
          constructor, specifying initial x and y coordinates, z is 0.
ReVector3D(double dX, double dY, double dZ)
          constructor specifying initial x, y, and z coordinates
 
Method Summary
 void add(ReVector3D v)
          Adds another vector to this vector.
 java.lang.Object clone()
          clones the vector
 void copy(ReVector3D v)
          copy other vector into this one
 ReVector3D cross(ReVector3D v)
          Calculates the cross product of this vector and the one passed to it.
 double dot(ReVector3D v)
          Calculates the dot product of this vector and another
 boolean equals(ReVector3D v)
          Tests whether or not two vectors are identical in respect to x,y,z coordinates.
 double getOrientationAngleXY()
          Return the XY orientation in radians.
 double getX()
          retrieves the x component
 double getY()
          retrieves the y component
 double getZ()
          retrieves the z component
 double magnitude()
          Reports the magnitude of this vector
 double magnitudeSquared()
          Reports the magnitude of this vector squred
 ReVector3D minus(ReVector3D v)
          Subtracts a vector from this one and returns the result.
 void normalize()
          Normalizes vector
 ReVector3D plus(ReVector3D v)
          Adds this vector and another and returns the result.
 void rotateXY(double dRadians)
          Rotate vector
 ReVector3D scale(double dScalar)
          Multiplies this vector by a scalar and keeps the result.
 void setOrientationAngleXY(double angle)
          Sets the XY orientation.
 double setX(double dNewX)
          sets x component
 void setXY(double dNewX, double dNewY)
          sets x and y component
 void setXYZ(double dNewX, double dNewY, double dNewZ)
          sets x, y, and z component
 double setY(double dNewY)
          sets y component
 double setZ(double dNewZ)
          sets z component
 void subtract(ReVector3D v)
          Subtracts argument vector from this vector.
 ReVector3D times(double dScalar)
          Multiplies this vector by a scalar and returns the result.
 java.awt.Point toPoint()
           
 java.lang.String toString()
          Returns a string representation of the vector.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReVector3D

public ReVector3D(double dX,
                  double dY,
                  double dZ)
constructor specifying initial x, y, and z coordinates
Parameters:
dX - x coordinate
dY - y coordinate
dZ - z coordinate

ReVector3D

public ReVector3D(double dX,
                  double dY)
constructor, specifying initial x and y coordinates, z is 0.
Parameters:
dX - x coordinate
dY - y coordinate

ReVector3D

public ReVector3D()
constructor that creates a <0,0,0> vector.
Method Detail

copy

public void copy(ReVector3D v)
copy other vector into this one
Parameters:
v - a 3d vector

add

public void add(ReVector3D v)
Adds another vector to this vector.
Parameters:
v - a 3d vector

dot

public double dot(ReVector3D v)
Calculates the dot product of this vector and another
Parameters:
v - a 3d vector to dot with
Returns:
the dot product of this vector and v

cross

public ReVector3D cross(ReVector3D v)
Calculates the cross product of this vector and the one passed to it.
Parameters:
v - a 3d vector to cross with
Returns:
a vector representing the resulting cross product

getX

public final double getX()
retrieves the x component

getY

public final double getY()
retrieves the y component

getZ

public final double getZ()
retrieves the z component

setX

public double setX(double dNewX)
sets x component

setY

public double setY(double dNewY)
sets y component

setZ

public double setZ(double dNewZ)
sets z component

setXY

public void setXY(double dNewX,
                  double dNewY)
sets x and y component

setXYZ

public void setXYZ(double dNewX,
                   double dNewY,
                   double dNewZ)
sets x, y, and z component

getOrientationAngleXY

public double getOrientationAngleXY()
Return the XY orientation in radians.
Returns:
the XY orientation

setOrientationAngleXY

public void setOrientationAngleXY(double angle)
Sets the XY orientation. Leaves z component unchanged.
Parameters:
angle - orientation in radians

plus

public ReVector3D plus(ReVector3D v)
Adds this vector and another and returns the result.
Parameters:
v - a 3d vector
Returns:
a new vector representing the addition

minus

public ReVector3D minus(ReVector3D v)
Subtracts a vector from this one and returns the result.
Parameters:
v - a 3d vector
Returns:
a new vector representing the subtraction

times

public ReVector3D times(double dScalar)
Multiplies this vector by a scalar and returns the result.
Parameters:
dScalar - a scalar (double) to multiply with
Returns:
a new vector representing the multiplication

scale

public ReVector3D scale(double dScalar)
Multiplies this vector by a scalar and keeps the result. Mutator
Parameters:
dScalar - a scalar to multiply
Returns:
this vector after it's been scaled

rotateXY

public void rotateXY(double dRadians)
Rotate vector

normalize

public void normalize()
Normalizes vector

magnitude

public double magnitude()
Reports the magnitude of this vector
Returns:
the magnitude of the vector

magnitudeSquared

public double magnitudeSquared()
Reports the magnitude of this vector squred
Returns:
the magnitude of the vector, squared

equals

public boolean equals(ReVector3D v)
Tests whether or not two vectors are identical in respect to x,y,z coordinates.
Parameters:
v - another ReVector3D
Returns:
whether or not this vector is equal to the other

subtract

public void subtract(ReVector3D v)
Subtracts argument vector from this vector.
Parameters:
v - a 3d vector

toString

public java.lang.String toString()
Returns a string representation of the vector. Overrides the toString method in the base Object class.
Returns:
a string representation of the vector
Overrides:
toString in class java.lang.Object

clone

public java.lang.Object clone()
clones the vector
Returns:
a new instance

toPoint

public java.awt.Point toPoint()


HOME | PROJECTS | REALITY | EMAIL