|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.vodafone.v10.util.Vector2D
Vector2D is a class providing functions for 2D vector operations. A Vector2D instance holds each of the vector elements as FixedPoint instances. The following functions are provided:
Constructor Summary | |
Vector2D()
Vector2D constructor. |
|
Vector2D(FixedPoint x,
FixedPoint y)
Vector2D constructor. |
|
Vector2D(int x,
int y)
Vector2D constructor. |
Method Summary | |
void |
add(int x,
int y)
Performs addition. |
void |
add(Vector2D vector)
Performs addition. |
Vector2D |
clone()
Clones an object. |
FixedPoint |
getX()
Gets a vector value along its x axis. |
FixedPoint |
getY()
Gets a vector value along its y axis. |
static FixedPoint |
innerProduct(Vector2D v1,
Vector2D v2)
Calculates an inner product. |
void |
normalize()
Normalizes a vector. |
static FixedPoint |
outerProduct(Vector2D v1,
Vector2D v2)
Calculates an outer product. |
void |
setValue(FixedPoint x,
FixedPoint y)
Sets new vector values. |
void |
setValue(int x,
int y)
Sets new vector values. |
void |
subtract(int x,
int y)
Performs subtraction. |
void |
subtract(Vector2D vector)
Performs subtraction. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Vector2D(FixedPoint x, FixedPoint y)
Vector2D constructor.
Holds as vector elements the coordinates designated in the parameters.
x
- X coordinatey
- Y coordinatepublic Vector2D(int x, int y)
Vector2D constructor.
Holds as vector elements the coordinates designated in the parameters.
x
- X coordinatey
- Y coordinatepublic Vector2D()
Vector2D constructor.
The x,y coordinates of the held vector are 0,0.
Method Detail |
public void add(Vector2D vector)
Performs addition.
Adds the vector designated in the parameter.
vector
- The vector to be added.NullPointerException
- if vector is null.public void add(int x, int y)
Performs addition.
Adds the vector designated in the parameters.
x
- Value along its x axis of the vector to be addedy
- Value along its y axis of the vector to be addedpublic void subtract(Vector2D vector)
Performs subtraction.
Subtracts the vector designated in the parameter.
vector
- The vector to be subtractedNullPointerException
- if vector is null.public void subtract(int x, int y)
Performs subtraction.
Subtracts the vector designated in the parameters.
x
- Value along its x axis of the vector to be subtractedy
- Value along its y axis of the vector to be subtractedpublic void normalize()
public static FixedPoint innerProduct(Vector2D v1, Vector2D v2)
Calculates an inner product.
Calculates and returns the inner product of the two Vector2D objects designated in the parameters.
v1
- Vector 1v2
- Vector 2NullPointerException
- if v1 or v2 is null.public static FixedPoint outerProduct(Vector2D v1, Vector2D v2)
Calculates an outer product.
Calculates and returns the outer product of the two Vector2D objects designated in the parameters.
v1
- Vector 1v2
- Vector 2NullPointerException
- if v1 or v2 is null.public void setValue(int x, int y)
x
- Vector value along its x axisy
- Vector value along its y axispublic void setValue(FixedPoint x, FixedPoint y)
x
- Vector value along its x axisy
- Vector value along its y axisNullPointerException
- if x or y is null.public FixedPoint getX()
public FixedPoint getY()
public Vector2D clone()
Clones an object.
Creates an object with the same contents.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |