/home/runner/work/kynema/kynema/kynema/src/math/quaternion_operations.hpp File Reference

Kynema API: /home/runner/work/kynema/kynema/kynema/src/math/quaternion_operations.hpp File Reference
Kynema API
A flexible multibody structural dynamics code for wind turbines
Loading...
Searching...
No Matches
quaternion_operations.hpp File Reference
#include <array>
#include <cmath>
#include <iterator>
#include <numbers>
#include <ranges>
#include <span>
#include <Kokkos_Core.hpp>
#include "vector_operations.hpp"

Go to the source code of this file.

Namespaces

namespace  kynema
 
namespace  kynema::math
 

Functions

template<typename Quaternion , typename RotationMatrix >
KOKKOS_INLINE_FUNCTION void kynema::math::QuaternionToRotationMatrix (const Quaternion &q, const RotationMatrix &R)
 Converts a 4x1 quaternion to a 3x3 rotation matrix and returns the result.
 
std::array< std::array< double, 3 >, 3 > kynema::math::QuaternionToRotationMatrix (const std::array< double, 4 > &q)
 Converts a 4x1 quaternion to a 3x3 rotation matrix and returns the result.
 
std::array< double, 4 > kynema::math::RotationMatrixToQuaternion (const std::array< std::array< double, 3 >, 3 > &m)
 Converts a 3x3 rotation matrix to a 4x1 quaternion and returns the result, see https://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/ for implementation details.
 
template<typename Quaternion , typename View1 , typename View2 >
KOKKOS_INLINE_FUNCTION void kynema::math::RotateVectorByQuaternion (const Quaternion &q, const View1 &v, const View2 &v_rot)
 Rotates provided vector by provided unit quaternion and returns the result.
 
std::array< double, 3 > kynema::math::RotateVectorByQuaternion (std::span< const double, 4 > q, std::span< const double, 3 > v)
 Rotates provided vector by provided unit quaternion and returns the result.
 
template<typename Quaternion , typename Matrix >
KOKKOS_INLINE_FUNCTION void kynema::math::QuaternionDerivative (const Quaternion &q, const Matrix &m)
 Computes the derivative of a quaternion and stores the result in a 3x4 matrix.
 
template<typename QuaternionInput , typename QuaternionOutput >
KOKKOS_INLINE_FUNCTION void kynema::math::QuaternionInverse (const QuaternionInput &q_in, const QuaternionOutput &q_out)
 Computes the inverse of a quaternion.
 
std::array< double, 4 > kynema::math::QuaternionInverse (std::span< const double, 4 > quaternion)
 Computes the inverse of a quaternion.
 
template<typename Quaternion1 , typename Quaternion2 , typename QuaternionN >
KOKKOS_INLINE_FUNCTION void kynema::math::QuaternionCompose (const Quaternion1 &q1, const Quaternion2 &q2, QuaternionN &qn)
 Composes (i.e. multiplies) two quaternions and stores the result in a third quaternion.
 
std::array< double, 4 > kynema::math::QuaternionCompose (const std::array< double, 4 > &q1, const std::array< double, 4 > &q2)
 Composes (i.e. multiplies) two quaternions and returns the result.
 
template<typename Vector , typename Quaternion >
KOKKOS_INLINE_FUNCTION void kynema::math::RotationVectorToQuaternion (const Vector &phi, const Quaternion &quaternion)
 Returns a 4-D quaternion from provided 3-D rotation vector, i.e. the exponential map.
 
template<typename Quaternion , typename Vector >
KOKKOS_INLINE_FUNCTION void kynema::math::QuaternionToRotationVector (const Quaternion &quaternion, const Vector &phi)
 Returns a 3-D rotation vector from provided 4-D quaternion, i.e. the logarithmic map.
 
std::array< double, 3 > kynema::math::QuaternionToRotationVector (const std::array< double, 4 > &quaternion)
 Returns a 3-D rotation vector from provided 4-D quaternion.
 
std::array< double, 4 > kynema::math::RotationVectorToQuaternion (const std::array< double, 3 > &phi)
 Returns a 4-D quaternion from provided 3-D rotation vector, i.e. the exponential map.
 
KOKKOS_INLINE_FUNCTION Kokkos::Array< double, 4 > kynema::math::NormalizeQuaternion (const Kokkos::Array< double, 4 > &q)
 Normalizes a quaternion to ensure it is a unit quaternion.
 
std::array< double, 4 > kynema::math::TangentTwistToQuaternion (const std::array< double, 3 > &tangent, const double twist)
 Returns a 4-D quaternion from provided tangent vector and twist (degrees) about tangent.
 
std::array< double, 4 > kynema::math::AxisAngleToQuaternion (const std::array< double, 3 > &axis, double angle)
 Returns a quaternion from the axis vector and angle (radians)
 
bool kynema::math::IsIdentityQuaternion (const std::array< double, 4 > &q, double tolerance=1e-12)
 Checks if a quaternion is approximately the identity quaternion [1, 0, 0, 0].