|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectvector.Vector3d
public class Vector3d
A simple class to represent 3-dimensional vectors. The vector is implemented using an array of double (NOTE: You would not ordinarily document such an implementation detail; I do so here to get you to use an array in your implementation).
| Constructor Summary | |
|---|---|
Vector3d()
Creates the vector [ 0.0, 0.0, 0.0 ]. |
|
Vector3d(double x,
double y,
double z)
Creates the vector [ x, y, z ] |
|
| Method Summary | |
|---|---|
Vector3d |
cross(Vector3d other)
Computes the cross product with another vector. |
boolean |
equals(Object obj)
Compares two vectors for equality. |
double |
getX()
Get the x-coordinate of the vector. |
double |
getY()
Get the y-coordinate of the vector. |
double |
getZ()
Get the z-coordinate of the vector. |
int |
hashCode()
Returns a hash code value for this object. |
void |
setX(double x)
Set the x-coordinate of the vector. |
void |
setY(double y)
Set the y-coordinate of the vector. |
void |
setZ(double z)
Set the z-coordinate of the vector. |
String |
toString()
Converts this vector to a String of the form [ x y z ]
where x, y, and z
are the coordinates of the vector. |
static Vector3d |
x()
Returns the unit vector along the x-axis [ 1.0, 0.0, 0.0 ] |
static Vector3d |
y()
Returns the unit vector along the y-axis [ 0.0, 1.0, 0.0 ] |
static Vector3d |
z()
Returns the unit vector along the z-axis [ 0.0, 0.0, 1.0 ] |
| Methods inherited from class java.lang.Object |
|---|
getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Vector3d()
public Vector3d(double x,
double y,
double z)
x - The x-coordinate of the vector.y - The y-coordinate of the vector.z - The z-coordinate of the vector.| Method Detail |
|---|
public static Vector3d x()
public static Vector3d y()
public static Vector3d z()
public double getX()
public double getY()
public double getZ()
public void setX(double x)
x - The value to set the x-coordinate of the vector.public void setY(double y)
y - The value to set the y-coordinate of the vector.public void setZ(double z)
z - The value to set the z-coordinate of the vector.public Vector3d cross(Vector3d other)
other - The vector to take the cross product with.
this x other.public boolean equals(Object obj)
true if and only if the argument is not
null and two vectors have the same coordinates.
equals in class Objectobj - The object to compare with.
true if the objects are the same;
false otherwise.public int hashCode()
hashCode in class Objectpublic String toString()
[ x y z ]
where x, y, and z
are the coordinates of the vector.
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||