cdx
Class Vector3d

java.lang.Object
  extended by cdx.Vector3d

public final class Vector3d
extends java.lang.Object

The Vector3d class implements a 3-dimensional vector that can represent the position or velocity of an object within a 3D space. This implementation uses public, non-final fields to avoid as much object creation as possible. Java does not have value types per se, but these vector classes are the closest thing that is possible.


Field Summary
 float x
          Fields for the x, y and z coordinates of the vector.
 float y
          Fields for the x, y and z coordinates of the vector.
 float z
          Fields for the x, y and z coordinates of the vector.
 
Constructor Summary
Vector3d()
          The default constructor for the Vector3d class returns an object representing the zero vector.
Vector3d(float x, float y, float z)
          The main constructor for the Vector3d class takes the three coordinates as parameters and produces an object representing that vector.
Vector3d(Vector3d v)
          The secondary constructor for the Vector3d class takes a vector to copy into this new instance and returns an instance that represents a copy of that vector.
 
Method Summary
 boolean equals(java.lang.Object o)
          Check the equality of two objects
 boolean equals(Vector3d b)
          Check the equality of two Vector3d objects
 int hashCode()
          The hashfunction for Vector3d
 void set(float x, float y, float z)
          The set method is basically a convenience method that sets the internal values of the coordinates.
 void set(Vector3d val)
          The set is basically a convenience method that sets the internal values of the coordinates copying them from another vector.
 java.lang.String toString()
          Convert the value of a Vector3d to a string
 void zero()
          The zero method is a convenience method to zero the coordinates of the vector.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

x

public float x
Fields for the x, y and z coordinates of the vector.


y

public float y
Fields for the x, y and z coordinates of the vector.


z

public float z
Fields for the x, y and z coordinates of the vector.

Constructor Detail

Vector3d

public Vector3d()
The default constructor for the Vector3d class returns an object representing the zero vector.


Vector3d

public Vector3d(float x,
                float y,
                float z)
The main constructor for the Vector3d class takes the three coordinates as parameters and produces an object representing that vector.

Parameters:
x - the coordinate on the x (east-west) axis
y - the coordinate on the y (north-south) axis
z - the coordinate on the z (elevation) axis

Vector3d

public Vector3d(Vector3d v)
The secondary constructor for the Vector3d class takes a vector to copy into this new instance and returns an instance that represents a copy of that vector.

Parameters:
v - the vector to copy into this new instance
Method Detail

set

public void set(float x,
                float y,
                float z)
The set method is basically a convenience method that sets the internal values of the coordinates.

Parameters:
x - the coordinate on the x (east-west) axis
y - the coordinate on the y (north-south) axis
z - the coordinate on the z (elevation) axis

set

public void set(Vector3d val)
The set is basically a convenience method that sets the internal values of the coordinates copying them from another vector.

Parameters:
val - the value of the vector

zero

public void zero()
The zero method is a convenience method to zero the coordinates of the vector.


equals

public boolean equals(java.lang.Object o)
Check the equality of two objects

Overrides:
equals in class java.lang.Object

equals

public boolean equals(Vector3d b)
Check the equality of two Vector3d objects


hashCode

public int hashCode()
The hashfunction for Vector3d

Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Convert the value of a Vector3d to a string

Overrides:
toString in class java.lang.Object