Class tjh2dVector

java.lang.Object
  |
  +--tjh2dVector

public class tjh2dVector
extends java.lang.Object

A simple class that manages a 2D location/vector in space given floats x and y.


Field Summary
 float x
          the coordinates of the location/vector
 float y
          the coordinates of the location/vector
 
Constructor Summary
tjh2dVector()
          default constructor
tjh2dVector(float a, float b)
          initializing constructor
 
Method Summary
 float Angle()
          returns the angle of the vector anticlockwise from the +ve x-axis
static tjh2dVector Cartesian(float degrees)
          return the unit vector with the correct angle anti-clockwise from the +ve x-axis
static float DotProduct(tjh2dVector a, tjh2dVector b)
          returns the dot product of the two vectors
 float Length()
          returns the length of the vector
static tjh2dVector minus(tjh2dVector a, tjh2dVector b)
          subtracts b from a, returns the result
static tjh2dVector mult(tjh2dVector a, float f)
          multiplies the vector a by the scalar f, returns the result
 tjh2dVector Normalize()
          changes the length of the vector to one
 tjh2dVector Perp()
          replaces this vector with its left-hand perpendicular
 void RotateAround(tjh2dVector c, float deg)
          rotates this point by deg degrees around the point c
static tjh2dVector sum(tjh2dVector a, tjh2dVector b)
          adds the two vectors together, returns the result
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

x

public float x
the coordinates of the location/vector

y

public float y
the coordinates of the location/vector
Constructor Detail

tjh2dVector

public tjh2dVector()
default constructor

tjh2dVector

public tjh2dVector(float a,
                   float b)
initializing constructor
Method Detail

DotProduct

public static float DotProduct(tjh2dVector a,
                               tjh2dVector b)
returns the dot product of the two vectors

RotateAround

public void RotateAround(tjh2dVector c,
                         float deg)
rotates this point by deg degrees around the point c

Perp

public tjh2dVector Perp()
replaces this vector with its left-hand perpendicular

Normalize

public tjh2dVector Normalize()
changes the length of the vector to one

Length

public float Length()
returns the length of the vector

Cartesian

public static tjh2dVector Cartesian(float degrees)
return the unit vector with the correct angle anti-clockwise from the +ve x-axis

Angle

public float Angle()
returns the angle of the vector anticlockwise from the +ve x-axis

sum

public static tjh2dVector sum(tjh2dVector a,
                              tjh2dVector b)
adds the two vectors together, returns the result

minus

public static tjh2dVector minus(tjh2dVector a,
                                tjh2dVector b)
subtracts b from a, returns the result

mult

public static tjh2dVector mult(tjh2dVector a,
                               float f)
multiplies the vector a by the scalar f, returns the result