from_angles#
- Quaternion.from_angles(angles: ndarray) ndarray #
Synonym to method from_rpy()
- 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
>>> from 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])
It can be corroborated with the class DCM, which represents a Direction Cosine Matrix, and can also be built with roll-pitch-yaw angles.
>>> 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])
With both approaches the same quaternion is obtained.