44 const T&
real()
const;
45 const Col<T>&
imag()
const;
65 constexpr int ulp = 10000;
78 return std::forward<Quaternion>(
A);
89 , im(arma::zeros<Col<
T>>(3)) {}
101 , im(std::move(I)) {}
110 const auto magnitude = std::sqrt(
norm());
117 const auto L =
norm();
153 A.re = re * B.re - arma::dot(im, B.im);
154 A.im = re * B.im + B.re * im + arma::cross(im, B.im);
166 suanpan_info(
"re: {:+0.6E} im: {:+0.6E} {:+0.6E} {:+0.6E}\n", re, im(0), im(1), im(2));
178 vec rotation = re < 0. ? -im : im;
180 rotation *= 2. / norm_im * (norm_im < std::abs(re) ? std::asin(norm_im) : std::acos(std::abs(re)));
An Quaternion class.
Definition: Quaternion.hpp:34
friend bool operator==(const Quaternion &A, const Quaternion &B)
Definition: Quaternion.hpp:64
friend Quaternion operator-(Quaternion &&A)
Definition: Quaternion.hpp:75
friend Quaternion operator-(const Quaternion &A)
Definition: Quaternion.hpp:73
Quaternion inv() const
Definition: Quaternion.hpp:116
Quaternion operator-(const Quaternion &) const
Definition: Quaternion.hpp:137
Quaternion operator/(const Quaternion &) const
Definition: Quaternion.hpp:161
Quaternion operator*(const Quaternion &) const
Definition: Quaternion.hpp:150
Quaternion & normalise()
Definition: Quaternion.hpp:109
Quaternion & operator-=(const Quaternion &)
Definition: Quaternion.hpp:143
T norm() const
Definition: Quaternion.hpp:107
Col< T > to_pseudo() const
Definition: Quaternion.hpp:173
Quaternion operator+(const Quaternion &) const
Definition: Quaternion.hpp:124
Quaternion & operator*=(const Quaternion &)
Definition: Quaternion.hpp:159
const Col< T > & imag() const
Definition: Quaternion.hpp:105
Quaternion & operator/=(const Quaternion &)
Definition: Quaternion.hpp:163
Quaternion & operator+=(const Quaternion &)
Definition: Quaternion.hpp:130
const T & real() const
Definition: Quaternion.hpp:103
Quaternion()
Definition: Quaternion.hpp:87
Quaternion conj() const
Definition: Quaternion.hpp:122
Mat< T > to_mat() const
Definition: Quaternion.hpp:171
void print() const
Definition: Quaternion.hpp:165
std::enable_if_t<!std::numeric_limits< T >::is_integer, bool > approx_equal(T x, T y, int ulp=2)
Definition: utility.h:60
double norm(const vec &)
Definition: tensor.cpp:370
#define suanpan_info
Definition: suanPan.h:305