ProGAL.geom3d
Class Vector

java.lang.Object
  extended by ProGAL.geomNd.Vector
      extended by ProGAL.geom3d.Vector
Direct Known Subclasses:
Vector.ImmutableVector3d

public class Vector
extends Vector

A vector in (x,y,z)-space represented with double precision.


Nested Class Summary
static class Vector.ImmutableVector3d
          A wrapper class for Vector3d which makes the vector immutable.
 
Field Summary
static Vector X
          An immutable vector pointing in the (1,0,0)-direction.
static Vector Y
          An immutable vector pointing in the (0,1,0)-direction.
static Vector Z
          An immutable vector pointing in the (0,0,1)-direction.
 
Constructor Summary
Vector(double[] coords)
          Construct a vector using the double-array as coordinates.
Vector(double x, double y, double z)
          Construct a vector with the specified coordinates.
Vector(Point p)
          Construct a vector pointing from origo to p.
Vector(Point p1, Point p2)
          Constructs a vector between two points p1 and p2 - added by pawel 12-11-2011
Vector(Vector v)
          Construct a vector that is a clone of v.
 
Method Summary
 Vector add(Point p)
          Add p to this vector and return the result (without changing this object).
 Vector add(Vector v)
          Add v to this vector and return the result (without changing this object).
 Vector addThis(Point p)
          Add p to this vector and return the result (changing this object).
 Vector addThis(Vector v)
          Add v to this vector and return the result (changing this object).
 double angle(Vector v)
          Get the angle between this vector and v.
 Vector clone()
          Create a clone of this vector.
 Vector cross(Vector v)
          Get the cross-product of this vector and v (without changing this object).
 Vector crossThis(Vector v)
          Get the cross-product of this vector and v and store the result in this vector (changes this object).
 Vector divide(double s)
          Divide this vector by s and return the result (without changing this object).
 Vector divideThis(double s)
          Divide this vector by s and return the result (changing this object).
 double dot(Vector v)
          Get the dot-product of this vector and v.
static double getAngle(Vector u, Vector v)
          Get the angle between vector u and v.
static double getCosDihedralAngle(Vector u, Vector v, Vector w)
           
static double getDihedralAngle(Vector b1, Vector b2, Vector b3)
          Get the dihedral angle between 3 non-colinear vectors b1, b2, b3.
 Vector getOrthonormal()
          Get a vector (one of many possible) orthonormal to vector v.
 boolean isParallel(Vector v)
           
 boolean isSteinerAngle(Vector v)
           
 Vector multiply(double s)
          Multiply this vector by s and return the result (without changing this object).
 Vector multiplyThis(double s)
          Multiply this vector by s and return the result (changing this object).
 Vector normalize()
          Normalize this vector and return the result (without changing this object).
 Vector normalizeFast()
           
 Vector normalizeThis()
          Normalize this vector and return the result (changing this object).
 Vector normalizeThisFast()
           
 Vector rotateIn(Vector v, double angle)
          Perform a right-handed rotation of v around this vector.
 Vector scaleToLength(double length)
          Scale this vector to a certain length (returns new object and does not change this object).
 Vector scaleToLengthThis(double length)
          Scale this vector to a certain length (changes this object).
 void set(Vector v)
          Set all coordinates of this vector equal to those of v
 void setX(double x)
          Set the first coordinate
 void setY(double y)
          Set the second coordinate
 void setZ(double z)
          Set the third coordinate
 Vector subtract(Vector v)
          Subtract v from this vector and return the result (without changing this object).
 Vector subtractThis(Vector v)
          Subract v from this vector and return the result (changing this object).
 void toConsole()
          Writes this vector to System.out.
 void toConsole(int dec)
          Writes this vector to System.out with dec decimals precision.
 Point toPoint()
          Convert this vector to a point.
 void toScene(J3DScene scene, java.awt.Color clr, double width)
           
 java.lang.String toString()
          Returns a string-representation of this vector formatted with two decimals precision.
 java.lang.String toString(int dec)
          Returns a string-representation of this vector formatted with dec decimals precision.
 double x()
          Get the first coordinate.
 double y()
          Get the second coordinate.
 double z()
          Get the third coordinate.
 
Methods inherited from class ProGAL.geomNd.Vector
add, addThis, angle, dot, equals, equals, get, getCoord, getDimensions, getLengthSquared, isZeroVector, length, outerProduct, set, setCoord, setCoords, subtract, subtractThis
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

X

public static Vector X
An immutable vector pointing in the (1,0,0)-direction.


Y

public static Vector Y
An immutable vector pointing in the (0,1,0)-direction.


Z

public static Vector Z
An immutable vector pointing in the (0,0,1)-direction.

