netwar.utils
Class Point2D

java.lang.Object
  |
  +--netwar.utils.Point2D

public class Point2D
extends java.lang.Object

This class is used to represent a location or vector in screenspace. Although the structure holds two floats, you will generally call the getInt functions to get the integers because screenspace is in pixels. A Point2D can be translated into a Point3D with z = 0.

Author:
Kyle Kakligian

Field Summary
 float x
          X-axis value or length.
 float y
          Y-axis value or length.
 
Constructor Summary
Point2D()
          Constructs a Point2D at the orgin.
Point2D(float X, float Y)
          Constructs a Point2D at the given point.
Point2D(Point2D p)
          Constructs a Point2D at the given point.
 
Method Summary
 int getIntx()
          This method is a shortcut to Math.round(x) which returns an integer.
 int getInty()
          This method is a shortcut to Math.round(y) which returns an integer.
 double getLength()
          Returns the distance from the point to the orgin.
 Point2D getProduct(float scalar)
          Returns a new Point2D that is the scalar product of this one.
 Point2D getSum(Point2D p)
          Returns a new Point2D that is the sum of this one, and the given vector.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

x

public float x
X-axis value or length.

y

public float y
Y-axis value or length.
Constructor Detail

Point2D

public Point2D()
Constructs a Point2D at the orgin.

Point2D

public Point2D(float X,
               float Y)
Constructs a Point2D at the given point.
Parameters:
X - X-axis value or length.
Y - Y-axis value or length.

Point2D

public Point2D(Point2D p)
Constructs a Point2D at the given point.
Parameters:
p - Copy.
Method Detail

getProduct

public Point2D getProduct(float scalar)
Returns a new Point2D that is the scalar product of this one.
Parameters:
scalar - Multiplier
Returns:
A new Point2D.

getSum

public Point2D getSum(Point2D p)
Returns a new Point2D that is the sum of this one, and the given vector.
Parameters:
p - Vector
Returns:
Returns a new Point2D.

getLength

public double getLength()
Returns the distance from the point to the orgin. (Or the vector length.)
Returns:
Distance to orgin.

getIntx

public int getIntx()
This method is a shortcut to Math.round(x) which returns an integer.
Returns:
Returns x as an integer.

getInty

public int getInty()
This method is a shortcut to Math.round(y) which returns an integer.
Returns:
Returns y as an integer.