|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcs2110.collision.Vector2D
public class Vector2D
A 2D vector with components of double precision. We also think of this as a point on a 2D plane. Remark: This data structure can be used both for something that is conceptually a vector (e.g. a displacement vector) and for something that is conceptually a point on the plane (because a point can be identified with the vector from the origin to the point).
Field Summary | |
---|---|
double |
x
The first component of the vector. |
double |
y
The second component of the vector. |
Constructor Summary | |
---|---|
Vector2D(double x,
double y)
Constructor a Vector with components x and y. |
|
Vector2D(javax.vecmath.Point2d p)
Constructor: a copy of p. |
|
Vector2D(Vector2D p)
Constructor: A copy of p. |
Method Summary | |
---|---|
Vector2D |
add(Vector2D a)
Return the result of adding this vector to a. |
static Vector2D |
add(Vector2D a,
Vector2D b)
Return the result of adding a and b. |
void |
addOn(Vector2D v)
Add v to this vector. |
static double |
dist(Vector2D a,
Vector2D b)
Return the Euclidean distance between a and b. |
Vector2D |
minus(Vector2D b)
Subtract b from this vector. |
java.lang.String |
toString()
Return a representation (x, y) of this instance. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public double x
public double y
Constructor Detail |
---|
public Vector2D(Vector2D p)
p
- A vector.public Vector2D(javax.vecmath.Point2d p)
p
- A Point2d object from the javax.vecmath package.public Vector2D(double x, double y)
x
- First component of vector.y
- Second component of vector.Method Detail |
---|
public java.lang.String toString()
toString
in class java.lang.Object
public Vector2D add(Vector2D a)
a
- A vector.
public static Vector2D add(Vector2D a, Vector2D b)
a
- A vector.b
- A vector.
public static double dist(Vector2D a, Vector2D b)
a
- A vector (point).b
- A vector (point).
public void addOn(Vector2D v)
v
- Vector to add on to this vector.public Vector2D minus(Vector2D b)
b
- A Vector.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |