Package org.robwork.sdurw
Class Quaterniond
- java.lang.Object
 - 
- org.robwork.sdurw.Rotation3DVectord
 - 
- org.robwork.sdurw.Quaterniond
 
 
 
- 
public class Quaterniond extends Rotation3DVectord
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 Quaterniond()constuct Quaterinion of {0,0,0,1}Quaterniond(double qx, double qy, double qz, double qw)Creates a QuaternionQuaterniond(long cPtr, boolean cMemoryOwn)Quaterniond(Quaterniond quat)Creates a Quaternion from another QuaternionQuaterniond(Rotation3Dd 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 Quaterniondadd()Unary plus.voiddelete()EigenQuaternionde()Convert to an Eigen Quaternion.booleanequals(Quaterniond r)Comparison (equals) operatordoubleget(long i)static longgetCPtr(Quaterniond obj)doublegetLength()get length of quaternion
\sqrt{q_x^2+q_y^2+q_z^2+q_w^2}doublegetLengthSquared()get squared length of quaternion
q_x^2+q_y^2+q_z^2+q_w^2doublegetQw()get method for the w componentdoublegetQx()get method for the x componentdoublegetQy()get method for the y componentdoublegetQz()get method for the z componentQuaterniondmultiply(double s)Scalar multiplication.Quaterniondnegate()Unary minus.voidnormalize()normalizes this quaternion so that
normalze(Q)=\frac{Q}{\sqrt{q_x^2+q_y^2+q_z^2+q_w^2}}voidset(long i, double d)longsize()The dimension of the quaternion (i.e.Quaterniondslerp(Quaterniond v, double 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.comRotation3DdtoRotation3D()Calculates the 3\times 3 Rotation matrix
java.lang.StringtoString()- 
Methods inherited from class org.robwork.sdurw.Rotation3DVectord
getCPtr 
 - 
 
 - 
 
- 
- 
Constructor Detail
- 
Quaterniond
public Quaterniond(long cPtr, boolean cMemoryOwn) 
- 
Quaterniond
public Quaterniond()
constuct Quaterinion of {0,0,0,1} 
- 
Quaterniond
public Quaterniond(double qx, double qy, double qz, double qw)Creates a Quaternion- Parameters:
 qx- [in] q_xqy- [in] q_yqz- [in] q_zqw- [in] q_w
 
- 
Quaterniond
public Quaterniond(Quaterniond quat)
Creates a Quaternion from another Quaternion- Parameters:
 quat- [in] Quaternion
 
- 
Quaterniond
public Quaterniond(Rotation3Dd 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(Quaterniond obj)
 
- 
delete
public void delete()
- Overrides:
 deletein classRotation3DVectord
 
- 
getQx
public double getQx()
get method for the x component- Returns:
 - the x component of the quaternion
 
 
- 
getQy
public double getQy()
get method for the y component- Returns:
 - the y component of the quaternion
 
 
- 
getQz
public double getQz()
get method for the z component- Returns:
 - the z component of the quaternion
 
 
- 
getQw
public double getQw()
get method for the w component- Returns:
 - the w component of the quaternion
 
 
- 
getLength
public double 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 double 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 Rotation3Dd toRotation3D()
Calculates the 3\times 3 Rotation matrix
- Overrides:
 toRotation3Din classRotation3DVectord- 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 Quaterniond slerp(Quaterniond v, double 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 Quaterniond multiply(double s)
Scalar multiplication. 
- 
negate
public Quaterniond negate()
Unary minus. 
- 
add
public Quaterniond add()
Unary plus. 
- 
equals
public boolean equals(Quaterniond r)
Comparison (equals) operator 
- 
e
public EigenQuaterniond e()
Convert to an Eigen Quaternion.- Returns:
 - Eigen Quaternion representation.
 
 
- 
toString
public java.lang.String toString()
- Overrides:
 toStringin classjava.lang.Object
 
- 
get
public double get(long i)
 
- 
set
public void set(long i, double d) 
 - 
 
 -