Class Vector3D
java.lang.Object
Vector3D
- All Implemented Interfaces:
IVector3D
public class Vector3D extends java.lang.Object implements IVector3D
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description Vector3D
add(Vector3D that)
double
angleBetween(Vector3D that)
Vector3D
cross(Vector3D that)
int
dot(Vector3D that)
boolean
equals(java.lang.Object o)
double
magnitude()
static void
main(java.lang.String[] args)
Vector3D
scalarMultiply(int scalar)
Vector3D
subtract(Vector3D that)
java.lang.String
toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Field Details
-
I
The constant vector I: 1i + 0j + 0k -
J
The constant vector J: 0i + 1j + 0k -
K
The constant vector K: 0i + oj + 1k -
ZERO
The zero vector -
TINY
public static final double TINYConstant for double tolerance- See Also:
- Constant Field Values
-
-
Constructor Details
-
Vector3D
public Vector3D(int a, int b, int c)- Parameters:
a
- the x-component of the vector we are creatingb
- the y-component of the vector we are creatingc
- the z-component of the vector we are creating
-
Vector3D
public Vector3D()This makes the zero vector
-
-
Method Details
-
dot
-
cross
-
scalarMultiply
- Specified by:
scalarMultiply
in interfaceIVector3D
- Parameters:
scalar
- a integer we are scalar multiplying this vector by- Returns:
- scalar*this
-
add
-
subtract
-
magnitude
public double magnitude() -
angleBetween
- Specified by:
angleBetween
in interfaceIVector3D
- Parameters:
that
- another vector- Returns:
- the angle between this and that in radians in [0,π]
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
- Returns:
- A string representation of the form ai + bj + ck. Make sure you have negative terms not looking like crap.
-
equals
public boolean equals(java.lang.Object o)- Overrides:
equals
in classjava.lang.Object
-
main
public static void main(java.lang.String[] args)
-