|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcdx.Vector2d
public final class Vector2d
The Vector2d
class implements a 2-dimensional vector that
can represent the position or velocity of an object within a 2D space.
This implementation uses public, non-final fields to avoid as much object
creation as possible. Java does not have value types per se, but these
vector classes are the closest thing that is possible.
Field Summary | |
---|---|
float |
x
Fields for the x and y coordinates of the vector. |
float |
y
Fields for the x and y coordinates of the vector. |
Constructor Summary | |
---|---|
Vector2d()
The default constructor for the Vector2d class returns an
object representing the zero vector. |
|
Vector2d(float x,
float y)
The main constructor for the Vector2d class takes the two
coordinates as parameters and produces an object representing that vector. |
|
Vector2d(Vector2d v)
The secondary constructor for the Vector2d class takes a
vector to copy into this new instance and returns an instance that
represents a copy of that vector. |
Method Summary | |
---|---|
boolean |
equals(java.lang.Object o)
Check for equality of two Vector2d objects |
boolean |
equals(Vector2d b)
Check for equality of two Vector2d objects |
int |
hashCode()
The hashfuction for Vector2d |
void |
set(float x,
float y)
The set method is basically a convenience method that sets
the internal values of the coordinates. |
void |
set(Vector2d v)
The set method is basically a convenience method that sets
the internal values of the coordinates copying them from another vector. |
java.lang.String |
toString()
Convert a Vector2d to a string |
void |
zero()
The zero method is a convenience method to zero the
coordinates of the vector. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public float x
public float y
Constructor Detail |
---|
public Vector2d()
Vector2d
class returns an
object representing the zero vector.
public Vector2d(float x, float y)
Vector2d
class takes the two
coordinates as parameters and produces an object representing that vector.
x
- the coordinate on the x (east-west) axisy
- the coordinate on the y (north-south) axispublic Vector2d(Vector2d v)
Vector2d
class takes a
vector to copy into this new instance and returns an instance that
represents a copy of that vector.
v
- the vector to copy into this new instanceMethod Detail |
---|
public void set(float x, float y)
set
method is basically a convenience method that sets
the internal values of the coordinates.
x
- the coordinate on the x (east-west) axisy
- the coordinate on the y (north-south) axispublic void set(Vector2d v)
set
method is basically a convenience method that sets
the internal values of the coordinates copying them from another vector.
v
- the coordinate on the x and y axis as a Vecter2dpublic void zero()
zero
method is a convenience method to zero the
coordinates of the vector.
public boolean equals(java.lang.Object o) throws java.lang.ClassCastException
equals
in class java.lang.Object
java.lang.ClassCastException
public boolean equals(Vector2d b)
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |