Quaternion.from_angles
Quaternion.from_angles(angles: ndarray) → ndarray : Synonym to method from_rpy()
code
Parameters:
: **angles** (*numpy.ndarray*) – 3 cardanian angles in following order: roll -> pitch -> yaw.
Returns:
: **q** – Quaternion from roll-pitch-yaw angles.
Return type:
: numpy.ndarray
Examples
```defaultfrom ahrs import DEG2RAD # Helper variable to convert angles to radians q = Quaternion() q.from_angles(np.array([10.0, 20.0, 30.0])*DEG2RAD) # Give roll-pitch-yaw angles as radians. array([0.95154852, 0.23929834, 0.18930786, 0.03813458])
code
It can be corroborated with the class [DCM](https://ahrs.readthedocs.io/en/latest/quaternion/dcm.html), which represents a Direction
Cosine Matrix, and can also be built with roll-pitch-yaw angles.
```default
>>> from ahrs import DCM
>>> R = DCM(rpy=[10.0, 20.0, 30.0]) # Here you give the angles as degrees
>>> R
DCM([[ 0.92541658, 0.01802831, 0.37852231],
[ 0.16317591, 0.88256412, -0.44096961],
[-0.34202014, 0.46984631, 0.81379768]])
>>> q.from_DCM(R)
array([0.95154852, 0.23929834, 0.18930786, 0.03813458])code
With both approaches the same quaternion is obtained.