|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectmath.geom2d.Vector2D
public class Vector2D
Define a vector in 2 Dimensions. Provides methods to compute cross product and dot product, addition and subtraction of vectors.
| Field Summary | |
|---|---|
protected double |
dx
|
protected double |
dy
|
| Constructor Summary | |
|---|---|
Vector2D()
construct a new Vectors initialized with dx=1 and dy=0. |
|
Vector2D(double dx,
double dy)
constructor with given position. |
|
Vector2D(java.awt.geom.Point2D point)
construct a new vector between origin and the point. |
|
Vector2D(java.awt.geom.Point2D point1,
java.awt.geom.Point2D point2)
construct a new vector between two points |
|
| Method Summary | |
|---|---|
static Vector2D |
createPolar(double rho,
double theta)
|
double |
cross(Vector2D v)
Get the cross product with point p. |
static double |
cross(Vector2D v1,
Vector2D v2)
get the cross product of the two vectors, defined by : dx1*dy2 - dx2*dy1
cross product is zero for colinear vectors. |
double |
dot(Vector2D v)
Get the dot product with point p. |
static double |
dot(Vector2D v1,
Vector2D v2)
Get the dot product of the two vectors, defined by : dx1*dy2 + dx2*dy1
Dot product is zero if the vectors defined by the 2 vectors are
orthogonal. |
boolean |
equals(java.lang.Object obj)
Test whether this object is the same as another vector. |
double |
getAngle()
Returns the angle with the horizontal axis, in radians. |
double |
getDx()
|
double |
getDy()
|
double |
getNorm()
Computes the norm of the vector |
Vector2D |
getNormalizedVector()
Returns the vector with same direction as this one, but with norm equal to 1. |
Vector2D |
getOpposite()
Returns the opposite vector v2 of this, such that the sum of this and v2 equals the null vector. |
boolean |
isColinear(Vector2D v)
test if the two vectors are colinear |
static boolean |
isColinear(Vector2D v1,
Vector2D v2)
test if the two vectors are colinear |
boolean |
isOrthogonal(Vector2D v)
test if the two vectors are orthogonal |
static boolean |
isOrthogonal(Vector2D v1,
Vector2D v2)
test if the two vectors are orthogonal |
Vector2D |
minus(Vector2D v)
Return the subtraction of current vector with vector given as parameter. |
void |
normalize()
Normalizes the vector, such that its norms becomes 1. |
Vector2D |
plus(Vector2D v)
Return the sum of current vector with vector given as parameter. |
void |
setAsPolar(double rho,
double theta)
Set location specified as polar coordinate : distance from origin + angle with horizontal. |
void |
setDx(double dx)
|
void |
setDy(double dy)
|
void |
setVector(double dx,
double dy)
|
Vector2D |
transform(AffineTransform2D trans)
Transform the vector, by using only the first 4 parameters of the transform. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected double dx
protected double dy
| Constructor Detail |
|---|
public Vector2D()
public Vector2D(java.awt.geom.Point2D point)
public Vector2D(java.awt.geom.Point2D point1,
java.awt.geom.Point2D point2)
public Vector2D(double dx,
double dy)
| Method Detail |
|---|
public static final Vector2D createPolar(double rho,
double theta)
public static final double dot(Vector2D v1,
Vector2D v2)
dx1*dy2 + dx2*dy1
Dot product is zero if the vectors defined by the 2 vectors are orthogonal. It is positive if vectors are in the same direction, and negative if they are in opposite direction.
public static final double cross(Vector2D v1,
Vector2D v2)
dx1*dy2 - dx2*dy1
cross product is zero for colinear vectors. It is positive if angle between vector 1 and vector 2 is comprised between 0 and PI, and negative otherwise.
public static final boolean isColinear(Vector2D v1,
Vector2D v2)
public static final boolean isOrthogonal(Vector2D v1,
Vector2D v2)
public double getDx()
public double getDy()
public void setDx(double dx)
public void setDy(double dy)
public void setVector(double dx,
double dy)
public void setAsPolar(double rho,
double theta)
public Vector2D getOpposite()
this.public double getNorm()
public double getAngle()
public void normalize()
public Vector2D getNormalizedVector()
public boolean isColinear(Vector2D v)
public boolean isOrthogonal(Vector2D v)
public double dot(Vector2D v)
p.
Dot product id defined by :
x1*y2 + x2*y1
Dot product is zero if the vectors defined by the 2 points are orthogonal. It is positive if vectors are in the same direction, and negative if they are in opposite direction.
public double cross(Vector2D v)
p. Cross product is
defined by :
x1*y2 - x2*y1
cross product is zero for colinear vector. It is positive if angle between vector 1 and vector 2 is comprised between 0 and PI, and negative otherwise.
public Vector2D plus(Vector2D v)
public Vector2D minus(Vector2D v)
public Vector2D transform(AffineTransform2D trans)
trans - an affine transform
public boolean equals(java.lang.Object obj)
equals in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||