Package org.robwork.sdurw_math
Class Quaternion
- java.lang.Object
-
- org.robwork.sdurw_math.Rotation3DVector
-
- org.robwork.sdurw_math.Quaternion
-
public class Quaternion extends Rotation3DVector
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 Quaternion()constuct Quaterinion of {0,0,0,1}Quaternion(double qx, double qy, double qz, double qw)Creates a QuaternionQuaternion(long cPtr, boolean cMemoryOwn)Quaternion(EigenQuaterniond r)Creates a Quaternion from a Eigen quaternionQuaternion(Quaternion quat)Creates a Quaternion from another QuaternionQuaternion(Rotation3D rot)Extracts a Quaternion from Rotation matrix using
setRotation(const Rotation3D<R>& rot)Quaternion(Rotation3DVector rot)Creates a Quaternion from another Rotation3DVector type
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Quaternionadd()Unary plus.Quaternionadd(Quaternion v)Addition of two quaternionsQuaternionaddAssign(Quaternion r)Add-to operatorvoidcopy(EigenQuaterniond r)copy a boost quaternion to this QuaternionQuaternioncopy(SWIGTYPE_p_rw__math__Rotation3DT_t rhs)copyfrom rotaion matrix, same as setRotation.voiddelete()Quaterniondivide(double s)Scalar Devision.EigenQuaternionde()Convert to an Eigen Quaternion.QuaternionelemDivide(double lhs)element whise divisionbooleanequals(Quaternion r)Comparison (equals) operatorQuaternionexp()doubleget(long i)static longgetCPtr(Quaternion 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 componentQuaternioninverse()Calculate the inverse QuaternionQuaternionln()calculates the natural logerithm of this quaternionQuaternionmultiply(double s)Scalar multiplication.Quaternionmultiply(Quaternion r)Multiply-from operatorQuaternionmultiplyAssign(double s)Scalar multiplication.QuaternionmultiplyAssign(Quaternion r)Multiply with operatorQuaternionnegate()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}}booleannotEqual(Quaternion r)Comparison (not equals) operatorQuaternionpow(double power)calculates the quaternion lifted to the power of powervoidset(long i, double d)longsize()The dimension of the quaternion (i.e.Quaternionslerp(Quaternion 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.comQuaternionsubtract(Quaternion v)Subtraction.QuaternionsubtractAssign(Quaternion r)Subtract-from operatorSWIGTYPE_p_Eigen__MatrixT_double_4_1_ttoEigenVector()convert to Eigen VectorRotation3DtoRotation3D()Returns the corresponding 3\times 3 Rotation matrixjava.lang.StringtoString()-
Methods inherited from class org.robwork.sdurw_math.Rotation3DVector
getCPtr
-
-
-
-
Constructor Detail
-
Quaternion
public Quaternion(long cPtr, boolean cMemoryOwn)
-
Quaternion
public Quaternion()
constuct Quaterinion of {0,0,0,1}
-
Quaternion
public Quaternion(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
-
Quaternion
public Quaternion(Quaternion quat)
Creates a Quaternion from another Quaternion- Parameters:
quat- [in] Quaternion
-
Quaternion
public Quaternion(Rotation3DVector rot)
Creates a Quaternion from another Rotation3DVector type- Parameters:
rot- [in] The Rotation3DVector type
-
Quaternion
public Quaternion(Rotation3D rot)
Extracts a Quaternion from Rotation matrix using
setRotation(const Rotation3D<R>& rot)- Parameters:
rot- [in] A 3x3 rotation matrix \mathbf{rot}
-
Quaternion
public Quaternion(EigenQuaterniond r)
Creates a Quaternion from a Eigen quaternion- Parameters:
r- [in] a boost quaternion
-
-
Method Detail
-
getCPtr
public static long getCPtr(Quaternion obj)
-
delete
public void delete()
- Overrides:
deletein classRotation3DVector
-
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
-
get
public double get(long i)
-
set
public void set(long i, double d)
-
toRotation3D
public Rotation3D toRotation3D()
Description copied from class:Rotation3DVectorReturns the corresponding 3\times 3 Rotation matrix- Overrides:
toRotation3Din classRotation3DVector- Returns:
- The rotation matrix
-
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[].
-
e
public EigenQuaterniond e()
Convert to an Eigen Quaternion.- Returns:
- Eigen Quaternion representation.
-
toEigenVector
public SWIGTYPE_p_Eigen__MatrixT_double_4_1_t toEigenVector()
convert to Eigen Vector- Returns:
- eigen Vector of quaternion
-
negate
public Quaternion negate()
Unary minus.
-
add
public Quaternion add()
Unary plus.
-
subtract
public Quaternion subtract(Quaternion v)
Subtraction.
-
multiply
public Quaternion multiply(Quaternion r)
Multiply-from operator
-
add
public Quaternion add(Quaternion v)
Addition of two quaternions
-
multiply
public Quaternion multiply(double s)
Scalar multiplication.
-
divide
public Quaternion divide(double s)
Scalar Devision.
-
elemDivide
public Quaternion elemDivide(double lhs)
element whise division- Parameters:
lhs- [in] the scalar to devide with- Returns:
- the result of elementwise devision
-
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}}
-
slerp
public Quaternion slerp(Quaternion 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
-
exp
public Quaternion exp()
-
inverse
public Quaternion inverse()
Calculate the inverse Quaternion- Returns:
- the inverse quaternion
-
ln
public Quaternion ln()
calculates the natural logerithm of this quaternion- Returns:
- natural logetihm
-
pow
public Quaternion pow(double power)
calculates the quaternion lifted to the power of power- Parameters:
power- [in] the power the quaternion is lifted to- Returns:
- Quaternion^power
-
copy
public void copy(EigenQuaterniond r)
copy a boost quaternion to this Quaternion- Parameters:
r- [in] - boost quaternion
-
multiplyAssign
public Quaternion multiplyAssign(double s)
Scalar multiplication.
-
multiplyAssign
public Quaternion multiplyAssign(Quaternion r)
Multiply with operator
-
addAssign
public Quaternion addAssign(Quaternion r)
Add-to operator
-
subtractAssign
public Quaternion subtractAssign(Quaternion r)
Subtract-from operator
-
copy
public Quaternion copy(SWIGTYPE_p_rw__math__Rotation3DT_t rhs)
copyfrom rotaion matrix, same as setRotation.- Parameters:
rhs- [in] the rotation that will be copyed
-
equals
public boolean equals(Quaternion r)
Comparison (equals) operator
-
notEqual
public boolean notEqual(Quaternion r)
Comparison (not equals) operator
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-