Constructor Detail

Vector

public Vector(double x,
              double y,
              double z)
Construct a vector with the specified coordinates.


Vector

public Vector(Point p)
Construct a vector pointing from origo to p.


Vector

public Vector(Point p1,
              Point p2)
Constructs a vector between two points p1 and p2 - added by pawel 12-11-2011


Vector

public Vector(Vector v)
Construct a vector that is a clone of v.


Vector

public Vector(double[] coords)
Construct a vector using the double-array as coordinates. Note: The array is not cloned

Method Detail

x

public double x()
Get the first coordinate.


y

public double y()
Get the second coordinate.


z

public double z()
Get the third coordinate.


setX

public void setX(double x)
Set the first coordinate


setY

public void setY(double y)
Set the second coordinate


setZ

public void setZ(double z)
Set the third coordinate


set

public void set(Vector v)
Set all coordinates of this vector equal to those of v


dot

public double dot(Vector v)
Get the dot-product of this vector and v.


angle

public double angle(Vector v)
Get the angle between this vector and v.


add

public Vector add(Vector v)
Add v to this vector and return the result (without changing this object).


addThis

public Vector addThis(Vector v)
Add v to this vector and return the result (changing this object).


add

public Vector add(Point p)
Add p to this vector and return the result (without changing this object).


addThis

public Vector addThis(Point p)
Add p to this vector and return the result (changing this object).


subtract

public Vector subtract(Vector v)
Subtract v from this vector and return the result (without changing this object).


subtractThis

public Vector subtractThis(Vector v)
Subract v from this vector and return the result (changing this object).


multiply

public Vector multiply(double s)
Multiply this vector by s and return the result (without changing this object).

Overrides:
multiply in class Vector

multiplyThis

public Vector multiplyThis(double s)
Multiply this vector by s and return the result (changing this object).

Overrides:
multiplyThis in class Vector

divide

public Vector divide(double s)
Divide this vector by s and return the result (without changing this object).

Overrides:
divide in class Vector

divideThis

public Vector divideThis(double s)
Divide this vector by s and return the result (changing this object).

Overrides:
divideThis in class Vector

normalize

public Vector normalize()
Normalize this vector and return the result (without changing this object).

Overrides:
normalize in class Vector

normalizeThis

public Vector normalizeThis()
Normalize this vector and return the result (changing this object).

Overrides:
normalizeThis in class Vector

normalizeFast

public Vector normalizeFast()

normalizeThisFast

public Vector normalizeThisFast()

scaleToLength

public Vector scaleToLength(double length)
Scale this vector to a certain length (returns new object and does not change this object).

Overrides:
scaleToLength in class Vector

scaleToLengthThis

public Vector scaleToLengthThis(double length)
Scale this vector to a certain length (changes this object).

Overrides:
scaleToLengthThis in class Vector

cross

public Vector cross(Vector v)
Get the cross-product of this vector and v (without changing this object).


crossThis

public Vector crossThis(Vector v)
Get the cross-product of this vector and v and store the result in this vector (changes this object).


rotateIn

public Vector rotateIn(Vector v,
                       double angle)
Perform a right-handed rotation of v around this vector. TODO: Test


toPoint

public Point toPoint()
Convert this vector to a point.

Overrides:
toPoint in class Vector

toString

public java.lang.String toString()
Returns a string-representation of this vector formatted with two decimals precision.

Overrides:
toString in class Vector

toString

public java.lang.String toString(int dec)
Returns a string-representation of this vector formatted with dec decimals precision.

Overrides:
toString in class Vector

toConsole

public void toConsole()
Writes this vector to System.out.

Overrides:
toConsole in class Vector

toConsole

public void toConsole(int dec)
Writes this vector to System.out with dec decimals precision.

Overrides:
toConsole in class Vector

toScene

public void toScene(J3DScene scene,
                    java.awt.Color clr,
                    double width)

clone

public Vector clone()
Create a clone of this vector.

Overrides:
clone in class Vector

getAngle

public static double getAngle(Vector u,
                              Vector v)
Get the angle between vector u and v.


getDihedralAngle

public static double getDihedralAngle(Vector b1,
                                      Vector b2,
                                      Vector b3)
Get the dihedral angle between 3 non-colinear vectors b1, b2, b3.


getOrthonormal

public Vector getOrthonormal()
Get a vector (one of many possible) orthonormal to vector v.


isParallel

public boolean isParallel(Vector v)

isSteinerAngle

public boolean isSteinerAngle(Vector v)

getCosDihedralAngle

public static double getCosDihedralAngle(Vector u,
                                         Vector v,
                                         Vector w)