Class Vector

java.lang.Object
  |
  +--Vector

public class Vector
extends java.lang.Object


Constructor Summary
Vector()
          Empty constructor
Vector(double x, double y)
          Constructor with two parameters viz.
Vector(double x1, double y1, double x2, double y2)
          Constructor with four parameters viz.
 
Method Summary
 Vector addVector(Vector operand)
          Add two vectors
 double dotProduct(Vector operand)
          Get dot product of two vectors
 double getMagnitude()
          Get the magnitude
 Vector getNormal()
          Get the normal vector
 double getX()
          Get x component of the vector
 double getY()
          Get y component of the vector
 boolean isEqual(Vector vec)
          Check if the two vectors are equal in magnitude and return result
 Vector multiply(double k)
          Multiply two vectors
 Vector rotateVector(double theta)
          Rotate a vector by a given angle
 void setVector(Vector vec)
          Set the x and y components of the vector
 void setX(double x)
          Set x component of the vector
 void setY(double y)
          Set y component of the vector
 Vector subtractVector(Vector operand)
          Subtract two vectors
 Vector unitVector()
          Get the unit vector of the given vector
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Vector

public Vector()
Empty constructor

Vector

public Vector(double x,
              double y)
Constructor with two parameters viz. the x and y components of the vector

Vector

public Vector(double x1,
              double y1,
              double x2,
              double y2)
Constructor with four parameters viz. two sets of x and y components
Method Detail

setVector

public void setVector(Vector vec)
Set the x and y components of the vector

isEqual

public boolean isEqual(Vector vec)
Check if the two vectors are equal in magnitude and return result

addVector

public Vector addVector(Vector operand)
Add two vectors

subtractVector

public Vector subtractVector(Vector operand)
Subtract two vectors

multiply

public Vector multiply(double k)
Multiply two vectors

dotProduct

public double dotProduct(Vector operand)
Get dot product of two vectors

getX

public double getX()
Get x component of the vector

setX

public void setX(double x)
Set x component of the vector

getY

public double getY()
Get y component of the vector

setY

public void setY(double y)
Set y component of the vector

rotateVector

public Vector rotateVector(double theta)
Rotate a vector by a given angle

getNormal

public Vector getNormal()
Get the normal vector

getMagnitude

public double getMagnitude()
Get the magnitude

unitVector

public Vector unitVector()
Get the unit vector of the given vector