Sim
Class Location

java.lang.Object
  extended by Sim.Location

public class Location
extends java.lang.Object

Location represents a Node's location in the World.


Constructor Summary
Location(double x, double y)
          Construct a new location object, given the x,y coordinates.
 
Method Summary
 Location add(Location other)
          Adds two location objects to one another.
 double getAngle(Location l1, Location l2)
          Find the angle of the triangle at this objects point using law of cosines.
 double getDistance(Location other)
          Get the distance between two points.
 double getQuadrance(Location other)
          Returns the square of the distance between two locations, or quadrance.
 int getSize()
          Returns the size of this Location as it is seralized on the network.
 double getX()
           
 double getY()
           
 Location mult(double scalar)
          Multiply the location by a scalar and return the new location object.
 Location sub(Location other)
          subtracts two location objects to one another.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Location

public Location(double x,
                double y)
Construct a new location object, given the x,y coordinates.

Parameters:
x -
y -
Method Detail

getX

public double getX()

getY

public double getY()

getQuadrance

public double getQuadrance(Location other)
Returns the square of the distance between two locations, or quadrance.

Parameters:
other - non-null other Location
Returns:
Quadrance of a line segment between this Location and other

getDistance

public double getDistance(Location other)
Get the distance between two points.

Parameters:
other - another location object to get the distance between
Returns:
distance between input and this.

mult

public Location mult(double scalar)
Multiply the location by a scalar and return the new location object.

Parameters:
scalar - number to multiple the x,y values by
Returns:
new location object with the changes

getAngle

public double getAngle(Location l1,
                       Location l2)
Find the angle of the triangle at this objects point using law of cosines.

Parameters:
l1 -
l2 -
Returns:

add

public Location add(Location other)
Adds two location objects to one another.

Parameters:
other - Object to add
Returns:
new location of addition of objects.

sub

public Location sub(Location other)
subtracts two location objects to one another.

Parameters:
other - Object to add
Returns:
new location of addition of objects.

getSize

public int getSize()
Returns the size of this Location as it is seralized on the network.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object