|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--universe.common.database.Coord
Encapsulates a cartesian three-space coordinate. Note that this class intentionally limits the precision of coordinates to the hundreth's position in order to simplify intersection and coincidence testing.
This class is used in many other classes within Universe and should only be altered carefully.
GalaxyBase
,
Serialized FormField Summary | |
static int |
ALPHA_QUADRANT
|
static int |
BETA_QUADRANT
|
static int |
DELTA_QUADRANT
|
static int |
GAMMA_QUADRANT
|
private static java.text.NumberFormat |
ourNumberFormat
|
private static java.util.Random |
ourRandGen
|
private static Coord |
ourZero
|
private float |
x
|
private float |
y
|
private float |
z
|
Constructor Summary | |
Coord()
This constructor returns a new instance of the coordinate (0, 0, 0). |
|
Coord(Coord src)
This constructor returns an exact copy of the supplied object. |
|
Coord(float in_x,
float in_y,
float in_z)
The designated constructor; returns a new instance with the given 3-space cartesian coordinates. |
Method Summary | |
java.lang.Object |
clone()
Returns an exact copy of this object. |
float |
distance(Coord other)
Computes and returns the distance between two coords. |
boolean |
equals(java.lang.Object obj)
This method returns true if the given object is a coordinate equivalent to the receiver and false otherwise. |
float |
getComponent(int index)
Returns a single component for the coordinate, as indicated by the supplied index (0=x, 1=y, all others=z). |
int |
getQuadrant()
This method returns the quadrant of the receiving coordinate relative to 0,0,0. |
float |
getX()
Returns the x component of the coordinate. |
float |
getY()
Returns the y component of the coordinate. |
float |
getZ()
Returns the z component of the coordinate. |
int |
hashCode()
This method returns a hash code value which can be used by Hashtable objects. |
boolean |
isInRange(Coord other,
float range)
Checks whether this coord is within a certain range of another |
Coord |
randomCoordInRadius(float maxRadius)
This method returns a new random coordinate up to the given radius from the receiver. |
Coord |
randomCoordInShell(float minRadius,
float maxRadius)
This method returns a new random coordinate within the shell around the receiver defined by the two given radii. |
Coord |
randomCoordInSpheroid(Coord axes)
This method returns a new random coordinate within the spheroid centered around the receiver and having axis lengths corresponding to the given coordinate. |
Coord |
set(float in_x,
float in_y,
float in_z)
This method sets the receiver's cartesian 3-space coordinates to the indicated values. |
Coord |
setX(float in_x)
Changes the x component of the coordinate. |
Coord |
setY(float in_y)
Changes the y component of the coordinate. |
Coord |
setZ(float in_z)
Changes the z component of the coordinate. |
java.lang.String |
toString()
This method returns a string equivalent to the coordinate using the format: x, y, z. |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int ALPHA_QUADRANT
public static final int BETA_QUADRANT
public static final int GAMMA_QUADRANT
public static final int DELTA_QUADRANT
private float x
private float y
private float z
private static java.util.Random ourRandGen
private static Coord ourZero
private static java.text.NumberFormat ourNumberFormat
Constructor Detail |
public Coord()
public Coord(Coord src)
src
- The coordinate to be copied.public Coord(float in_x, float in_y, float in_z)
Method Detail |
public java.lang.Object clone()
clone
in class java.lang.Object
public Coord set(float in_x, float in_y, float in_z)
public float getX()
public float getY()
public float getZ()
public float getComponent(int index)
index
- The index of the desired component.public Coord setX(float in_x)
public Coord setY(float in_y)
public Coord setZ(float in_z)
public int getQuadrant()
public float distance(Coord other)
public boolean isInRange(Coord other, float range)
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public Coord randomCoordInRadius(float maxRadius)
public Coord randomCoordInShell(float minRadius, float maxRadius)
minRadius
- The minimum distance the returned coordinate should be from the receiver.maxRadius
- The maximum distance the returned coordinate should be from the receiver.public Coord randomCoordInSpheroid(Coord axes)
axes
- Coord containing desired axial distances in each direction.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |