uavsim.flightdynamicsmodel
Class Vector

java.lang.Object
  extended by uavsim.flightdynamicsmodel.Vector
All Implemented Interfaces:
java.lang.Cloneable

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

Defines a mathematical vector designed to hold either position (as x, y, and z) or attitude (as roll, pitch, and yaw, respectively). For compatibility with the other classes derived from the original source (Physics for Game Developers by David Bourg), the member variables are public and mutable. Eventually they will be protected appropriately. In addition, some methods inconsistently operate in place, while others behave as expected and return a new affected instance of the vector.

Author:
Dan Tappan [17.08.11]

Field Summary
 double _x
          the x component, or roll in Euler angles
 double _y
          the y component, or pitch in Euler angles
 double _z
          the z component, or yaw in Euler angles
 
Constructor Summary
Vector()
          Creates an attitude or position vector with zero values.
Vector(Attitude attitude)
          Creates an attitude vector from Euler angles.
Vector(CoordinateWorld3D coordinate)
          Creates a position vector from a 3D world coordinate.
Vector(double x, double y, double z)
          Creates an attitude or position vector.
 
Method Summary
 Vector add(Vector vector)
          Calculates the sum of this vector and another.
 Vector clone()
          
 Vector conjugate()
          Calculates the conjugate of this vector.
 Attitude convertToAttitude()
          Converts this vector to an attitude.
 CoordinateWorld3D convertToCoordinateWorld3D()
          Converts this vector to 3D world coordinates.
 Vector crossProduct(Vector vector)
          Calculates the cross product of this vector and another.
 Vector divide(double scale)
          Calculates the scaled components of this vector.
 Vector dotProduct(Vector vector)
          Calculates the dot product of this vector and another.
 double getX()
          Gets the x component, or roll in Euler angles.
 double getY()
          Gets the y/i> component, or pitch in Euler angles.
 double getZ()
          Gets the z/i> component, or yaw in Euler angles.
 double magnitude()
          Calculates the magnitude of this vector.
 Vector multiply(double scale)
          Calculates the scaled components of this vector.
 double multiply(Vector vector)
          Calculates the product of this vector and another.
 Vector normalize()
          Normalizes the components of this vector in place and returns it as well.
 Vector reset()
          Resets the components of this vector in place and returns it as well.
 Vector reverse()
          Negates the components of this vector in place and returns it as well.
 Vector subtract(Vector vector)
          Calculates the difference of this vector and another.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_x

public double _x
the x component, or roll in Euler angles


_y

public double _y
the y component, or pitch in Euler angles


_z

public double _z
the z component, or yaw in Euler angles

Constructor Detail

Vector

public Vector()
Creates an attitude or position vector with zero values.


Vector

public Vector(Attitude attitude)
Creates an attitude vector from Euler angles. [xxx test]

Parameters:
attitude - - the attitude

Vector

public Vector(CoordinateWorld3D coordinate)
Creates a position vector from a 3D world coordinate. [xxx test]

Parameters:
coordinate - - the coordinate

Vector

public Vector(double x,
              double y,
              double z)
Creates an attitude or position vector.

Parameters:
x - - the x component, or roll in Euler angles
y - - the y component, or pitch in Euler angles
z - - the y component, or yaw in Euler angles
Method Detail

add

public Vector add(Vector vector)
Calculates the sum of this vector and another.

Parameters:
vector - - the other vector
Returns:
the result as a new vector

clone

public Vector clone()

Overrides:
clone in class java.lang.Object

conjugate

public Vector conjugate()
Calculates the conjugate of this vector.

Returns:
the result as a new vector

convertToAttitude

public Attitude convertToAttitude()
Converts this vector to an attitude. xxx test

Returns:
the attitude

convertToCoordinateWorld3D

public CoordinateWorld3D convertToCoordinateWorld3D()
Converts this vector to 3D world coordinates. xxx test

Returns:
the coordinates

crossProduct

public Vector crossProduct(Vector vector)
Calculates the cross product of this vector and another.

Parameters:
vector - - the other vector
Returns:
the result as a new vector

divide

public Vector divide(double scale)
Calculates the scaled components of this vector.

Parameters:
scale - - the scale
Returns:
the result as a new vector

dotProduct

public Vector dotProduct(Vector vector)
Calculates the dot product of this vector and another.

Parameters:
vector - - the other vector
Returns:
the result as a new vector

getX

public double getX()
Gets the x component, or roll in Euler angles.

Returns:
the component

getY

public double getY()
Gets the y/i> component, or pitch in Euler angles.

Returns:
the component

getZ

public double getZ()
Gets the z/i> component, or yaw in Euler angles.

Returns:
the component

magnitude

public double magnitude()
Calculates the magnitude of this vector.

Returns:
the result

multiply

public Vector multiply(double scale)
Calculates the scaled components of this vector.

Parameters:
scale - - the scale
Returns:
the result as a new vector

multiply

public double multiply(Vector vector)
Calculates the product of this vector and another.

Parameters:
vector - - the other vector
Returns:
the result

normalize

public Vector normalize()
Normalizes the components of this vector in place and returns it as well.

Returns:
this vector

reset

public Vector reset()
Resets the components of this vector in place and returns it as well.

Returns:
this vector

reverse

public Vector reverse()
Negates the components of this vector in place and returns it as well.

Returns:
this vector

subtract

public Vector subtract(Vector vector)
Calculates the difference of this vector and another.

Parameters:
vector - - the other vector
Returns:
the result as a new vector

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object