public class Point
extends java.lang.Object
Constructor and Description |
---|
Point(double[] coords)
Creates a new point from an array.
|
Point(double x,
double y)
Creates a new point with the given coordinates.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Point other) |
int |
getAngleTo(Point other)
Gets the absolute angle between this and another Point in space.
|
Point |
getClosestMappedPoint(Point other,
int width,
int height)
Maps the other point across world boundaries to return the closest form of the given point.
|
double |
getDistanceTo(Point other)
Gets the distance from this to another Point in space using the
standard distance formula.
|
Point |
getPointAt(double angle,
double distance)
Returns a new point which represents the location at the given angle and distance away from this point.
|
double |
getX()
Gets the x-coordinate of this point.
|
double |
getY()
Gets the y-coordinate of this point.
|
boolean |
isCloseTo(Point other,
double tolerance)
Returns true if the given point's X & Y values are within the tolerance of this point's X & Y values.
|
boolean |
isInEllipse(Point center,
int major,
int minor,
int orientation)
Checks if this point is in an Ellipse with the given center point, major/minor axis lengths at the given orientation.
|
java.lang.String |
toString() |
public Point(double x, double y)
x
- the x-coordinatey
- the y-coordinatepublic Point(double[] coords)
coords
- the coordinates of the pointpublic double getX()
public double getY()
public double getDistanceTo(Point other)
other
- the location to which to calculate the distancepublic int getAngleTo(Point other)
To determine the amount of rotation necessary to face the argument,
a ship's current orientation
should be subtracted from the result
of this method.
other
- the location to which to calculate the anglepublic Point getPointAt(double angle, double distance)
angle
- from due east (0 degrees)distance
- from this pointpublic boolean isInEllipse(Point center, int major, int minor, int orientation)
center
- of the ellipsemajor
- axis lengthminor
- axis lengthorientation
- angle of the major axispublic Point getClosestMappedPoint(Point other, int width, int height)
other
- point to map from this onewidth
- of the worldheight
- of the worldpublic boolean isCloseTo(Point other, double tolerance)
other
- location to test againsttolerance
- amount to test in range againstpublic java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(Point other)