hpp-corbaserver 6.0.0
Corba server for Humanoid Path Planner applications
Loading...
Searching...
No Matches
hpp.quaternion.Quaternion Class Reference

Public Member Functions

 __init__ (self, *args)
 
 __str__ (self)
 
 __neg__ (self)
 
 __add__ (self, other)
 
 __sub__ (self, other)
 
 __mul__ (self, other)
 
 __rmul__ (self, other)
 
 transform (self, v)
 
 __abs__ (self)
 
 conjugate (self)
 
 inv (self)
 
 __div__ (self, other)
 
 __pow__ (self, n)
 
 normalize (self)
 
 normalized (self)
 
 toRotationMatrix (self)
 
 toRotationVector (self)
 
 copy (self)
 
 toRPY (self)
 
 fromRPY (self, R, P, Y)
 
 toTuple (self)
 
 fromTwoVector (self, a, b)
 
 fromAngleAxis (self, axis, angle, degree=False)
 

Public Attributes

 array
 

Detailed Description

Quaternion class :
------------------

A quaternion has a scalar part and a vector part.
In this class the quaternion is represented as an array of 4 elements :
  - the 3 first elements represent the vector part
  - the last element represents the scalar part

One can acces to the array directly with the attribute "array"
  e.g. q1=Quaternion(0,0,0,1) --> q1.array

A quaternion can be instanciated with 1, 2 or 4 elements
  (see : __init__() for more information).

It can also return a rotation vector, a rotation matrix, or a SO3
  (see the methods : to...() for more information).

Constructor & Destructor Documentation

◆ __init__()

hpp.quaternion.Quaternion.__init__ (   self,
args 
)
Instanciation of the quaternion with 1, 2 or 4 arguments  :
-----------------------------------------------------------
This creates a 4-sized array (self.array) representing the quaternion
with the first element representing the scalar part
and the 3 others the vector part.

With 4 arguments :
------------------
  - the 3 first one are used as the vector part,
  - the last one as the scalar part.

With 2 arguments :
------------------
  - the 3-sized argument is used as the vector part.
  - the 1-sized argument is used as the scalar part,

With 1 argument :
-----------------
  - if it is a quaternion it will create a copy of this quaternion.
  - if it is a scalar, the scalar will be used as the scalar part
    and the vector part will be set at (0,0,0).
  - if it is an array, matrix, tuple or list of 4 elements,
    the last element is used as the scalar part
    and the first elements as the vector part.
  - if it is an array, matrix, tuple or list of 3 elements,
    the 3 elements are interpreted as a rotation vector,
    this creates a quaternion representing the same rotation.
  - if it is a 2 dimension array convertible array, matrix, tuple
    or list with at least (3*3) elements,
    the upper left (3*3) elements are interpreted as a rotation matrix,
    this creates a quaternion representing the same rotation.
  - if it is an instance of SO3, quaternion is built from rotation
    matrix.

With 0 arguments :
------------------
If no argument is given, than the quaternion will be set by default
to with the scalar part set to 1 and the vector part to (0,0,0).
(this is the neutral element for multiplication in quaternion space)

To create a quaternion from Roll, Pitch, Yaw angles :
-----------------------------------------------------
first instanciate a quaternion and than use the method fromRPY()
to change the values of it to the dezired ones.
  e.g. : quat().fromRPY(R,P,Y)

Member Function Documentation

◆ __abs__()

hpp.quaternion.Quaternion.__abs__ (   self)
Returns the norm of the quaternion.

◆ __add__()

hpp.quaternion.Quaternion.__add__ (   self,
  other 
)
If other is not a quaternion it is casted to a quaternion,
the elements are added one to one.

◆ __div__()

hpp.quaternion.Quaternion.__div__ (   self,
  other 
)
If other is not a quaternion it is casted to a quaternion,
the result of the quaternion multiplication with the inverse of other
is returned.

◆ __mul__()

hpp.quaternion.Quaternion.__mul__ (   self,
  other 
)
If other is not a quaternion it is casted to a quaternion,
the result of the quaternion multiplication is returned.

◆ __neg__()

