|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectjava.awt.geom.Point2D
java.awt.geom.Point2D.Double
fang.Location2D
public class Location2D
This class represents an (x, y) coordinate within some space. Both
coordinates are double values so they can hold fractional parts. In
FANG, Location2D is used to represent points on the screen (where
coordinates go from 0.0 to 1.0). They can also be used to hold velocities and
other two-dimensional vectors.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.awt.geom.Point2D |
|---|
Point2D.Double, Point2D.Float |
| Field Summary |
|---|
| Fields inherited from class java.awt.geom.Point2D.Double |
|---|
x, y |
| Constructor Summary | |
|---|---|
Location2D()
Creates a new Location2D instance at (0.0, 0.0). |
|
Location2D(double x,
double y)
Creates a new Location2D instance at (x, y). |
|
Location2D(Location2D original)
Creates a new Location2D instance that is a copy of the given
location. |
|
Location2D(Point2D point)
Creates a new Location2D instance with the same values as the given
point. |
|
| Method Summary | |
|---|---|
Location2D |
additiveInverse()
Calculate the additive inverse of this vector |
static double |
componentMagnitude(Location2D originalVector,
Location2D directionVector)
Determine the magnitude of originalVector in the direction of directionVector. |
static Location2D |
componentVector(Location2D originalVector,
Location2D directionVector)
Return the projection of originalVector onto directionVector; this is a vector. |
Location2D |
difference(Location2D other)
Calculate the difference of this vector and the other vector. |
double |
distance(double x,
double y)
Return the Euclidian distance from this location to the location (x, y). |
double |
distance(Location2D other)
Return the Euclidian distance from this location to the given location. |
double |
distance(Sprite sprite)
Return the Euclidian distance from this location to the location of the sprite. |
double |
dotProduct(Location2D other)
Calculate the dot-product of this vector with the given other vector. |
double |
getX()
Get the x-coordinate of this location. |
double |
getY()
Get the y-coodinate of this location |
boolean |
intersects(Box2D box)
Determine whether this location and the given box coincide. |
boolean |
intersects(Sprite sprite)
Determine whether this location and the sprite coincide. |
double |
magnitude()
Calculate the magnitude (or length) of this vector. |
Location2D |
norm()
Return a normalized vector in the same direction as this vector. |
double |
radians()
Calculate the rotation of this vector around the origin. |
void |
setX(double x)
Set the x-coordinate of this location. |
void |
setY(double y)
Set the y-coordinate of this location. |
Location2D |
sum(Location2D other)
Calculate the sum of this vector and the other vector. |
String |
toString()
|
| Methods inherited from class java.awt.geom.Point2D.Double |
|---|
setLocation |
| Methods inherited from class java.awt.geom.Point2D |
|---|
clone, distance, distance, distanceSq, distanceSq, distanceSq, equals, hashCode, setLocation |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Location2D()
Location2D instance at (0.0, 0.0).
public Location2D(double x,
double y)
Location2D instance at (x, y).
x - the x-coordinate of the locationy - the y-coordinate of the locationpublic Location2D(Location2D original)
Location2D instance that is a copy of the given
location.
original - the original location this is to copypublic Location2D(Point2D point)
Location2D instance with the same values as the given
point.
point - the point this location is to copy| Method Detail |
|---|
public double distance(double x,
double y)
distance in class Point2Dx - x-coordinate of the location to measure distance toy - y-coordinate of the location to measure distance to return
distance (in screens) between this location and the location
(x, y)public double distance(Location2D other)
other - location to measure the distance to
otherpublic double distance(Sprite sprite)
sprite - the Sprite from which the distance of
this location is to be measured
public double getX()
getX in class Point2D.Doublepublic double getY()
getY in class Point2D.Doublepublic boolean intersects(Box2D box)
box - the Box2D to check this location
against
true if the location is within the
Box2D, false otherwisepublic boolean intersects(Sprite sprite)
sprite - the Sprite to check this location against
true if the location is within the
Sprite, false otherwisepublic void setX(double x)
x - the new x-coordinate for this locationpublic void setY(double y)
y - the new y-coordinate for this locationpublic String toString()
toString in class Point2D.Doublepublic double dotProduct(Location2D other)
other - Location2D as vector representing value for which we want the dot product
public double magnitude()
public Location2D norm()
public Location2D sum(Location2D other)
other - the vector to add to this vector
public Location2D difference(Location2D other)
other - the vector to subtract from this vector
public Location2D additiveInverse()
public double radians()
public static double componentMagnitude(Location2D originalVector,
Location2D directionVector)
originalVector - the vector (in x, y basis) to be projected into the directionVectordirectionVector - the vector onto which the original vector should be projected
public static Location2D componentVector(Location2D originalVector,
Location2D directionVector)
originalVector - the vector (in x, y basis) to be projected onto the directionVectordirectionVector - the vector onto which the originalVector should be projected
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||