kyosu v0.1.0
Complex Without Complexes
 
Loading...
Searching...
No Matches

◆ from_spherical

kyosu::from_spherical = {}
inlineconstexpr

Callable object computing a quaternion from its spherical representation.

This function build quaternions in a way similar to the way polar builds complex numbers from a spherical representation of an \(\mathbb{R}^4\) element.

from_spherical takes as inputs a (positive) magnitude and a point on the hypersphere, given by three angles. The first of these, theta has a natural range of \(-\pi\) to \(+\pi\), and the other two have natural ranges of \(-\pi/2\) to \(+\pi/2\) (as is the case with the usual spherical coordinates in \(\mathbb{R}^3\)).

Defined in header

#include eve/module/quaternion.hpp>`

Callable Signatures

namespace eve
{
auto from_spherical(auto rho, auto theta, auto phi1, auto phi2) const noexcept;
}
constexpr tags::callable_from_spherical from_spherical
Callable object computing a quaternion from its spherical representation.
Definition: from_spherical.hpp:100

Parameters

  • rho: the modulus
  • theta, phi1, phi2: angles in radian

Return value

the quaternion value


Example

#include <kyosu/kyosu.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
auto r = 2.0;
auto theta = eve::pio_3(eve::as(r));
auto phi1 = eve::pio_4(eve::as(r));
auto phi2 = eve::pio_2(eve::as(r));
std::cout << " <- r " << r << std::endl;
std::cout << " <- theta " << theta<< std::endl;
std::cout << " <- phi1 " << phi1<< std::endl;
std::cout << " <- phi2 " << phi2<< std::endl;
std::cout << " -> " << from_spherical(r, theta, phi1, phi2) << "\n";
return 0;
}
as_cayley_dickson_n_t< 4, T > quaternion_t
Type alias for quaternion numbers.
Definition: quaternion.hpp:27
as_cayley_dickson_n_t< 2, T > complex_t
Type alias for complex numbers.
Definition: complex.hpp:27