|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.kuka.nav.geometry.Vector2D
public final class Vector2D
Immutable representation of a 2-element vector consisting of x and
y elements. The class Vector2D represents a difference
vector, which describes the displacement between two 2D points. To quote
Murray, R. et al — A mathematical Introduction to Robotic
Manipulation, Section 3.1 the following propositions are hold:
Concerning transformations the following properties are enforced on vectors
of(double, double).
| Field Summary | |
|---|---|
static Vector2D |
UNIT_X
Immutable Vector2D instance representing the X unit vector. |
static Vector2D |
UNIT_Y
Immutable Vector2D instance representing the Y unit vector. |
static Vector2D |
ZERO
Immutable Vector2D instance representing a zero vector. |
| Constructor Summary | |
|---|---|
Vector2D(double x,
double y)
New instance of this class. |
|
Vector2D(com.kuka.math.geometry.Vector3D v)
Creates a new 2D vector from a given 3D vector by dropping the third (z) coordinate. |
|
| Method Summary | |
|---|---|
Vector2D |
add(Vector2D other)
Adds the given vector to the values of this vector. |
double |
angleRad(Vector2D other)
Calculates the smallest angle between this and the other vector. |
boolean |
approxEquals(Vector2D p,
double epsilon)
Compares for equality within an epsilon envelope. |
int |
compareTo(Vector2D o)
|
Vector2D |
crossProduct(Vector2D other)
Returns the vector that is the cross product between this vector and the other vector. |
double |
dotProduct(Vector2D other)
Returns the dot (inner/scalar) product between this vector and the other vector. |
boolean |
equals(Object obj)
Compares the specified object for equality with this vector. |
double |
get(int index)
Gets a value of the vector at the specified index, where 0 denotes the x and 1 the y element of the vector. |
double |
getX()
|
double |
getY()
|
int |
hashCode()
Returns the hash code for this vector. |
Vector2D |
invert()
Returns an inverted vector, i.e. a vector with element wise negated values. |
double |
length()
Returns the length of the vector. |
Vector2D |
multiply(double factor)
Returns a vector that has the values of this vector scaled by the given factor. |
Vector2D |
normalize()
Returns a vector that points in the same direction as this vector, scaled to unit length (1). |
static Vector2D |
of(double x,
double y)
Returns an immutable Vector2D instance constructed from its
Cartesian X and Y elements. |
Vector2D |
subtract(Vector2D other)
Subtracts the given vector from the values of this vector. |
double[] |
toArray()
Converts the Vector into an array with 3 values. |
String |
toString()
Returns the vector value formatted as a column vector in a way compatible with popular scientific numerical computing applications. |
String |
toString(NumberFormat fmt)
Returns the vector value formatted as a column vector in a way similar to popular scientific numerical computing applications. |
Vector2D |
withX(double value)
Returns a new instance (copy) of the vector, with the x element
replaced by the new value. |
Vector2D |
withY(double value)
Returns a new instance (copy) of the vector, with the y element
replaced by the new value. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final Vector2D ZERO
Vector2D instance representing a zero vector.
public static final Vector2D UNIT_X
Vector2D instance representing the X unit vector.
public static final Vector2D UNIT_Y
Vector2D instance representing the Y unit vector.
| Constructor Detail |
|---|
public Vector2D(double x,
double y)
x - x element of the vectory - y element of the vectorpublic Vector2D(com.kuka.math.geometry.Vector3D v)
v - a 3D vector| Method Detail |
|---|
public static Vector2D of(double x,
double y)
Vector2D instance constructed from its
Cartesian X and Y elements.
x - the Cartesian X element of the vectory - the Cartesian Y element of the vector
Vector2D instancepublic double getX()
x element of the vector.getY(),
get(int)public double getY()
y element of the vector.getX(),
get(int)public double get(int index)
x and 1 the y element of the vector.
index - The index of the element, must be between 0 and 1.
IndexOutOfBoundsException - illegal indexgetX(),
getY()public Vector2D withX(double value)
x element
replaced by the new value.
value - The x element of the vector.
public Vector2D withY(double value)
y element
replaced by the new value.
value - The y element of the vector.
public Vector2D invert()
public double length()
public Vector2D normalize()
public double dotProduct(Vector2D other)
other - another vector.
public Vector2D crossProduct(Vector2D other)
other - another vector.
public double angleRad(Vector2D other)
other - a vector
ArithmeticException - if this or the other vector has a approximate zero lengthpublic Vector2D multiply(double factor)
factor - The factor with which this vector should be multiplied.
ArithmeticException - factor is infinite or NaNpublic Vector2D add(Vector2D other)
other - The vector which will be added to the values of this vector.
public Vector2D subtract(Vector2D other)
other - The vector which will be subtracted from the values of this
vector.
public String toString()
MathUtils.getDefaultNumberFormat().
The following string can be regarded as typical:
[1.234; 300.0; -20.2]
toString in class Objectpublic String toString(NumberFormat fmt)
NumberFormat.format(double) method of
the given formatter.
Example: The following code snippet, used on a given Vector3D
vec
NumberFormat fmt = NumberFormat.getNumberInstance(Locale.US); fmt.setMinimumFractionDigits(1); fmt.setMaximumFractionDigits(3); System.out.println(vec.toString(fmt));might give the following output:
[-1.234; 1.414; 20.0]
fmt - the NumberFormat used to format the number values
public double[] toArray()
public int hashCode()
hashCode in class Objectpublic boolean equals(Object obj)
equals in class Objectobj - Object to be compared with this vector.
true if the object is equal to this vector.public int compareTo(Vector2D o)
compareTo in interface Comparable<Vector2D>
public boolean approxEquals(Vector2D p,
double epsilon)
p - the other point to compare toepsilon - the tolerance
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||