Jeospace API

org.jeospace.coordinate
Class Vector

java.lang.Object
  extended byorg.jeospace.coordinate.Vector
Direct Known Subclasses:
Cartesian

public class Vector
extends java.lang.Object

A 3 dimensional vector implemented with double precision floating point values.

Version:
$Revision: 1.1.1.1 $
Author:
Rex Melton

Field Summary
static int X
          Index of the X-axis coordinate, used in array representations of the coordinate axis values.
static int Y
          Index of the Y-axis coordinate, used in array representations of the coordinate axis values.
static int Z
          Index of the Z-axis coordinate, used in array representations of the coordinate axis values.
 
Constructor Summary
Vector()
          Construct a new vector with values (0, 0, 0)
Vector(double[] vec)
          Construct a new vector initialized with the specified values
Vector(double x, double y, double z)
          Construct a new vector initialized with the specified values
Vector(float[] vec)
          Construct a new vector initialized with the specified values
Vector(Vector arg)
          Construct a new vector duplicating the passed argument
 
Method Summary
 void clear()
          Clear the values of the vector
static Vector cross(Vector a, Vector b)
          Return the cross product of two vectors
 double dot(Vector v)
          Return the value of the dot product of this vector and the argument
 boolean equals(java.lang.Object obj)
          Check the vector for equality with the passed object.
 double[] get()
          Return the values of the vector
 double get(Axis axis)
          Get the vector value along an axis
 void get(double[] value)
          Get the double values of the vector
 void get(float[] value)
          Get the float values of the vector
 int hashCode()
          Calculate the hash code
 double magnitude()
          Return the magnitude of the vector
 void negate()
          Change the sign of each coordinate point
 void negate(Axis axis)
          Change the sign of the coordinate point on the specified Axis
 void normalize()
          Normalize the vector values
 void scale(double arg)
          Multiply each vector value by the passed argument
 void set(Axis axis, double value)
          Set the vector value along an axis
 void set(double[] vec)
          Set the values of the vector
 void set(double x, double y, double z)
          Set the value of the vector
 void set(float[] vec)
          Set the values of the vector
 java.lang.String toString()
          Return a string representing the vector of the form "x, y, z"
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

X

public static final int X
Index of the X-axis coordinate, used in array representations of the coordinate axis values.


Y

public static final int Y
Index of the Y-axis coordinate, used in array representations of the coordinate axis values.


Z

public static final int Z
Index of the Z-axis coordinate, used in array representations of the coordinate axis values.

Constructor Detail

Vector

public Vector()
Construct a new vector with values (0, 0, 0)


Vector

public Vector(Vector arg)
Construct a new vector duplicating the passed argument

Parameters:
arg - the vector to duplicate

Vector

public Vector(double x,
              double y,
              double z)
Construct a new vector initialized with the specified values

Parameters:
x - the x value
y - the y value
z - the z value

Vector

public Vector(double[] vec)
Construct a new vector initialized with the specified values

Parameters:
vec - the double array of values

Vector

public Vector(float[] vec)
Construct a new vector initialized with the specified values

Parameters:
vec - the float array of values
Method Detail

magnitude

public double magnitude()
Return the magnitude of the vector

Returns:
the magnitude of the vector

normalize

public void normalize()
Normalize the vector values


set

public void set(double x,
                double y,
                double z)
Set the value of the vector

Parameters:
x - the x value
y - the y value
z - the z value

set

public void set(double[] vec)
Set the values of the vector

Parameters:
vec - the double array of values

set

public void set(float[] vec)
Set the values of the vector

Parameters:
vec - the float array of values

clear

public void clear()
Clear the values of the vector


negate

public void negate()
Change the sign of each coordinate point


negate

public void negate(Axis axis)
Change the sign of the coordinate point on the specified Axis

Parameters:
axis - the Axis identifier

get

public double[] get()
Return the values of the vector

Returns:
the double array of vector values

get

public void get(double[] value)
Get the double values of the vector

Parameters:
value - the double array to be initialized with the values in X, Y, and Z axis order

get

public void get(float[] value)
Get the float values of the vector

Parameters:
value - the float array to be initialized with the values in X, Y, and Z axis order

get

public double get(Axis axis)
Get the vector value along an axis

Parameters:
axis - the Axis identifier
Returns:
the double value for the X, Y or Z axis

set

public void set(Axis axis,
                double value)
Set the vector value along an axis

Parameters:
axis - the Axis identifier
value - the double value for the X, Y or Z axis

scale

public void scale(double arg)
Multiply each vector value by the passed argument

Parameters:
arg - the multiplier

cross

public static Vector cross(Vector a,
                           Vector b)
Return the cross product of two vectors

Parameters:
a - the first vector
b - the second vector

dot

public double dot(Vector v)
Return the value of the dot product of this vector and the argument

Parameters:
v - the argument vector
Returns:
the dot product

hashCode

public int hashCode()
Calculate the hash code

Returns:
the hash code

equals

public boolean equals(java.lang.Object obj)
Check the vector for equality with the passed object.

Returns:
true if the values of the vector are identical, false otherwise

toString

public java.lang.String toString()
Return a string representing the vector of the form "x, y, z"

Returns:
the string representation of the quaternion

Jeospace API

Copyright © 2006 - jeospace.org