lt.monarch.chart.chart3D.engine.vecmath
Class Vector3d

java.lang.Object
  extended by lt.monarch.chart.chart3D.engine.vecmath.Vector3d

public class Vector3d
extends java.lang.Object

A class which represents a vector in three dimensional space.


Field Summary
Modifier and Type Field and Description
 double x
          The x coordinate.
 double y
          The y coordinate.
 double z
          The z coordinate.
static Vector3d Z_VECTOR
           
 
Constructor Summary
Constructor and Description
Vector3d()
          Constructs a new instance of vector.
Vector3d(double xpos, double ypos, double zpos)
          Constructs a new instance of vector with coordinate value specified.
Vector3d(Point3D point)
           
 
Method Summary
Modifier and Type Method and Description
static Vector3d add(Vector3d a, Vector3d b)
          Adds two vectors.
static double angle(Vector3d a, Vector3d b)
          Deprecated. 
 Vector3d crossProduct(Vector3d v1)
           
static Vector3d crossProduct(Vector3d a, Vector3d b)
          Calculates vector cross product.
static double dot(Vector3d a, Vector3d b)
          Calculates the dot product.
 boolean equals(Vector3d vector)
          Compare vectors
 boolean equalsPreciselly(Vector3d vector)
          Test if a supplied Vector3D has the exactly same position.
 Vector3d getCopy()
          Retrieves a copy.
static Vector3d getNormal(Vector3d a, Vector3d b, Vector3d c)
          Retrieves a normal of a plane defined by three points.
static Vector3d getNormal(Vector3d a, Vector3d b, Vector3d c, Vector3d normal)
          Retrieves a normal of a plane defined by three points.
 double length()
          Calculates the length of the vector.
 double lengthSq()
          Calculates the square length of the vector.
 Vector3d normalize()
          Normalizes the vector.
 Vector3d reverse()
          Reverses the vector direction.
static Vector3d scale(double f, Vector3d a)
          Scales the specified vector by a scaling factor.
static Vector3d sub(Vector3d a, Vector3d b)
          Subtracts one vector from another.
 java.lang.String toString()
           
static Vector3d vectorProduct(Vector3d a, Vector3d b)
          Deprecated. 
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

Z_VECTOR

public static final Vector3d Z_VECTOR

x

public double x
The x coordinate.


y

public double y
The y coordinate.


z

public double z
The z coordinate.

Constructor Detail

Vector3d

public Vector3d()
Constructs a new instance of vector.


Vector3d

public Vector3d(double xpos,
                double ypos,
                double zpos)
Constructs a new instance of vector with coordinate value specified.

Parameters:
xpos - the x coordinate
ypos - the y coordinate
zpos - the z coordinate

Vector3d

public Vector3d(Point3D point)
Method Detail

normalize

public Vector3d normalize()
Normalizes the vector.

Returns:
the normalized vector

reverse

public Vector3d reverse()
Reverses the vector direction.

Returns:
the vector with reversed direction

lengthSq

public double lengthSq()
Calculates the square length of the vector.

Returns:
the squared vector length

length

public double length()
Calculates the length of the vector.

Returns:
the vector length

getNormal

public static Vector3d getNormal(Vector3d a,
                                 Vector3d b,
                                 Vector3d c)
Retrieves a normal of a plane defined by three points.

Parameters:
a - the first plane reference point
b - the second plane reference point
c - the third plane reference point
Returns:
the normal of the specified plane

getNormal

public static Vector3d getNormal(Vector3d a,
                                 Vector3d b,
                                 Vector3d c,
                                 Vector3d normal)
Retrieves a normal of a plane defined by three points. Result is placed in parameter.

Parameters:
a - the first plane reference point
b - the second plane reference point
c - the third plane reference point
the - normal of the specified plane

vectorProduct

@Deprecated
public static Vector3d vectorProduct(Vector3d a,
                                                Vector3d b)
Deprecated. 


dot

public static double dot(Vector3d a,
                         Vector3d b)
Calculates the dot product.

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

angle

@Deprecated
public static double angle(Vector3d a,
                                      Vector3d b)
Deprecated. 

Calculates the angle between two vectors.

Parameters:
a - the first vector
b - the second vector
Returns:
the angle in radians

add

public static Vector3d add(Vector3d a,
                           Vector3d b)
Adds two vectors.

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

sub

public static Vector3d sub(Vector3d a,
                           Vector3d b)
Subtracts one vector from another.

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

scale

public static Vector3d scale(double f,
                             Vector3d a)
Scales the specified vector by a scaling factor.

Parameters:
f - the scaling factor
a - the vector to be scaled
Returns:
the resulting vector

getCopy

public Vector3d getCopy()
Retrieves a copy.

Returns:
a copy

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

equals

public boolean equals(Vector3d vector)
Compare vectors

Parameters:
vector -
Returns:

equalsPreciselly

public boolean equalsPreciselly(Vector3d vector)
Test if a supplied Vector3D has the exactly same position.

Parameters:
vector. -
Returns:
supplied Vector3D has the exactly same position.

crossProduct

public Vector3d crossProduct(Vector3d v1)

crossProduct

public static Vector3d crossProduct(Vector3d a,
                                    Vector3d b)
Calculates vector cross product.

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