net.aerith.misao.util
Class Position

java.lang.Object
  |
  +--net.aerith.misao.util.Position
Direct Known Subclasses:
StarPosition, TriangleMatchingSolver.TrianglePosition, XmlData.StarPosition

public class Position
extends java.lang.Object

The Position represents a position which consists of (x,y) position. The position is expressed in float data.


Field Summary
protected  float x
          The x value.
protected  float y
          The y value.
 
Constructor Summary
Position()
          Constructs an empty Position.
Position(double initial_x, double initial_y)
          Constructs a Position with specified position.
Position(Position source_position)
          Constructs a Position by copy.
 
Method Summary
 void add(Position position)
          Adds the specified Position to this.
 double getDistanceFrom(Position position)
          Gets the distance from the specified position.
 double getPositionAngleTo(Position position)
          Gets the position angle from this position to the specified position.
 double getX()
          Gets the x value.
 double getY()
          Gets the y value.
protected  java.lang.String paramString()
          Returns a raw string representation of the state of this object, for debugging use.
 void rescale(double ratio)
          Rescales the position by magnifying the specified value.
 void setPosition(Position new_position)
          Sets the position.
 void setX(double new_x)
          Sets the x value.
 void setY(double new_y)
          Sets the y value.
 java.lang.String toString()
          Returns a string representation of the state of this object, for debugging use.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

x

protected float x
The x value.

y

protected float y
The y value.
Constructor Detail

Position

public Position()
Constructs an empty Position. The position is set at (0,0).

Position

public Position(double initial_x,
                double initial_y)
Constructs a Position with specified position.
Parameters:
initial_x - the x position.
initial_y - the y position.

Position

public Position(Position source_position)
Constructs a Position by copy.
Parameters:
source_position - the source position to copy.
Method Detail

getX

public double getX()
Gets the x value.
Returns:
the x value.

setX

public void setX(double new_x)
Sets the x value.
Parameters:
new_x - the new x value.

getY

public double getY()
Gets the y value.
Returns:
the y value.

setY

public void setY(double new_y)
Sets the y value.
Parameters:
new_y - the new y value.

setPosition

public void setPosition(Position new_position)
Sets the position.
Parameters:
new_position - the new position.

add

public void add(Position position)
Adds the specified Position to this.
Parameters:
position - the value to add.

rescale

public void rescale(double ratio)
Rescales the position by magnifying the specified value.
Parameters:
ratio - the value to magnify.

getDistanceFrom

public double getDistanceFrom(Position position)
Gets the distance from the specified position.
Parameters:
position - the position.
Returns:
the distance from the specified position.

getPositionAngleTo

public double getPositionAngleTo(Position position)
Gets the position angle from this position to the specified position. The 0 degree is in the direction of x axis, 90 degree is in the direction of y axis.
Parameters:
position - the position.
Returns:
the position angle.

paramString

protected java.lang.String paramString()
Returns a raw string representation of the state of this object, for debugging use. It should be invoked from toString method of the subclasses.
Returns:
a string representation of the state of this object.

toString

public java.lang.String toString()
Returns a string representation of the state of this object, for debugging use.
Overrides:
toString in class java.lang.Object
Returns:
a string representation of the state of this object.