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 Vector3Dadd(Vector3D that)doubleangleBetween(Vector3D that)Vector3Dcross(Vector3D that)intdot(Vector3D that)booleanequals(java.lang.Object o)doublemagnitude()static voidmain(java.lang.String[] args)Vector3DscalarMultiply(int scalar)Vector3Dsubtract(Vector3D that)java.lang.StringtoString()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:
scalarMultiplyin interfaceIVector3D- Parameters:
scalar- a integer we are scalar multiplying this vector by- Returns:
- scalar*this
-
add
-
subtract
-
magnitude
public double magnitude() -
angleBetween
- Specified by:
angleBetweenin interfaceIVector3D- Parameters:
that- another vector- Returns:
- the angle between this and that in radians in [0,π]
-
toString
public java.lang.String toString()- Overrides:
toStringin 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:
equalsin classjava.lang.Object
-
main
public static void main(java.lang.String[] args)
-