|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.tensegrity.graphics.Coordinate
This class represents a single point within a coordinate system and is not restricted to representing a fixed number of dimension components. Instances store its dimension components inside an integer array which can also be passed in a constructor.
There are several overloaded constructors from which to choose from.
As a result of the quick access requirement of Coordinate objects,
this class's internals are publicly visible. It is therefore recommended that
you declare a local variable when coding, as in the example shown below. This
should increase the probability that the internal component array will not be
accidentally corrupted!
Coordinate coordinate = anObject.getCoordinate(); final int[] components = coordinate.components; components[Coordinate.X_COMPONENT] = 100; components[Coordinate.Y_COMPONENT] = 100;
The component indices within the array are defined by X_COMPONENT,
Y_COMPONENT and Z_COMPONENT for 2D and 3D spaces.
| Field Summary | |
int[] |
components
instance variable for the single components of the coordinate |
static int |
X_COMPONENT
constant that tells about the indices of the coordinates components |
static int |
Y_COMPONENT
constant that tells about the indices of the coordinates components |
static int |
Z_COMPONENT
constant that tells about the indices of the coordinates components |
| Constructor Summary | |
Coordinate()
Default constructor for Coordinate that initializes it for
2D space. |
|
Coordinate(Coordinate coordinate)
Constructor for Coordinate with a Coordinate
given by coordinate to copy the components from. |
|
Coordinate(int dimensions)
Constructor for Coordinate with given number of dimensions. |
|
Coordinate(int[] components)
Constructor for Coordinate with array of components given
components for a non fixed number of dimensions. |
|
Coordinate(int x,
int y)
Constructor for Coordinate with given components for the
x axis and the y axis. |
|
Coordinate(int x,
int y,
int z)
Constructor for Coordinate with given components for the
x axis, the y axis and the z axis. |
|
| Method Summary | |
boolean |
equals(Coordinate c)
|
boolean |
equals(java.lang.Object other)
|
int |
getDimensions()
Returns the number of dimensions this Coordinate consist of. |
int |
getX()
Returns the X component of this coordinate |
int |
getY()
Returns the y component of this coordinate |
int |
getZ()
Returns the z component of this coordinate |
int |
hashCode()
|
void |
setX(int x)
Sets the x component of this coordinate |
void |
setY(int y)
Sets the y component of this coordinate |
void |
setZ(int z)
Sets the z component of this coordinate |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final int X_COMPONENT
public static final int Y_COMPONENT
public static final int Z_COMPONENT
public int[] components
| Constructor Detail |
public Coordinate()
Coordinate that initializes it for
2D space.
public Coordinate(int dimensions)
Coordinate with given number of dimensions.
dimensions - the number of dimensions for the new
Coordinate instance
public Coordinate(int x,
int y)
Coordinate with given components for the
x axis and the y axis.
x - the component for the location on the x axisy - the component for the location on the y axis
public Coordinate(int x,
int y,
int z)
Coordinate with given components for the
x axis, the y axis and the z axis.
x - the component for the location on the x axisy - the component for the location on the y axisz - the component for the location on the z axispublic Coordinate(int[] components)
Coordinate with array of components given
components for a non fixed number of dimensions.
components - the components array for the location on the different
axespublic Coordinate(Coordinate coordinate)
Coordinate with a Coordinate
given by coordinate to copy the components from.
coordinate - the Coordinate to copy the components from| Method Detail |
public int getDimensions()
Coordinate consist of.
public int getX()
public void setX(int x)
x - the new x component of this coordinatepublic int getY()
public void setY(int y)
y - the new y component for this coordinatepublic int getZ()
public void setZ(int z)
z - the new z component for this coordinatepublic boolean equals(java.lang.Object other)
public boolean equals(Coordinate c)
public int hashCode()
public java.lang.String toString()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||