21 #ifndef yap_CoordinateSystem_h
22 #define yap_CoordinateSystem_h
24 #include "fwd/CoordinateSystem.h"
32 #include <type_traits>
34 #define VECTOREPSILON 1e-10
39 template <
typename T,
size_t N>
40 std::string
to_string(
const CoordinateSystem<T, N>& C)
44 s.erase(s.size() - 2, 2);
51 template <
typename T,
size_t N>
52 const CoordinateSystem<T, N>
unit(
const CoordinateSystem<T, N>& C)
54 CoordinateSystem<T, N> uC;
55 std::transform(C.begin(), C.end(), uC.begin(), [](
const Vector<T, N>& c) {
return yap::unit<T, N>(c);});
61 template <
typename T,
size_t N>
62 const CoordinateSystem<T, N>
operator*(
const SquareMatrix<T, N>& M,
const CoordinateSystem<T, N>& C)
64 CoordinateSystem<T, N> MC;
65 std::transform(C.begin(), C.end(), MC.begin(), [&](
const Vector<T, N>& c) {
return M * c; });
78 return (norm(
unit(C[2]) -
unit(
cross(C[0], C[1]))) < VECTOREPSILON);
87 return (norm(
unit(C[2]) +
unit(
cross(C[0], C[1]))) < VECTOREPSILON);
94 constexpr T
phi(
const ThreeVector<T>& V,
const CoordinateSystem<T, 3>& C)
95 {
return angle(V - (V * C[2]) * C[2], C[0]) * ( ((V * C[1]) >= 0) ? T(1) : T(-1) ); }
100 template <
typename T>
101 constexpr T
theta(
const ThreeVector<T>& V,
const CoordinateSystem<T, 3>& C)
102 {
return angle(V, C[2]); }
108 template <
typename T>
109 constexpr std::array<T, 2>
angles(
const ThreeVector<T>& V,
const CoordinateSystem<T, 3>& C)
110 {
return std::array<T, 2> {
phi(V, C),
theta(V, C) }; }
constexpr bool isRightHanded(const CoordinateSystem< T, 3 > &C)
Definition: CoordinateSystem.h:75
constexpr std::array< T, 2 > angles(const ThreeVector< T > &V, const CoordinateSystem< T, 3 > &C)
Definition: CoordinateSystem.h:109
constexpr T theta(const ThreeVector< T > &V, const CoordinateSystem< T, 3 > &C)
Definition: CoordinateSystem.h:101
constexpr bool isLeftHanded(const CoordinateSystem< T, 3 > &C)
Definition: CoordinateSystem.h:84
const CoordinateSystem< T, N > operator*(const SquareMatrix< T, N > &M, const CoordinateSystem< T, N > &C)
Definition: CoordinateSystem.h:62
const CoordinateSystem< T, N > unit(const CoordinateSystem< T, N > &C)
Definition: CoordinateSystem.h:52
std::string to_string(const CachedValue::Status &S)
streaming operator for CachedValue::Status
Definition: CachedValue.cxx:27
constexpr T phi(const ThreeVector< T > &V, const CoordinateSystem< T, 3 > &C)
Definition: CoordinateSystem.h:94
constexpr ThreeVector< T > cross(const ThreeVector< T > &A, const ThreeVector< T > &B) noexcept
Definition: ThreeVector.h:33
N-dimensional column vector.
Definition: Vector.h:168