koala
Class KoalaVector
java.lang.Object
koala.KoalaVector
public class KoalaVector
- extends java.lang.Object
Represents a 2D vector, which is a line with magnitude and direction. Class essentially
exists to encapsulate the all-pervasive vector calculations. The geometric convention at
work here is that +x is to the right, +y is to the top, and +direction is anti-clockwise
(the usual convention). Angles are in degrees.
Field Summary |
double |
x
|
double |
y
|
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
x
public double x
y
public double y
KoalaVector
public KoalaVector(double x,
double y)
createFromMagAndDir
public static KoalaVector createFromMagAndDir(double magnitude,
double direction)
direction
public int direction()
magnitude
public double magnitude()
add
public KoalaVector add(KoalaVector v)
subtract
public KoalaVector subtract(KoalaVector v)
normalise
public void normalise()
scale
public void scale(double s)
integerX
public int integerX()
integerY
public int integerY()
equals
public boolean equals(java.lang.Object ob)
- Overrides:
equals
in class java.lang.Object
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
main
public static void main(java.lang.String[] args)