JavaGrinders.spatial
Class SpatialVector

java.lang.Object
  extended by JavaGrinders.spatial.SpatialVector
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
Capture, PolarVector

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

provides the interface for obtaining descriptive statistics from continuous variables.


Constructor Summary
SpatialVector()
          empty constructor
SpatialVector(double x, double y)
          Standard constructor for the 2D SpatialVector class with x and y coordinates provided
SpatialVector(double x, double y, double z)
          constructor specifying initial x, y, and z coordinates
SpatialVector(java.awt.geom.Point2D.Double aPoint)
          Standard constructor for the 2D SpatialVector class with x and y coordinates provided
 
Method Summary
 SpatialVector applyVector(PolarVector aVector)
          Returns the coordinates of the Location after a Move has been applied to it
 SpatialVector applyVector(SpatialVector aVector)
          Returns the coordinates of the Location after a Move has been applied to it
 java.lang.Object clone()
          clone the object
 void copy(SpatialVector v)
          copy other vector into this one
 SpatialVector cross(SpatialVector v)
          Calculates the cross product of this vector and the one passed to it.
 double dot(SpatialVector v)
          Calculates the dot product of this vector and another
 boolean equals(SpatialVector v)
          Tests whether or not two vectors are identical in respect to x,y,z coordinates.
 boolean getConnect()
          sets whether the move should be visually connected
 double getEuclidianDistance(SpatialVector theOtherLocation)
          Returns the straight-line distance between two points
 double getLat()
          Return the latitudinal heading in radians.
 double getLatDeg()
          Return the latitudinal heading in degrees.
 double getLength()
          Reports the magnitude of this vector
 double getLengthSquared()
          Reports the magnitude of this vector squared
 double getLong()
          Return the longitudinal heading in radians.
 double getLongDeg()
          Return the longitudinal heading in degrees.
 double getManhattanDistance(SpatialVector theOtherLocation)
          Returns the straight-line distance between two points
 double getManhattanLength()
          Reports the magnitude of this vector
 PolarVector getPolarVector(SpatialVector theOtherLocation)
          Returns the angle in degrees to another point.
 java.awt.Point getScaledPoint(GridSpace3D visualSpace)
          Scales a single location to a frame's x and y scale values
 SpatialVector getSpatialVector(SpatialVector theOtherLocation)
          Returns the angle in degrees to another point.
 double getSquaredEuclidianDistance(SpatialVector theOtherLocation)
          Returns the straight-line distance between two points
 double getX()
          retrieves the x component
 java.awt.geom.Point2D.Double getXY()
          Scales a single location to a frame's x and y scale values
 double getY()
          retrieves the y component
 double getZ()
          retrieves the z component
 SpatialVector minus(SpatialVector v)
          Subtracts a vector from this one and returns the result.
 void negate()
          negate the SpatialVector
 void negateX()
          negate the x axis of the SpatialVector
 void negateY()
          negate the y axis of the SpatialVector
 void negateZ()
          negate the z axis of the SpatialVector
 SpatialVector plus(SpatialVector v)
          Adds another vector to this vector.
 void remapLatLongToDistanceCoords(SpatialVector theOrigin)
          returns a latitude/longitude Capture remapped into a real distance
 SpatialVector rotate(double xyAngle, double xzAngle)
          Rotate vector in XYZ
 SpatialVector rotate(SpatialVector aVector)
          Rotate vector in XYZ
 SpatialVector rotateXY(double r)
          Rotate vector in XY
 SpatialVector rotateXZ(double r)
          Rotate vector in XY
 SpatialVector scale(double dScalar)
          Multiplies this vector by a scalar and keeps the result.
 void setConnect(boolean con)
          Returns whether the move should be visually connected
 SpatialVector setLength(double newLength)
          Scales the vector to a particular length
 double setX(double dNewX)
          sets x component
 double setY(double dNewY)
          sets y component
 double setZ(double dNewZ)
          sets z component
 void subtract(SpatialVector v)
          Subtracts argument vector from this vector.
 SpatialVector times(double dScalar)
          Multiplies this vector by a scalar and returns the result.
 java.awt.Point toPoint()
          returns the vector as a point
 PolarVector toPolarVector()
          returns the vector as vector defined by measures of longitude, latitude, length
 SpatialVector toSpatialVector()
          returns the vector as vector defined by measures of longitude, latitude, length
 java.lang.String toString()
          Returns a string representation of the vector.
 void unitLength()
          Normalizes vector to unit length
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SpatialVector

