|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.kuka.math.geometry.Vector3D
public final class Vector3D
Immutable representation of a 3-element vector consisting of x, y and z elements. The class
Vector represents a difference vector, which describes the displacement between two 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
ITransformation.applyTo(Vector3D) results in a (displacement) vector represented in the new coordinate
system. From numerical point of view the rotational part of the transformation is applied to the three components of
the vector, but the translational part of the transformation will not be applied to the vectorThe Robotics API always assumes the translation vector to be given in [mm].
To create a new Vector object use the static factory method of(double, double, double).
| Field Summary | |
|---|---|
static Vector3D |
UNIT_X
Immutable Vector3D instance representing the X unit vector. |
static Vector3D |
UNIT_Y
Immutable Vector3D instance representing the Y unit vector. |
static Vector3D |
UNIT_Z
Immutable Vector3D instance representing the Z unit vector. |
static Vector3D |
ZERO
Immutable Vector3D instance representing a zero vector. |
| Method Summary | |
|---|---|
Vector3D |
add(Vector3D other)
Adds the given vector to the values of this vector. |
double |
angleRad(Vector3D other)
Calculates the smallest angle between this and the other vector. |
Vector3D |
crossProduct(Vector3D other)
Returns the vector that is the cross product between this vector and the other vector. |
double |
dotProduct(Vector3D 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, 1 the y and 2 the
z element of the vector. |
double |
getX()
Returns the x element of the vector. |
double |
getY()
Returns the y element of the vector. |
double |
getZ()
Returns the z element of the vector. |
int |
hashCode()
Returns the hash code for this vector. |
Vector3D |
invert()
Returns an inverted vector, i.e. a vector with element wise negated values. |
double |
length()
Returns the length of the vector. |
Vector3D |
multiply(double factor)
Returns a vector that has the values of this vector scaled by the given factor. |
Vector3D |
normalize()
Returns a vector that points in the same direction as this vector, scaled to unit length (1). |
static Vector3D |
of(double x,
double y,
double z)
Returns an immutable Vector3D instance constructed from its cartesian X, Y and Z elements. |
Vector3D |
subtract(Vector3D 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. |
Vector3D |
withX(double value)
Returns a new instance (copy) of the vector, with the x element replaced by the new value. |
Vector3D |
withY(double value)
Returns a new instance (copy) of the vector, with the y element replaced by the new value. |
Vector3D |
withZ(double value)
Returns a new instance (copy) of the vector, with the z 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 Vector3D ZERO
Vector3D instance representing a zero vector.
public static final Vector3D UNIT_X
Vector3D instance representing the X unit vector.
public static final Vector3D UNIT_Y
Vector3D instance representing the Y unit vector.
public static final Vector3D UNIT_Z
Vector3D instance representing the Z unit vector.
| Method Detail |
|---|
public static Vector3D of(double x,
double y,
double z)
Vector3D instance constructed from its cartesian X, Y and Z elements.
x - the cartesian X element of the vectory - the cartesian Y element of the vectorz - the cartesian Z element of the vector
Vector3D instancepublic double getX()
x element of the vector.
x element of the vector.getY(),
getZ(),
get(int)public double getY()
y element of the vector.
y element of the vector.getX(),
getZ(),
get(int)public double getZ()
z element of the vector.
z element of the vector.getX(),
getY(),
get(int)public double get(int index)
x, 1 the y and 2 the
z element of the vector.
index - The index of the element, must be between 0 and 2.
IndexOutOfBoundsException - illegal indexgetX(),
getY(),
getZ()public Vector3D withX(double value)
x element replaced by the new value.
value - The x element of the vector.
public Vector3D withY(double value)
y element replaced by the new value.
value - The y element of the vector.
public Vector3D withZ(double value)
z element replaced by the new value.
value - The z element of the vector.
public Vector3D invert()
public double length()
public Vector3D normalize()
public double dotProduct(Vector3D other)
other - another vector.
public Vector3D crossProduct(Vector3D other)
other - another vector.
public double angleRad(Vector3D other)
other - a vector
ArithmeticException - if this or the other vector has a approximate zero lengthpublic Vector3D multiply(double factor)
factor - The factor with which this vector should be multiplied.
ArithmeticException - factor is infinite or NaNpublic Vector3D add(Vector3D other)
other - The vector which will be added to the values of this vector.
public Vector3D subtract(Vector3D 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.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||