Package org.robwork.sdurw
Class Quaternionf
- java.lang.Object
-
- org.robwork.sdurw.Rotation3DVectorf
-
- org.robwork.sdurw.Quaternionf
-
public class Quaternionf extends Rotation3DVectorf
A Quaternion \mathbf{q}\in \mathbb{R}^4 a complex
number used to describe rotations in 3-dimensional space.
q_w+{\bf i}\ q_x+ {\bf j} q_y+ {\bf k}\ q_z
Quaternions can be added and multiplied in a similar way as usual
algebraic numbers. Though there are differences. Quaternion
multiplication is not commutative which means
Q\cdot P \neq P\cdot Q
-
-
Constructor Summary
Constructors Constructor Description Quaternionf()
constuct Quaterinion of {0,0,0,1}Quaternionf(float qx, float qy, float qz, float qw)
Creates a QuaternionQuaternionf(long cPtr, boolean cMemoryOwn)
Quaternionf(Quaternionf quat)
Creates a Quaternion from another QuaternionQuaternionf(Rotation3Df rot)
Extracts a Quaternion from Rotation matrix using
setRotation(const rw::math::Rotation3D<R>& rot)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Quaternionf
add()
Unary plus.void
delete()
EigenQuaternionf
e()
Convert to an Eigen Quaternion.boolean
equals(Quaternionf r)
Comparison (equals) operatorfloat
get(long i)
static long
getCPtr(Quaternionf obj)
float
getLength()
get length of quaternion
\sqrt{q_x^2+q_y^2+q_z^2+q_w^2}float
getLengthSquared()
get squared length of quaternion
q_x^2+q_y^2+q_z^2+q_w^2float
getQw()
get method for the w componentfloat
getQx()
get method for the x componentfloat
getQy()
get method for the y componentfloat
getQz()
get method for the z componentQuaternionf
multiply(float s)
Scalar multiplication.Quaternionf
negate()
Unary minus.void
normalize()
normalizes this quaternion so that
normalze(Q)=\frac{Q}{\sqrt{q_x^2+q_y^2+q_z^2+q_w^2}}void
set(long i, float d)
long
size()
The dimension of the quaternion (i.e.Quaternionf
slerp(Quaternionf v, float t)
Calculates a slerp interpolation between this and v.
The slerp interpolation ensures a constant velocity across the interpolation.
For t=0 the result is this and for t=1 it is v.
Note: Algorithm and implementation is thanks to euclideanspace.comRotation3Df
toRotation3D()
Calculates the 3\times 3 Rotation matrix
java.lang.String
toString()
-
Methods inherited from class org.robwork.sdurw.Rotation3DVectorf
getCPtr
-
-
-
-
Constructor Detail
-
Quaternionf
public Quaternionf(long cPtr, boolean cMemoryOwn)
-
Quaternionf
public Quaternionf()
constuct Quaterinion of {0,0,0,1}
-
Quaternionf
public Quaternionf(float qx, float qy, float qz, float qw)
Creates a Quaternion- Parameters:
qx
- [in] q_xqy
- [in] q_yqz
- [in] q_zqw
- [in] q_w
-
Quaternionf
public Quaternionf(Quaternionf quat)
Creates a Quaternion from another Quaternion- Parameters:
quat
- [in] Quaternion
-
Quaternionf
public Quaternionf(Rotation3Df rot)
Extracts a Quaternion from Rotation matrix using
setRotation(const rw::math::Rotation3D<R>& rot)- Parameters:
rot
- [in] A 3x3 rotation matrix \mathbf{rot}
-
-
Method Detail
-
getCPtr
public static long getCPtr(Quaternionf obj)
-
delete
public void delete()
- Overrides:
delete
in classRotation3DVectorf
-
getQx
public float getQx()
get method for the x component- Returns:
- the x component of the quaternion
-
getQy
public float getQy()
get method for the y component- Returns:
- the y component of the quaternion
-
getQz
public float getQz()
get method for the z component- Returns:
- the z component of the quaternion
-
getQw
public float getQw()
get method for the w component- Returns:
- the w component of the quaternion
-
getLength
public float getLength()
get length of quaternion
\sqrt{q_x^2+q_y^2+q_z^2+q_w^2}- Returns:
- the length og this quaternion
-
getLengthSquared
public float getLengthSquared()
get squared length of quaternion
q_x^2+q_y^2+q_z^2+q_w^2- Returns:
- the length og this quaternion
-
normalize
public void normalize()
normalizes this quaternion so that
normalze(Q)=\frac{Q}{\sqrt{q_x^2+q_y^2+q_z^2+q_w^2}}
-
toRotation3D
public Rotation3Df toRotation3D()
Calculates the 3\times 3 Rotation matrix
- Overrides:
toRotation3D
in classRotation3DVectorf
- Returns:
- A 3x3 rotation matrix \mathbf{rot}
\mathbf{rot} = \left[ \begin{array}{ccc} 1-2(q_y^2-q_z^2) 2(q_x\ q_y+q_z\ q_w) 2(q_x\ q_z-q_y\ q_w) \\ 2(q_x\ q_y-q_z\ q_w) 1-2(q_x^2-q_z^2) 2(q_y\ q_z+q_x\ q_w)\\ 2(q_x\ q_z+q_y\ q_w) 2(q_y\ q_z-q_x\ q_z) 1-2(q_x^2-q_y^2) \end{array} \right]
-
size
public long size()
The dimension of the quaternion (i.e. 4).
This method is provided to help support generic algorithms using
size() and operator[].
-
slerp
public Quaternionf slerp(Quaternionf v, float t)
Calculates a slerp interpolation between this and v.
The slerp interpolation ensures a constant velocity across the interpolation.
For t=0 the result is this and for t=1 it is v.
Note: Algorithm and implementation is thanks to euclideanspace.com
-
multiply
public Quaternionf multiply(float s)
Scalar multiplication.
-
negate
public Quaternionf negate()
Unary minus.
-
add
public Quaternionf add()
Unary plus.
-
equals
public boolean equals(Quaternionf r)
Comparison (equals) operator
-
e
public EigenQuaternionf e()
Convert to an Eigen Quaternion.- Returns:
- Eigen Quaternion representation.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
get
public float get(long i)
-
set
public void set(long i, float d)
-
-