public SpatialVector(double x,
                     double y,
                     double z)
constructor specifying initial x, y, and z coordinates

Parameters:
x - x coordinate
y - y coordinate
z - z coordinate

SpatialVector

public SpatialVector(double x,
                     double y)
Standard constructor for the 2D SpatialVector class with x and y coordinates provided

Parameters:
x - the x coordinate of the location
y - the y coordinate of the location

SpatialVector

public SpatialVector(java.awt.geom.Point2D.Double aPoint)
Standard constructor for the 2D SpatialVector class with x and y coordinates provided

Parameters:
aPoint - the coordinates as a Point

SpatialVector

public SpatialVector()
empty constructor

Method Detail

setConnect

public void setConnect(boolean con)
Returns whether the move should be visually connected

Parameters:
con - should the SpatialVector be connected with the previous vector?

getConnect

public boolean getConnect()
sets whether the move should be visually connected


copy

public void copy(SpatialVector v)
copy other vector into this one

Parameters:
v - a SpatialVector

plus

public SpatialVector plus(SpatialVector v)
Adds another vector to this vector.

Parameters:
v - a SpatialVector

dot

public double dot(SpatialVector v)
Calculates the dot product of this vector and another

Parameters:
v - a SpatialVector to dot with
Returns:
the dot product of this vector and v

cross

public SpatialVector cross(SpatialVector v)
Calculates the cross product of this vector and the one passed to it.

Parameters:
v - a SpatialVector to cross with
Returns:
a vector representing the resulting cross product

getX

public double getX()
retrieves the x component


getY

public double getY()
retrieves the y component


getZ

public double getZ()
retrieves the z component


setX

public double setX(double dNewX)
sets x component

Parameters:
dNewX - the nex x extent

setY

public double setY(double dNewY)
sets y component

Parameters:
dNewY - the nex y extent

setZ

public double setZ(double dNewZ)
sets z component

Parameters:
dNewZ - the nex z extent

getLat

public double getLat()
Return the latitudinal heading in radians. Northern hemisphere angles result in positive angles, while southern hemisphere produces negative angles.

Returns:
latitude in radians

getLatDeg

public double getLatDeg()
Return the latitudinal heading in degrees. Northern hemisphere angles result in positive angles, while southern hemisphere produces negative angles.

Returns:
latitude in degrees

getLong

public double getLong()
Return the longitudinal heading in radians. Picture viewing the earth from the south pole. positive values of x result in positive degrees (0 to 180), while negative x produce negative angles (0 to -180)

Returns:
longitude in radians

getLongDeg

public double getLongDeg()
Return the longitudinal heading in degrees. Picture viewing the earth from the south pole. positive values of x result in positive degrees (0 to 180), while negative x produce negative angles (0 to -180)

Returns:
longitude in degrees

minus

public SpatialVector minus(SpatialVector v)
Subtracts a vector from this one and returns the result.

Parameters:
v - a SpatialVector
Returns:
a new vector representing the subtraction

times

public SpatialVector 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 SpatialVector scale(double dScalar)
Multiplies this vector by a scalar and keeps the result. Mutator

Parameters:
dScalar - a scalar to multiply
Returns:
this vector after scaling

setLength

public SpatialVector setLength(double newLength)
Scales the vector to a particular length

Parameters:
newLength - the desired length or the vector
Returns:
this vector after scaling

rotate

public SpatialVector rotate(SpatialVector aVector)
Rotate vector in XYZ

Parameters:
aVector - the SpatialVector around which to rotate
Returns:
the new, rotated Spatialvector

rotateXY

