|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object math.geom2d.Vector2D
public class Vector2D
A vector in the 2D plane. Provides methods to compute cross product and dot product, addition and subtraction of vectors.
Constructor Summary | |
---|---|
Vector2D()
Constructs a new Vectors initialized with x=1 and y=0. |
|
Vector2D(double x,
double y)
Constructs a new vector with the given coordinates. |
|
Vector2D(Point2D point)
Constructs a new vector between the origin and the given point. |
|
Vector2D(Point2D point1,
Point2D point2)
Constructs a new vector between two points |
Method Summary | |
---|---|
boolean |
almostEquals(GeometricObject2D obj,
double eps)
Test whether this object is the same as another vector, with respect to a given threshold. |
double |
angle()
Returns the angle with the horizontal axis, in radians. |
Vector2D |
clone()
|
static Vector2D |
create(double x,
double y)
Deprecated. since 0.11.1 |
static Vector2D |
create(Point2D point)
Deprecated. since 0.11.1 |
static Vector2D |
createPolar(double rho,
double theta)
Creates a new vector by specifying the distance to the origin, and the angle with the horizontal. |
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 exactly the same as another vector. |
double |
getX()
Deprecated. replaces by x() (since 0.11.1) |
double |
getY()
Deprecated. replaces by y() (since 0.11.1) |
boolean |
isColinear(Vector2D v)
test if the two vectors are colinear |
static boolean |
isColinear(Vector2D v1,
Vector2D v2)
Tests if the two vectors are colinear |
boolean |
isOrthogonal(Vector2D v)
test if the two vectors are orthogonal |
static boolean |
isOrthogonal(Vector2D v1,
Vector2D v2)
Tests if the two vectors are orthogonal |
Vector2D |
minus(Vector2D v)
Returns the subtraction of current vector with vector given as parameter. |
double |
norm()
Computes the norm of the vector |
Vector2D |
normalize()
Returns the vector with same direction as this one, but with norm equal to 1. |
Vector2D |
opposite()
Returns the opposite vector v2 of this, such that the sum of this and v2 equals the null vector. |
Vector2D |
plus(Vector2D v)
Returns the sum of current vector with vector given as parameter. |
Vector2D |
rotate(double theta)
Rotates the vector by the given angle. |
Vector2D |
times(double k)
Multiplies the vector by a scalar amount. |
java.lang.String |
toString()
Display the coordinates of the vector. |
Vector2D |
transform(AffineTransform2D trans)
Transform the vector, by using only the first 4 parameters of the transform. |
double |
x()
Returns the x coordinates of this vector. |
double |
y()
Returns the y coordinates of this vector. |
Methods inherited from class java.lang.Object |
---|
getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Vector2D()
public Vector2D(double x, double y)
public Vector2D(Point2D point)
public Vector2D(Point2D point1, Point2D point2)
Method Detail |
---|
@Deprecated public static Vector2D create(double x, double y)
@Deprecated public static Vector2D create(Point2D point)
public static Vector2D createPolar(double rho, double theta)
public static 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 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 boolean isColinear(Vector2D v1, Vector2D v2)
public static boolean isOrthogonal(Vector2D v1, Vector2D v2)
public double x()
@Deprecated public double getX()
public double y()
@Deprecated public double getY()
public Vector2D opposite()
this
.public double norm()
public double angle()
public Vector2D normalize()
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 times(double k)
k
- the scale factor
public Vector2D rotate(double theta)
theta
- the angle of rotation, in radians counter-clockwisepublic Vector2D transform(AffineTransform2D trans)
trans
- an affine transform
public boolean almostEquals(GeometricObject2D obj, double eps)
almostEquals
in interface GeometricObject2D
obj
- the object to compareeps
- a threshold value, for example the minimal coordinate difference
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
almostEquals(math.geom2d.GeometricObject2D, double)
public java.lang.String toString()
x=3 y=4
.
toString
in class java.lang.Object
public Vector2D clone()
clone
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |