nl.kun.Engine3D
Class TVector3D

java.lang.Object
  |
  +--nl.kun.Engine3D.TVector3D
Direct Known Subclasses:
TCoordSys3D, TVertex3D

public class TVector3D
extends java.lang.Object

The TVector3D class is the basic class for all 3D classes and contains all information to define a vector in 3D. It also contains a lot of functions that can manipulate vectors


Field Summary
static int DBSCIENTIFIC
          Static macro for use in Double2String.
static int DBSTANDARD
          Static macro for use in Double2String.
 double x
          The x part of the vector.
 double y
          The y part of the vector.
 double z
          The z part of the vector.
 
Constructor Summary
TVector3D()
          Empty constructor.
TVector3D(double _x, double _y, double _z)
          Standard constructor.
TVector3D(TVector3D _p)
          Copy constructor.
 
Method Summary
protected  double Angle(TVector3D _a, TVector3D _b)
          Calculates the angle between TVector3D's _a and _b.
static java.lang.String Double2String(double _x, int _digits)
          Converts a double to a String in DBSTANDARD mode.
static java.lang.String Double2String(double _x, int _digits, int _mode)
          A method to convert a double to a String with a certain roundoff.
 double Modulus()
          The modulus of the vector
 double Modulus(TVector3D _b)
          The modulus of a vector
protected  TVector3D Negate()
          Negates this vector
protected  TVector3D Negate(TVector3D _b)
          Negates vector _b.
 TVector3D Normalize()
          Normalizes this vector
 TVector3D Normalize(TVector3D _b)
          Normalizes the vector _b
static TVector3D NulVec()
          A vector with all elements zero
 void Rotate(TVector3D _PosVec, TVector3D _DirVec, double _Angle)
          Rotates this vector around the line that is build op by a position vector and a direction vector by an amount _Angle
static TVector3D StdXaxis()
          A standard vector for a X axis.
static TVector3D StdYaxis()
          A standard vector for a Y axis.
static TVector3D StdZaxis()
          A standard vector for a Z axis.
static double String2Double(java.lang.String _string)
          Converts a String to a double.
 java.lang.String toString()
          Used when a string version of this object is needed
 TVector3D Translate(double _dx, double _dy, double _dz)
          Translates this vector.
 TVector3D Translate(TVector3D _dV)
          Translates this vector by another vector.
protected  TVector3D VAdd(TVector3D _a, TVector3D _b)
          Adds vector _a and _b from
protected  TVector3D VCrossProduct(TVector3D _a, TVector3D _b)
          Calculates the crossproduct of vector _a and the vector _b
protected  TVector3D VCrossProduct(TVector3D _a, TVector3D _b, TVector3D _c)
          Calculates the crossproduct of vector _a and the vector _b, and returns the result in vector _c
protected  double VDotProduct(TVector3D _a, TVector3D _b)
          Calculates the dotproduct of vector _a and _b from
 TVector3D Vector3D()
          This object
 TVector3D Vector3D(double _x, double _y, double _z)
          This object.
 TVector3D Vector3D(TVector3D _pos)
          This object.
protected  TVector3D VPerpendicular(TVector3D _b)
          Calculates a vector that is perpendicular to vector _b
protected  TVector3D VPerpendicular(TVector3D _b, TVector3D _a)
          Calculates a vector that is perpendicular to vector _b and returns it's result in vector _a
protected  TVector3D VScalarProduct(double _alpha)
          Calculates the scalar product of this vector and the double _alpha
protected  TVector3D VScalarProduct(TVector3D _a, double _alpha)
          Calculates the scalar product of vector _a and the double _alpha
protected  TVector3D VScalarProduct(TVector3D _a, double _alpha, TVector3D _b)
          Calculates the scalar product of the vector _a and the double _alpha and puts the result in _b
protected  TVector3D VSubstract(TVector3D _b)
          Substracts vector _b from this vector
protected  TVector3D VSubstract(TVector3D _a, TVector3D _b)
          Substracts vector _b from _a so _a-_b
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

x

public double x
The x part of the vector.

y

public double y
The y part of the vector.

z

public double z
The z part of the vector.

DBSCIENTIFIC

public static int DBSCIENTIFIC
Static macro for use in Double2String.
See Also:
Double2String(double,int)

DBSTANDARD

public static int DBSTANDARD
Static macro for use in Double2String.
See Also:
Double2String(double,int)
Constructor Detail

TVector3D

public TVector3D(double _x,
                 double _y,
                 double _z)
Standard constructor.

TVector3D

public TVector3D(TVector3D _p)
Copy constructor.
Parameters:
_p - An other TVector3D that will be copied into this object.

TVector3D

public TVector3D()
Empty constructor. Makes an object with values (0,0,0)
Method Detail

NulVec

public static TVector3D NulVec()
A vector with all elements zero

StdXaxis

public static TVector3D StdXaxis()
A standard vector for a X axis.

StdYaxis

public static TVector3D StdYaxis()
A standard vector for a Y axis.

StdZaxis

public static TVector3D StdZaxis()
A standard vector for a Z axis.

Vector3D

public final TVector3D Vector3D()
This object

Vector3D