hpp.quaternion.Quaternion.__neg__ (   self)
Returns a quaternion which elements are the opposite of the original,
(this opposite quaternion represents the same rotation).

◆ __pow__()

hpp.quaternion.Quaternion.__pow__ (   self,
  n 
)
Returns quaternion**n with quaternion**0 = Quaternion(1,0,0,0).

◆ __rmul__()

hpp.quaternion.Quaternion.__rmul__ (   self,
  other 
)
other is casted to a quaternion,
the result of the quaternion multiplication is returned.

◆ __str__()

hpp.quaternion.Quaternion.__str__ (   self)
String representation of the quaternion.

◆ __sub__()

hpp.quaternion.Quaternion.__sub__ (   self,
  other 
)
If other is not a quaternion it is casted to a quaternion,
the elements are substracted one to one.

◆ conjugate()

hpp.quaternion.Quaternion.conjugate (   self)
Returns the conjugate of the quaternion.

◆ copy()

hpp.quaternion.Quaternion.copy (   self)
Returns a copy of the quaternion.

◆ fromAngleAxis()

hpp.quaternion.Quaternion.fromAngleAxis (   self,
  axis,
  angle,
  degree = False 
)
Build a quaternion from an axis of rotation and an angle.
The angle is in radians by default and in degree if degree is set to True.
The axis is normalized.

◆ fromRPY()

hpp.quaternion.Quaternion.fromRPY (   self,
  R,
  P,
  Y 
)
Set the values of the quaternion to the values of a unit quaternion
representing the same rotation as the one performed by Roll Pitch Yaw :
  - A rotation of R (Roll) about the original x-axis,
    followed by a rotation of P (Pitch) about the original y-axis,
    followed by a rotation of Y (Yaw) about the original z-axis.
  - Or otherwise a rotation of Y about the original z-axis,
    followed by a rotation of P about the new y-axis,
    followed by a rotation of R about the new x-axis.

◆ fromTwoVector()

hpp.quaternion.Quaternion.fromTwoVector (   self,
  a,
  b 
)
Return a quaternion build representing the rotation between the two vectors.
In other words, the built rotation represent a rotation sending
the line of direction a to the line of direction b,
both lines passing through the origin.
Equations from Eigen
https://eigen.tuxfamily.org/dox/classEigen_1_1Quaternion.html#title13

◆ inv()

hpp.quaternion.Quaternion.inv (   self)
Returns the inverse of the quaternion.

◆ normalize()

hpp.quaternion.Quaternion.normalize (   self)
Changes the values of the quaternion to make it a unit quaternion
representing the same rotation as the original one
and returns the updated version.

◆ normalized()

hpp.quaternion.Quaternion.normalized (   self)
Returns the unit quaternion representation of the quaternion
without changing the original.

◆ toRotationMatrix()

hpp.quaternion.Quaternion.toRotationMatrix (   self)
Returns a (3*3) array (rotation matrix)
representing the same rotation as the (normalized) quaternion.

◆ toRotationVector()

hpp.quaternion.Quaternion.toRotationVector (   self)
Returns a 3-sized array (rotation vector)
representing the same rotation as the (normalized) quaternion.

◆ toRPY()

hpp.quaternion.Quaternion.toRPY (   self)
Returns a 3-sized array with representing the same rotation
as the (normalized) quaternion. With :
  - the first element representing the Roll,
  - the second the Pitch
  - the third the Yaw
Where Roll Pitch and Yaw are the angles so that the rotation
with the quaternion represents the same rotation as :
  - A rotation of R (Roll) about the original x-axis,
    followed by a rotation of P (Pitch) about the original y-axis,
    followed by a rotation of Y (Yaw) about the original z-axis.
  - Or otherwise a rotation of Y about the original z-axis,
    followed by a rotation of P about the new y-axis,
    followed by a rotation of R about the new x-axis.

◆ toTuple()

hpp.quaternion.Quaternion.toTuple (   self)
Return quaternion as a tuple a float starting with real part.

◆ transform()

hpp.quaternion.Quaternion.transform (   self,
  v 
)
apply rotation to a vector

Member Data Documentation

◆ array

hpp.quaternion.Quaternion.array

The documentation for this class was generated from the following file: