|
||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||
java.lang.Object | +--Vector2D
Represents a vector containing two components.
All of the methods execpt for setX(),
setY() and set() will
leave the vector unchanged; the result will be returned rather than
assigned. Although it is possible to modify the components, one
should bear in mind that other classes may store vectors, and may not
anticipate a change.
| Field Summary | |
protected double |
x
|
protected double |
y
|
| Constructor Summary | |
Vector2D()
Creates a new zero vector. |
|
Vector2D(double x,
double y)
Creates a new vector. |
|
| Method Summary | |
Vector2D |
add(Vector2D v)
Adds the supplied vector to this one, and returns the result. |
double |
argument()
Returns the argument of this vector (radians widdershins from (1,0)). |
double |
getX()
|
double |
getY()
|
boolean |
isNaN()
Returns true if either of the components are
NaNs, else false |
double |
modulus()
Returns the modulus of this vector. |
double |
modulusSquared()
Returns the square of the modulus of this vector. |
Vector2D |
multiply(double d)
Multiplies this vector by the supplied constant, and returns the result. |
double |
scalarProduct(Vector2D v)
Returns the scalar product of the supplied vector with the this one. |
void |
set(double x,
double y)
Sets both components of this vector. |
void |
setX(double x)
|
void |
setY(double y)
|
Vector2D |
subtract(Vector2D v)
Subtracts the supplied vector from this one, and returns the result. |
Vector2D |
unitVector()
Returns a vector with modulus 1, and the same argument as this vector. |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
protected double x
protected double y
| Constructor Detail |
public Vector2D(double x,
double y)
x - The 'x' componenty - The 'y' componentpublic Vector2D()
| Method Detail |
public Vector2D add(Vector2D v)
public Vector2D subtract(Vector2D v)
public Vector2D multiply(double d)
public double scalarProduct(Vector2D v)
public double modulus()
public double modulusSquared()
public double argument()
public Vector2D unitVector()
public double getX()
public double getY()
public void setX(double x)
public void setY(double y)
public void set(double x,
double y)
x - The new 'x' componenty - The new 'y' componentpublic boolean isNaN()
true if either of the components are
NaNs, else false
|
||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||