public TVector3D Vector3D(TVector3D _pos)
This object. Able to change this object to another object. Like a constructor only the object already exists.
Parameters:
_pos - Another TVector3D which values are copied in this object

Vector3D

public TVector3D Vector3D(double _x,
                          double _y,
                          double _z)
This object. Able to change this object with parameters. Like a constructor only the object already exists.

Modulus

public final double Modulus()
The modulus of the vector

Modulus

public final double Modulus(TVector3D _b)
The modulus of a vector
Parameters:
_b - A TVector3D object to determine the modulus for

Normalize

public final TVector3D Normalize()
Normalizes this vector

Normalize

public final TVector3D Normalize(TVector3D _b)
Normalizes the vector _b
Parameters:
_b - a TVector3D that is to be normalized

Translate

public TVector3D Translate(double _dx,
                           double _dy,
                           double _dz)
Translates this vector.
Parameters:
_dx - the translation in x direction
_dy - the translation in y direction
_dz - the translation in z direction

Translate

public TVector3D Translate(TVector3D _dV)
Translates this vector by another vector.
Parameters:
_dV - the translation vector

Angle

protected final double Angle(TVector3D _a,
                             TVector3D _b)
Calculates the angle between TVector3D's _a and _b. When the dotproduct between _a and _b <0, the angle is negated.
Parameters:
_a - the first vector
_b - the second vector

VScalarProduct

protected final TVector3D VScalarProduct(TVector3D _a,
                                         double _alpha)
Calculates the scalar product of vector _a and the double _alpha
Parameters:
_a - The vector
_alpha - the scalar

VScalarProduct

protected final TVector3D VScalarProduct(double _alpha)
Calculates the scalar product of this vector and the double _alpha
Parameters:
_alpha - the scalar

VScalarProduct

protected final TVector3D VScalarProduct(TVector3D _a,
                                         double _alpha,
                                         TVector3D _b)
Calculates the scalar product of the vector _a and the double _alpha and puts the result in _b
Parameters:
_alpha - the scalar
_a - the vector to be multiplied with
_b - the result vector

Negate

protected final TVector3D Negate()
Negates this vector

Negate

protected final TVector3D Negate(TVector3D _b)
Negates vector _b.
Parameters:
_b - the vector to be negated.

VCrossProduct

protected final TVector3D VCrossProduct(TVector3D _a,
                                        TVector3D _b)
Calculates the crossproduct of vector _a and the vector _b
Parameters:
_a - The first vector
_b - The second vector

VCrossProduct

protected final TVector3D VCrossProduct(TVector3D _a,
                                        TVector3D _b,
                                        TVector3D _c)
Calculates the crossproduct of vector _a and the vector _b, and returns the result in vector _c
Parameters:
_a - The first vector
_b - The second vector
_c - The result vector

VSubstract

protected final TVector3D VSubstract(TVector3D _a,
                                     TVector3D _b)
Substracts vector _b from _a so _a-_b
Parameters:
_a - The first vector
_b - The second vector

VSubstract

protected final TVector3D VSubstract(TVector3D _b)
Substracts vector _b from this vector
Parameters:
_b - A vector which is substracted from this vector

VAdd

protected final TVector3D VAdd(TVector3D _a,
                               TVector3D _b)
Adds vector _a and _b from
Parameters:
_a - The first vector
_b - The second vector

VDotProduct

protected final double VDotProduct(TVector3D _a,
                                   TVector3D _b)
Calculates the dotproduct of vector _a and _b from
Parameters:
_a - The first vector
_b - The second vector

VPerpendicular

protected final TVector3D VPerpendicular(TVector3D _b)
Calculates a vector that is perpendicular to vector _b
Parameters:
_b - The vector for which a perpendicular vector should be found.

VPerpendicular

protected final TVector3D VPerpendicular(TVector3D _b,
                                         TVector3D _a)
Calculates a vector that is perpendicular to vector _b and returns it's result in vector _a
Parameters:
_b - The vector for which a perpendicular vector should be found.
_a - Result vector

toString

public java.lang.String toString()
Used when a string version of this object is needed
Overrides:
toString in class java.lang.Object

Rotate

public void Rotate(TVector3D _PosVec,
                   TVector3D _DirVec,
                   double _Angle)
Rotates this vector around the line that is build op by a position vector and a direction vector by an amount _Angle
Parameters:
_PosVec - The position vector
_DirVec - The direction vector
_Angle - The rotation angle (in radians)

Double2String

public static final java.lang.String Double2String(double _x,
                                                   int _digits,
                                                   int _mode)
A method to convert a double to a String with a certain roundoff. It automatically uses exponential notation when the number is too large or too small, but can also be set to use exponential notation always.
Parameters:
_x - The double to be converted
_digits - the number of significant numbers in DBSCIENTIFIC mode. or the number of digits in general (without the point) in DBSTANDARD mode.
_mode - kan be DBSCIENTIFIC or DBSTANDARD.

Double2String

public static final java.lang.String Double2String(double _x,
                                                   int _digits)
Converts a double to a String in DBSTANDARD mode.
Parameters:
_x - The double to be converted
_digits - the number of digits in general (without the point) in DBSTANDARD mode.

String2Double

public static final double String2Double(java.lang.String _string)
Converts a String to a double.
Parameters:
_string - the String to be converted to double.