34#include <NDEVR/Angle.h>
35#include <NDEVR/Vector.h>
59 template<
class t_type_a,
class t_type_b>
60 constexpr static bool operator>(
const Angle<t_type_a>&
angle_a,
const Angle<t_type_b>&
angle_b)
65 template<
class t_type_a,
class t_type_b>
66 constexpr static bool operator<(
const Angle<t_type_a>&
angle_a,
const Angle<t_type_b>&
angle_b)
86 template<
class t_type_a,
class t_type_b>
87 constexpr static bool operator>=(
const Angle<t_type_a>&
angle_a,
const Angle<t_type_b>&
angle_b)
92 template<
class t_type_a,
class t_type_b>
93 constexpr static bool operator<=(
const Angle<t_type_a>&
angle_a,
const Angle<t_type_b>&
angle_b)
112 template<
class t_type>
133 template<
class t_type>
136 return ::sin(angle.template as<RADIANS>());
153 template<
class t_type>
157 return sin(internal_angle);
160 template<
class t_type>
163 return ::cos(angle.template as<RADIANS>());
181 template<
class t_type>
184 return sin(angle) /
cos(angle);
187 template<
class t_type>
190 return ::tan(angle.template as<RADIANS>());
207 template<
class t_type>
208 t_type
sin(
const t_type& angle)
227 template<
class t_type>
228 t_type
cos(
const t_type& angle)
247 template<
class t_type>
248 t_type
tan(
const t_type& angle)
268 template<
class t_type>
269 constexpr static Angle<t_type> operator-(
const Angle<t_type>&
angle_a,
const Angle<t_type>&
angle_b)
288 template<
class t_type>
289 constexpr static Angle<t_type> operator+(
const Angle<t_type>&
angle_a,
const Angle<t_type>&
angle_b)
294 template<
class t_type>
295 constexpr static Angle<t_type> difference(
const Angle<t_type>&
angle_a,
const Angle<t_type>&
angle_b)
298 if (angle <= Angle<t_type>(
DEGREES, 180.0f))
301 return Angle<t_type>(
DEGREES, -360.0f) + angle;
303 template<u
int01 t_dims,
class t_type>
304 constexpr static Vector<t_dims, Angle<t_type>> difference(
const Vector<t_dims, Angle<t_type>>&
angle_a,
const Vector<t_dims, Angle<t_type>>&
angle_b)
306 Vector<t_dims, Angle<t_type>> angle;
307 for (
uint01 dim = 0; dim < t_dims; ++dim)
314 template<
class t_type>
315 constexpr static Angle<t_type> Average(
const Angle<t_type>&
angle_a,
const Angle<t_type>&
angle_b)
322 template<u
int01 t_dims,
class t_type>
323 constexpr static Vector<t_dims, Angle<t_type>> Average(
const Vector<t_dims, Angle<t_type>>&
angle_a,
const Vector<t_dims, Angle<t_type>>&
angle_b)
325 Vector<t_dims, Angle<t_type>> angle;
326 for (
uint01 dim = 0; dim < t_dims; ++dim)
349 template<
class t_type>
350 constexpr static Angle<t_type> operator*(
const Angle<t_type>&
angle_a,
const Angle<t_type>&
angle_b)
370 template<
class t_type>
391 template<
class t_type,
class t_angle_type>
392 constexpr static Angle<t_angle_type> operator*(
const Angle<t_angle_type>& angle, t_type mult)
396 template<
class t_type,
class t_angle_type>
397 constexpr static Angle<t_angle_type> operator*(t_type mult,
const Angle<t_angle_type>& angle)
401 template<
class t_type,
class t_vector_type>
402 constexpr typename std::enable_if<IsVecType<t_vector_type, Angle<fltp08>>::value, t_vector_type>::type
403 operator*(
const t_vector_type& angle,
const t_type& mult)
405 t_vector_type product;
406 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); ++dim)
407 product[dim] = angle[dim] * mult;
410 template<
class t_type,
class t_vector_type>
411 constexpr typename std::enable_if<IsVecType<t_vector_type, Angle<sint04>>::value, t_vector_type>::type
412 operator*(
const t_vector_type& angle,
const t_type& mult)
414 t_vector_type product;
415 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); ++dim)
416 product[dim] = angle[dim] * mult;
419 template<u
int01 t_dims,
class t_type,
class t_vector_type>
420 constexpr typename std::enable_if<std::is_base_of<Vector<t_dims, Angle<fltp08>>, t_vector_type>::value, t_vector_type>::type
423 t_vector_type product;
424 for (
uint01 dim = 0; dim < t_dims; ++dim)
425 product[dim] = angle[dim] * mult[dim];
428 template<u
int01 t_dims,
class t_type,
class t_vector_type>
429 constexpr typename std::enable_if<std::is_base_of<Vector<t_dims, Angle<sint04>>, t_vector_type>::value, t_vector_type>::type
432 t_vector_type product;
433 for (
uint01 dim = 0; dim < t_dims; ++dim)
434 product[dim] = angle[dim] * mult[dim];
452 template<
class t_type,
class t_angle_type>
453 constexpr static Angle<t_angle_type> operator/(
const Angle<t_angle_type>& num, t_type den)
457 template<
class t_type,
class t_vector_type,
class t_angle_type>
458 constexpr typename std::enable_if<IsVecType<t_vector_type, Angle<t_angle_type>>::value, t_vector_type>::type
459 operator/(
const t_vector_type& angle,
const t_type& den)
462 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); ++dim)
463 div[dim] = angle[dim] / den;
466 template<
class t_type,
class t_vector_type>
467 constexpr typename std::enable_if<IsVecType<t_vector_type, Angle<fltp08>>::value, t_vector_type>::type
468 operator/(
const t_vector_type& angle,
const t_type& den)
471 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); ++dim)
472 div[dim] = angle[dim] / den;
475 template<
class t_type,
class t_vector_type>
476 constexpr typename std::enable_if<IsVecType<t_vector_type, Angle<sint04>>::value, t_vector_type>::type
477 operator/(
const t_vector_type& angle,
const t_type& den)
480 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); ++dim)
481 div[dim] = angle[dim] / den;
484 template<u
int01 t_dims,
class t_type,
class t_vector_type,
class t_angle_type>
485 constexpr typename std::enable_if<std::is_base_of<Vector<t_dims, Angle<t_angle_type>>, t_vector_type>::value, t_vector_type>::type
489 for (
uint01 dim = 0; dim < t_dims; ++dim)
490 div[dim] = angle[dim] / den[dim];
493 template<u
int01 t_dims,
class t_vector_type,
class t_angle_type>
494 constexpr typename std::enable_if<std::is_base_of<Vector<t_dims, Angle<t_angle_type>>, t_vector_type>::value, Vector<t_dims, fltp08>>::type
498 for (
uint01 dim = 0; dim < t_dims; ++dim)
499 div[dim] = angle[dim] / den[dim];
502 template<u
int01 t_dims,
class t_angle_type>
506 for (
uint01 dim = 0; dim < t_dims; ++dim)
507 div[dim] = angle[dim] / den[dim];
525 template<
class t_type,
class t_vector_type>
526 constexpr typename std::enable_if<IsVecType<t_vector_type, Angle<fltp08>>::value, t_vector_type>::type
527 operator*(
const t_type& mult,
const t_vector_type& angle)
529 t_vector_type product;
530 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); ++dim)
531 product[dim] = mult * angle[dim];
534 template<
class t_type,
class t_vector_type>
535 constexpr typename std::enable_if<IsVecType<t_vector_type, Angle<sint04>>::value, t_vector_type>::type
536 operator*(
const t_type& mult,
const t_vector_type& angle)
538 t_vector_type product;
539 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); ++dim)
540 product[dim] = mult * angle[dim];
543 template<u
int01 t_dims,
class t_type,
class t_vector_type>
544 constexpr typename std::enable_if<std::is_base_of<Vector<t_dims, Angle<fltp08>>, t_vector_type>::value, t_vector_type>::type
547 t_vector_type product;
548 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); ++dim)
549 product[dim] = mult[dim] * angle[dim];
552 template<u
int01 t_dims,
class t_type,
class t_vector_type>
553 constexpr typename std::enable_if<std::is_base_of<Vector<t_dims, Angle<sint04>>, t_vector_type>::value, t_vector_type>::type
556 t_vector_type product;
557 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); ++dim)
558 product[dim] = mult[dim] * angle[dim];
561 template<
class t_type,
class t_vector_type>
562 constexpr typename std::enable_if<IsVecType<t_vector_type, Angle<fltp08>>::value, t_vector_type>::type
563 operator*(
const t_vector_type& mult,
const t_vector_type& angle)
565 t_vector_type product;
566 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); ++dim)
567 product[dim] = mult[dim] * angle[dim];
570 template<
class t_type,
class t_vector_type>
571 constexpr typename std::enable_if<IsVecType<t_vector_type, Angle<sint04>>::value, t_vector_type>::type
572 operator*(
const t_vector_type& mult,
const t_vector_type& angle)
574 t_vector_type product;
575 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); ++dim)
576 product[dim] = mult[dim] * angle[dim];
594 template<
class t_type,
class t_angle_type>
595 constexpr static Angle<t_angle_type> operator/(t_type num,
const Angle<t_angle_type>& den)
599 template<
class t_type,
class t_vector_type,
class t_angle_type>
600 constexpr typename std::enable_if<IsVecType<t_vector_type, Angle<t_angle_type>>::value, t_vector_type>::type
601 operator/(t_type num,
const t_vector_type& angle)
604 for (
uint01 dim = 0; dim < t_vector_type::NumberOfDimensions(); ++dim)
605 div[dim] = num / angle[dim];
625 template<
class t_angle_type>
626 constexpr static Angle<t_angle_type>& operator+=(Angle<t_angle_type>& angle,
const Angle<t_angle_type>& add)
647 template<
class t_angle_type>
648 constexpr static Angle<t_angle_type>& operator-=(Angle<t_angle_type>& angle,
const Angle<t_angle_type>& sub)
669 template<
class t_type,
class t_angle_type>
670 constexpr static Angle<t_angle_type>& operator*=(Angle<t_angle_type>& angle,
const t_type& mult)
672 angle = angle * mult;
675 template<u
int01 t_dims,
class t_type,
class t_angle_type>
676 constexpr static Vector<t_dims, Angle<t_angle_type>>& operator*=(Vector<t_dims, Angle<t_angle_type>>& angle,
const t_type& mult)
678 for (
uint01 dim = 0; dim < t_dims; ++dim)
679 angle[dim] = angle[dim] * mult;
682 template<u
int01 t_dims,
class t_type,
class t_angle_type>
683 constexpr static Vector<t_dims, Angle<t_angle_type>>& operator*=(Vector<t_dims, Angle<t_angle_type>>& angle,
const Vector<t_dims, t_type>& mult)
685 for (
uint01 dim = 0; dim < t_dims; ++dim)
686 angle[dim] = angle[dim] * mult[dim];
705 template<
class t_angle_type>
706 constexpr static Angle<t_angle_type>& operator*=(Angle<t_angle_type>& angle,
const Angle<t_angle_type>& mult)
708 angle = angle * mult;
712 template<
class t_type,
class t_angle_type>
713 constexpr static Angle<t_angle_type>& operator/=(Angle<t_angle_type>& angle,
const t_type& mult)
715 angle = angle / mult;
718 template<u
int01 t_dims,
class t_type,
class t_angle_type>
719 constexpr static Vector<t_dims, Angle<t_angle_type>>& operator/=(Vector<t_dims, Angle<t_angle_type>>& angle,
const t_type& den)
721 for (
uint01 dim = 0; dim < t_dims; ++dim)
722 angle[dim] = angle[dim] / den;
725 template<u
int01 t_dims,
class t_type,
class t_angle_type>
726 constexpr static Vector<t_dims, Angle<t_angle_type>>& operator/=(Vector<t_dims, Angle<t_angle_type>>& angle,
const Vector<t_dims, t_type>& den)
728 for (
uint01 dim = 0; dim < t_dims; ++dim)
729 angle[dim] = angle[dim] / den[dim];
733 template<u
int01 t_dims,
class t_angle_type>
737 for (
uint01 dim = 0; dim < t_dims; ++dim)
741 template<u
int01 t_dims,
class t_angle_type>
745 for (
uint01 dim = 0; dim < t_dims; ++dim)
749 template<
class t_angle_type>
757 template<
class t_new_type, u
int01 t_dims,
class t_angle_type>
761 for(
uint01 dim = 0; dim < t_dims; ++dim)
762 angle[dim] = old[dim].
template toTypeAngle<t_new_type>();
814 template<
class t_angle_type, u
int01 t_dims,
class t_type>
836 template<
class t_angle_type>
842 template<
class t_angle_type, u
int01 t_dims,
class t_type>
849 template<
class t_angle_type, u
int01 t_dims,
class t_type>
855 template<
class t_angle_type, u
int01 t_dims,
class t_type>
859 for (
uint01 i = 0; i < t_dims; i++)
861 return orient_vector;
863 template<
bool t_normalized, u
int01 t_dims,
class t_angle_type>
867 for (
uint01 i = 0; i < t_dims; i++)
868 orient_vector[i] = ray[i].as(angle_type);
869 return orient_vector;
887 template<
class t_angle_type,
class t_type>
892 if (::fabs(
cos(pitch)) < 0.001)
894 else if (::fabs(
cos(yaw)) < 0.01)
903 template<
class t_angle_type>
906 fltp08 suggested_pitch_value = angle[
PITCH].template as<DEGREES>();
907 fltp08 our_pitch_value = reference[
PITCH].template as<DEGREES>();
909 fltp08 suggested_yaw_value = angle[
YAW].template as<DEGREES>();
910 fltp08 our_yaw_value = reference[
YAW].template as<DEGREES>();
912 fltp08 suggested_roll_value = angle[
ROLL].template as<DEGREES>();
913 fltp08 our_roll_value = reference[
ROLL].template as<DEGREES>();
915 if (suggested_pitch_value - our_pitch_value > 180)
916 our_pitch_value += 360;
917 else if (our_pitch_value - suggested_pitch_value > 180)
918 suggested_pitch_value += 360;
920 if (suggested_yaw_value - our_yaw_value > 180)
921 our_yaw_value += 360;
922 else if (our_yaw_value - suggested_yaw_value > 180)
923 suggested_yaw_value += 360;
925 if (suggested_roll_value - our_roll_value > 180)
926 our_roll_value += 360;
927 else if (our_roll_value - suggested_roll_value > 180)
928 suggested_roll_value += 360;
930 bool flip = ::abs(suggested_roll_value - our_roll_value) >= 90.0f && ::abs(suggested_yaw_value - our_yaw_value) >= 90.0f;
951 static const fltp08* CalcIndexSin();
954 template<u
int01 t_dims,
class t_angle_type>
960 template<u
int01 t_dims,
class t_angle_type>
Logic for converting between Euler angles and basic rotations or normals.
Definition AngleFunctions.h:777
static Vector< 3, Angle< t_angle_type > > NormalToOrientation(const Vector< 3, t_type > &normal, const Angle< t_angle_type > &yaw=Angle< t_angle_type >(0))
Definition AngleFunctions.h:888
static Vector< 3, Angle< t_angle_type > > NormalizeOrientation(Vector< 3, Angle< t_angle_type > > angle, const Vector< 3, Angle< t_angle_type > > &reference)
Definition AngleFunctions.h:904
static constexpr Angle< t_angle_type > Heading(const Vector< t_dims, t_type > ray)
Definition AngleFunctions.h:850
static constexpr Vector< t_dims, fltp08 > Orientation(AngleType angle_type, const Vector< t_dims, Angle< t_angle_type > > &ray)
Definition AngleFunctions.h:864
static Angle< t_angle_type > Rotation(const Vector< t_dims, t_type > &left, const Vector< t_dims, t_type > &middle, const Vector< t_dims, t_type > &right)
Definition AngleFunctions.h:815
static Angle< t_angle_type > Inclination(const Angle< t_angle_type > &roll, const Angle< t_angle_type > &pitch)
Definition AngleFunctions.h:837
static constexpr Vector< t_dims, Angle< t_angle_type > > Orientation(AngleType angle_type, const Vector< t_dims, t_type > &ray)
Definition AngleFunctions.h:856
static constexpr Angle< t_angle_type > Inclination(const Vector< t_dims, t_type > ray)
Definition AngleFunctions.h:843
Stores an angle in an optimized format.
Definition StringStream.h:352
An element of a vector space. An element of the real coordinate space Rn Basis vector,...
Definition Vector.hpp:62
constexpr t_type magnitudeSquared() const
Definition Vector.hpp:458
std::enable_if<!ObjectInfo< t_type >::Float, fltp08 >::type tan(const Angle< t_type > &angle)
Definition AngleFunctions.h:182
t_type dot(const Vector< t_dims, t_type > &v1, const Vector< t_dims, t_type > &v2)
Definition VectorFunctions.hpp:1096
@ ROLL
Definition Angle.h:51
@ YAW
Definition Angle.h:53
@ PITCH
Definition Angle.h:52
constexpr Vector< t_dims, Angle< t_angle_type > > quantize(const Vector< t_dims, Angle< t_angle_type > > &value, Angle< t_angle_type > d=Angle< t_angle_type >(DEGREES, 1.0))
Definition AngleFunctions.h:955
@ angle_b
Definition Triangle.hpp:61
@ angle_a
Definition Triangle.hpp:60
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:98
AngleType
The possible units that can be used by the angle class. These are returned and used for real world an...
Definition Angle.h:64
@ RADIANS
Definition Angle.h:65
@ DEGREES
Definition Angle.h:66
@ INTERNAL_ANGLE
Definition Angle.h:67
std::enable_if<!ObjectInfo< t_type >::Float, fltp08 >::type cos(const Angle< t_type > &angle)
Definition AngleFunctions.h:154
constexpr Vector< t_dims, Angle< t_new_type > > ToTypeAngle(const Vector< t_dims, Angle< t_angle_type > > &old)
Definition AngleFunctions.h:758
NDEVR_BASE_API const fltp08 *const s_index_sin
Definition AngleFunctions.cpp:35
t_type sqrt(const t_type &value)
Definition VectorFunctions.hpp:1309
constexpr t_to cast(const Angle< t_from > &value)
Definition Angle.h:514
uint16_t uint02
-Defines an alias representing a 2 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:109
constexpr Angle< t_angle_type > abs(const Angle< t_angle_type > &value)
Definition AngleFunctions.h:750
std::enable_if<!ObjectInfo< t_type >::Float, fltp08 >::type sin(const Angle< t_type > &angle)
Definition AngleFunctions.h:113
constexpr Vector< t_dims, Angle< t_angle_type > > operator%(const Vector< t_dims, Angle< t_angle_type > > &vec_a, const Vector< t_dims, Angle< t_angle_type > > &vec_b)
Definition AngleFunctions.h:734
@ Y
Definition BaseValues.hpp:202
@ X
Definition BaseValues.hpp:200
@ Z
Definition BaseValues.hpp:204
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:181