fi.utu.cs.physics
Class Point2

java.lang.Object
  |
  +--fi.utu.cs.physics.Tuple2
        |
        +--fi.utu.cs.physics.Point2
All Implemented Interfaces:
java.lang.Cloneable

public class Point2
extends Tuple2

A two-element point of double-precision floating point x, y coordinates.


Field Summary
static java.util.Comparator HORIZONTAL
          A comparator for the x coordinates of Point2 objects.
static Point2 ORIGIN
          The origin residing in the coordinates (0.0, 0.0).
static java.util.Comparator VERTICAL
          A comparator for the y coordinates of Point2 objects.
 
Constructor Summary
Point2(double x, double y)
          Creates a new two-element point with the given coordinates.
 
Method Summary
 void add(double x, double y)
          Adds values to the coordinates.
protected  void add(Point2 other)
          Adds the coordinates of other to the coordinates.
 double getX()
          Returns the x coordinate.
 double getY()
          Returns the y coordinate.
 void set(double x, double y)
          Sets the coordinates.
 void set(Point2 other)
          Sets the coordinates to the same values as in other.
 void setX(double x)
          Sets the x coordinate to x.
 void setY(double y)
          Sets the y coordinate to y.
 void transfer(Vector2 v)
          Transfers the coordinates according to the vector v.
 Vector2 vectorFrom(Point2 source)
          Creates and returns a vector that corresponds the transfer from the point source to this point.
 Vector2 vectorTo(Point2 target)
          Creates and returns a vector that corresponds the transfer from this point to the point target.
 
Methods inherited from class fi.utu.cs.physics.Tuple2
add, clone, equals, firstElementSign, getFirstElement, getSecondElement, hashCode, max, min, multiply, negate, negateFirstElement, negateSecondElement, secondElementSign, set, setFirstElement, setSecondElement, swap, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ORIGIN

public static final Point2 ORIGIN
The origin residing in the coordinates (0.0, 0.0).


HORIZONTAL

public static final java.util.Comparator HORIZONTAL
A comparator for the x coordinates of Point2 objects. The compare method returns a negative integer, zero, or a positive integer as the x coordinate of the first argument is less than, equal to, or greater than the x coordinate of the second.


VERTICAL

public static final java.util.Comparator VERTICAL
A comparator for the y coordinates of Point2 objects. The compare method returns a negative integer, zero, or a positive integer as the y coordinate of the first argument is less than, equal to, or greater than the y coordinate of the second.

Constructor Detail

Point2

public Point2(double x,
              double y)
Creates a new two-element point with the given coordinates.

Method Detail

getX

public double getX()
Returns the x coordinate.


getY

public double getY()
Returns the y coordinate.


setX

public void setX(double x)
Sets the x coordinate to x.


setY

public void setY(double y)
Sets the y coordinate to y.


set

public void set(double x,
                double y)
Sets the coordinates.

Overrides:
set in class Tuple2
Parameters:
x - The value of the x coordinate.
y - The value of the y coordinate.
See Also:
set(Point2)

set

public void set(Point2 other)
Sets the coordinates to the same values as in other.


add

public void add(double x,
                double y)
Adds values to the coordinates.

Overrides:
add in class Tuple2
Parameters:
x - The value added to the x coordinate.
y - The value added to the y coordinate.
See Also:
add(Point2)

add

protected void add(Point2 other)
Adds the coordinates of other to the coordinates.


transfer

public void transfer(Vector2 v)
Transfers the coordinates according to the vector v. After the transfer, getX() = this.getX() + v.getDeltaX() and getY() = this.getY() + v.getDeltaY().


vectorTo

public Vector2 vectorTo(Point2 target)
Creates and returns a vector that corresponds the transfer from this point to the point target. In the new vector, getDeltaX() = target.getX() - this.getX() and getDeltaY() = target.getY() - this.getY().

See Also:
vectorFrom(Point2), Vector2.Vector2(Point2,Point2)

vectorFrom

public Vector2 vectorFrom(Point2 source)
Creates and returns a vector that corresponds the transfer from the point source to this point. In the new vector, getDeltaX() = this.getX() - source.getX() and getDeltaY() = this.getY() - source.getY().

See Also:
vectorTo(Point2), Vector2.Vector2(Point2,Point2)