public SpatialVector rotateXY(double r)
Rotate vector in XY

Parameters:
r - the angle (in radians) to rotate in the xy plane
Returns:
the new, rotated Spatialvector

rotateXZ

public SpatialVector rotateXZ(double r)
Rotate vector in XY

Parameters:
r - the angle to rotate in the xz plane
Returns:
the new, rotated Spatialvector

rotate

public SpatialVector rotate(double xyAngle,
                            double xzAngle)
Rotate vector in XYZ

Parameters:
xyAngle - the angle to rotate in the xy plane
xzAngle - the angle to rotate in the xz plane
Returns:
the new, rotated Spatialvector

negate

public void negate()
negate the SpatialVector


negateX

public void negateX()
negate the x axis of the SpatialVector


negateY

public void negateY()
negate the y axis of the SpatialVector


negateZ

public void negateZ()
negate the z axis of the SpatialVector


unitLength

public void unitLength()
Normalizes vector to unit length


getLength

public double getLength()
Reports the magnitude of this vector

Returns:
the magnitude of the vector

getLengthSquared

public double getLengthSquared()
Reports the magnitude of this vector squared

Returns:
the magnitude of the vector, squared

getManhattanLength

public double getManhattanLength()
Reports the magnitude of this vector

Returns:
the magnitude of the vector

equals

public boolean equals(SpatialVector v)
Tests whether or not two vectors are identical in respect to x,y,z coordinates.

Parameters:
v - another SpatialVector
Returns:
whether or not this vector is equal to the other

subtract

public void subtract(SpatialVector v)
Subtracts argument vector from this vector.

Parameters:
v - a SpatialVector

getXY

public java.awt.geom.Point2D.Double getXY()
Scales a single location to a frame's x and y scale values


getScaledPoint

public java.awt.Point getScaledPoint(GridSpace3D visualSpace)
Scales a single location to a frame's x and y scale values

Parameters:
visualSpace - the visual space in which x,y will be scaled

toPolarVector

public PolarVector toPolarVector()
returns the vector as vector defined by measures of longitude, latitude, length


toSpatialVector

public SpatialVector toSpatialVector()
returns the vector as vector defined by measures of longitude, latitude, length


getEuclidianDistance

public double getEuclidianDistance(SpatialVector theOtherLocation)
Returns the straight-line distance between two points

Parameters:
theOtherLocation - the other location

getSquaredEuclidianDistance

public double getSquaredEuclidianDistance(SpatialVector theOtherLocation)
Returns the straight-line distance between two points

Parameters:
theOtherLocation - the other location

getManhattanDistance

public double getManhattanDistance(SpatialVector theOtherLocation)
Returns the straight-line distance between two points

Parameters:
theOtherLocation - the other location

remapLatLongToDistanceCoords

public void remapLatLongToDistanceCoords(SpatialVector theOrigin)
returns a latitude/longitude Capture remapped into a real distance


getSpatialVector

public SpatialVector getSpatialVector(SpatialVector theOtherLocation)
Returns the angle in degrees to another point. This method calculates the angle relative to up on the y coordinate axis (0°) and moving clockwise to 360° - in the YZ coordinate plane

Parameters:
theOtherLocation - the other location

getPolarVector

public PolarVector getPolarVector(SpatialVector theOtherLocation)
Returns the angle in degrees to another point. This method calculates the angle relative to up on the y coordinate axis (0°) and moving clockwise to 360° - in the YZ coordinate plane

Parameters:
theOtherLocation - the other location

applyVector

public SpatialVector applyVector(SpatialVector aVector)
Returns the coordinates of the Location after a Move has been applied to it

Parameters:
aVector - the vector to apply

applyVector

public SpatialVector applyVector(PolarVector aVector)
Returns the coordinates of the Location after a Move has been applied to it

Parameters:
aVector - the vector to apply

toString

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

Overrides:
toString in class java.lang.Object
Returns:
a string representation of the vector

toPoint

public java.awt.Point toPoint()
returns the vector as a point

Returns:
a point

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
clone the object

Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException