Package org.robwork.sdurw_math
Class Quaternion_f
- java.lang.Object
-
- org.robwork.sdurw_math.Rotation3DVectorf
-
- org.robwork.sdurw_math.Quaternion_f
-
public class Quaternion_f 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 Quaternion_f()
constuct Quaterinion of {0,0,0,1}Quaternion_f(float qx, float qy, float qz, float qw)
Creates a QuaternionQuaternion_f(long cPtr, boolean cMemoryOwn)
Quaternion_f(EigenQuaternionf r)
Creates a Quaternion from a Eigen quaternionQuaternion_f(Quaternion_f quat)
Creates a Quaternion from another QuaternionQuaternion_f(Rotation3Df rot)
Extracts a Quaternion from Rotation matrix using
setRotation(const Rotation3D<R>& rot)Quaternion_f(Rotation3DVectorf rot)
Creates a Quaternion from another Rotation3DVector type
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Quaternion_f
add()
Unary plus.Quaternion_f
add(Quaternion_f v)
Addition of two quaternionsQuaternion_f
addAssign(Quaternion_f r)
Add-to operatorvoid
copy(EigenQuaternionf r)
copy a boost quaternion to this QuaternionQuaternion_f
copy(SWIGTYPE_p_rw__math__Rotation3DT_t rhs)
copyfrom rotaion matrix, same as setRotation.void
delete()
Quaternion_f
divide(float s)
Scalar Devision.EigenQuaternionf
e()
Convert to an Eigen Quaternion.Quaternion_f
elemDivide(float lhs)
element whise divisionboolean
equals(Quaternion_f r)
Comparison (equals) operatorQuaternion_f
exp()
float
get(long i)
static long
getCPtr(Quaternion_f 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 componentQuaternion_f
inverse()
Calculate the inverse QuaternionQuaternion_f
ln()
calculates the natural logerithm of this quaternionQuaternion_f
multiply(float s)
Scalar multiplication.Quaternion_f
multiply(Quaternion_f r)
Multiply-from operatorQuaternion_f
multiplyAssign(float s)
Scalar multiplication.Quaternion_f
multiplyAssign(Quaternion_f r)
Multiply with operatorQuaternion_f
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}}boolean
notEqual(Quaternion_f r)
Comparison (not equals) operatorQuaternion_f
pow(double power)
calculates the quaternion lifted to the power of powervoid
set(long i, float d)
long
size()
The dimension of the quaternion (i.e.Quaternion_f
slerp(Quaternion_f 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.comQuaternion_f
subtract(Quaternion_f v)
Subtraction.Quaternion_f
subtractAssign(Quaternion_f r)
Subtract-from operatorSWIGTYPE_p_Eigen__MatrixT_float_4_1_t
toEigenVector()
convert to Eigen VectorRotation3Df
toRotation3D()
Returns the corresponding 3\times 3 Rotation matrixjava.lang.String
toString()
-
Methods inherited from class org.robwork.sdurw_math.Rotation3DVectorf
getCPtr
-
-
-
-
Constructor Detail
-
Quaternion_f
public Quaternion_f(long cPtr, boolean cMemoryOwn)
-
Quaternion_f
public Quaternion_f()
constuct Quaterinion of {0,0,0,1}
-
Quaternion_f
public Quaternion_f(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
-
Quaternion_f
public Quaternion_f(Quaternion_f quat)
Creates a Quaternion from another Quaternion- Parameters:
quat
- [in] Quaternion
-
Quaternion_f
public Quaternion_f(Rotation3DVectorf rot)
Creates a Quaternion from another Rotation3DVector type- Parameters:
rot
- [in] The Rotation3DVector type
-
Quaternion_f
public Quaternion_f(Rotation3Df rot)
Extracts a Quaternion from Rotation matrix using
setRotation(const Rotation3D<R>& rot)- Parameters:
rot
- [in] A 3x3 rotation matrix \mathbf{rot}
-
Quaternion_f
public Quaternion_f(EigenQuaternionf r)
Creates a Quaternion from a Eigen quaternion- Parameters:
r
- [in] a boost quaternion
-
-
Method Detail
-
getCPtr
public static long getCPtr(Quaternion_f 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
-
get
public float get(long i)
-
set
public void set(long i, float d)
-
toRotation3D
public Rotation3Df toRotation3D()
Description copied from class:Rotation3DVectorf
Returns the corresponding 3\times 3 Rotation matrix- Overrides:
toRotation3D
in classRotation3DVectorf
- 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 EigenQuaternionf e()
Convert to an Eigen Quaternion.- Returns:
- Eigen Quaternion representation.
-
toEigenVector
public SWIGTYPE_p_Eigen__MatrixT_float_4_1_t toEigenVector()
convert to Eigen Vector- Returns:
- eigen Vector of quaternion
-
negate
public Quaternion_f negate()
Unary minus.
-
add
public Quaternion_f add()
Unary plus.
-
subtract
public Quaternion_f subtract(Quaternion_f v)
Subtraction.
-
multiply
public Quaternion_f multiply(Quaternion_f r)
Multiply-from operator
-
add
public Quaternion_f add(Quaternion_f v)
Addition of two quaternions
-
multiply
public Quaternion_f multiply(float s)
Scalar multiplication.
-
divide
public Quaternion_f divide(float s)
Scalar Devision.
-
elemDivide
public Quaternion_f elemDivide(float lhs)
element whise division- Parameters:
lhs
- [in] the scalar to devide with- Returns:
- the result of elementwise devision
-
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}}
-
slerp
public Quaternion_f slerp(Quaternion_f 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
-
exp
public Quaternion_f exp()
-
inverse
public Quaternion_f inverse()
Calculate the inverse Quaternion- Returns:
- the inverse quaternion
-
ln
public Quaternion_f ln()
calculates the natural logerithm of this quaternion- Returns:
- natural logetihm
-
pow
public Quaternion_f 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(EigenQuaternionf r)
copy a boost quaternion to this Quaternion- Parameters:
r
- [in] - boost quaternion
-
multiplyAssign
public Quaternion_f multiplyAssign(float s)
Scalar multiplication.
-
multiplyAssign
public Quaternion_f multiplyAssign(Quaternion_f r)
Multiply with operator
-
addAssign
public Quaternion_f addAssign(Quaternion_f r)
Add-to operator
-
subtractAssign
public Quaternion_f subtractAssign(Quaternion_f r)
Subtract-from operator
-
copy
public Quaternion_f 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_f r)
Comparison (equals) operator
-
notEqual
public boolean notEqual(Quaternion_f r)
Comparison (not equals) operator
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-