quaternion_math_functions.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /******************************************************************************
  2. * @file quaternion_math_functions.h
  3. * @brief Public header file for CMSIS DSP Library
  4. * @version V1.10.0
  5. * @date 08 July 2021
  6. *
  7. * Target Processor: Cortex-M and Cortex-A cores
  8. ******************************************************************************/
  9. /*
  10. * Copyright (c) 2010-2021 Arm Limited or its affiliates. All rights reserved.
  11. *
  12. * SPDX-License-Identifier: Apache-2.0
  13. *
  14. * Licensed under the Apache License, Version 2.0 (the License); you may
  15. * not use this file except in compliance with the License.
  16. * You may obtain a copy of the License at
  17. *
  18. * www.apache.org/licenses/LICENSE-2.0
  19. *
  20. * Unless required by applicable law or agreed to in writing, software
  21. * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  22. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  23. * See the License for the specific language governing permissions and
  24. * limitations under the License.
  25. */
  26. #ifndef _QUATERNION_MATH_FUNCTIONS_H_
  27. #define _QUATERNION_MATH_FUNCTIONS_H_
  28. #include "arm_math_types.h"
  29. #include "arm_math_memory.h"
  30. #include "dsp/none.h"
  31. #include "dsp/utils.h"
  32. #ifdef __cplusplus
  33. extern "C"
  34. {
  35. #endif
  36. /**
  37. * @defgroup groupQuaternionMath Quaternion Math Functions
  38. * Functions to operates on quaternions and convert between a
  39. * rotation and quaternion representation.
  40. */
  41. /**
  42. @brief Floating-point quaternion Norm.
  43. @param[in] pInputQuaternions points to the input vector of quaternions
  44. @param[out] pNorms points to the output vector of norms
  45. @param[in] nbQuaternions number of quaternions in each vector
  46. */
  47. void arm_quaternion_norm_f32(const float32_t *pInputQuaternions,
  48. float32_t *pNorms,
  49. uint32_t nbQuaternions);
  50. /**
  51. @brief Floating-point quaternion inverse.
  52. @param[in] pInputQuaternions points to the input vector of quaternions
  53. @param[out] pInverseQuaternions points to the output vector of inverse quaternions
  54. @param[in] nbQuaternions number of quaternions in each vector
  55. */
  56. void arm_quaternion_inverse_f32(const float32_t *pInputQuaternions,
  57. float32_t *pInverseQuaternions,
  58. uint32_t nbQuaternions);
  59. /**
  60. @brief Floating-point quaternion conjugates.
  61. @param[in] pInputQuaternions points to the input vector of quaternions
  62. @param[out] pConjugateQuaternions points to the output vector of conjugate quaternions
  63. @param[in] nbQuaternions number of quaternions in each vector
  64. */
  65. void arm_quaternion_conjugate_f32(const float32_t *inputQuaternions,
  66. float32_t *pConjugateQuaternions,
  67. uint32_t nbQuaternions);
  68. /**
  69. @brief Floating-point normalization of quaternions.
  70. @param[in] pInputQuaternions points to the input vector of quaternions
  71. @param[out] pNormalizedQuaternions points to the output vector of normalized quaternions
  72. @param[in] nbQuaternions number of quaternions in each vector
  73. */
  74. void arm_quaternion_normalize_f32(const float32_t *inputQuaternions,
  75. float32_t *pNormalizedQuaternions,
  76. uint32_t nbQuaternions);
  77. /**
  78. @brief Floating-point product of two quaternions.
  79. @param[in] qa First quaternion
  80. @param[in] qb Second quaternion
  81. @param[out] r Product of two quaternions
  82. */
  83. void arm_quaternion_product_single_f32(const float32_t *qa,
  84. const float32_t *qb,
  85. float32_t *r);
  86. /**
  87. @brief Floating-point elementwise product two quaternions.
  88. @param[in] qa First array of quaternions
  89. @param[in] qb Second array of quaternions
  90. @param[out] r Elementwise product of quaternions
  91. @param[in] nbQuaternions Number of quaternions in the array
  92. */
  93. void arm_quaternion_product_f32(const float32_t *qa,
  94. const float32_t *qb,
  95. float32_t *r,
  96. uint32_t nbQuaternions);
  97. /**
  98. * @brief Conversion of quaternion to equivalent rotation matrix.
  99. * @param[in] pInputQuaternions points to an array of normalized quaternions
  100. * @param[out] pOutputRotations points to an array of 3x3 rotations (in row order)
  101. * @param[in] nbQuaternions in the array
  102. *
  103. * <b>Format of rotation matrix</b>
  104. * \par
  105. * The quaternion a + ib + jc + kd is converted into rotation matrix:
  106. * a^2 + b^2 - c^2 - d^2 2bc - 2ad 2bd + 2ac
  107. * 2bc + 2ad a^2 - b^2 + c^2 - d^2 2cd - 2ab
  108. * 2bd - 2ac 2cd + 2ab a^2 - b^2 - c^2 + d^2
  109. *
  110. * Rotation matrix is saved in row order : R00 R01 R02 R10 R11 R12 R20 R21 R22
  111. */
  112. void arm_quaternion2rotation_f32(const float32_t *pInputQuaternions,
  113. float32_t *pOutputRotations,
  114. uint32_t nbQuaternions);
  115. /**
  116. * @brief Conversion of a rotation matrix to equivalent quaternion.
  117. * @param[in] pInputRotations points to an array 3x3 rotation matrix (in row order)
  118. * @param[out] pOutputQuaternions points to an array of quaternions
  119. * @param[in] nbQuaternions in the array
  120. */
  121. void arm_rotation2quaternion_f32(const float32_t *pInputRotations,
  122. float32_t *pOutputQuaternions,
  123. uint32_t nbQuaternions);
  124. #ifdef __cplusplus
  125. }
  126. #endif
  127. #endif /* ifndef _QUATERNION_MATH_FUNCTIONS_H_ */