33#include <NDEVR/BaseValues.h>
34#include <NDEVR/BufferBase.h>
67 template<
class t_
float_type>
68 static constexpr t_float_type
PI()
81 template<
class t_type = fltp08>
97 : m_index_angle(angle.m_index_angle)
103 template<
class t_other_type>
105 : m_index_angle(
cast<t_type>(angle.template
internal<false>()))
114 : m_index_angle(ConvertToInternal(
type, value))
123 : m_index_angle(ConvertToInternal(
type, value))
130 constexpr explicit Angle(t_type value)
131 : m_index_angle(value)
140 template<AngleType t_angle_type>
143 switch (t_angle_type)
147 return Constant<fltp08>::Invalid;
157 return Constant<fltp08>::Invalid;
174 return Constant<fltp08>::Invalid;
182 template<
bool t_normalized>
185 if constexpr(t_normalized)
191 return m_index_angle;
197 template<
class t_new_type>
226 m_index_angle = angle.m_index_angle;
256 return Angle(-m_index_angle);
265 template<
class t_value_type>
276 template<
class t_value_type>
287 template<
class t_value_type>
299 template<
class t_value_type>
313 template<
class t_normal_type>
314 static constexpr typename std::enable_if<!ObjectInfo<t_normal_type>::Float, t_normal_type>
::type NormalizeInternal(t_normal_type value)
316 const t_normal_type angle = (value >= 0 ? value : -value) % (2 *
INDEX_PI);
328 template<
class t_normal_type>
329 static constexpr typename std::enable_if<ObjectInfo<t_normal_type>::Float, t_normal_type>
::type NormalizeInternal(t_normal_type value)
343 template<
class t_value_type>
344 static constexpr t_type ConvertToInternal(
AngleType type, t_value_type value)
358 t_type m_index_angle;
377 template<
class t_type>
387 template<
class t_type>
390 return IsInvalid(value.template internal<false>());
397 template<
class t_type>
400 return IsValid(value.template internal<false>());
407 template<
class t_to,
class t_from>
Stores an angle in an optimized internal format with support for efficient trigonometric operations.
constexpr Angle(AngleType type, fltp04 value)
Angle Constructor.
constexpr Angle(const Angle &angle)
Default copy constructor.
constexpr Angle(AngleType type, fltp08 value)
Angle Constructor.
static Angle asin(t_value_type value)
Computes the principal value of the arc sine of the given value.
constexpr Angle(const Angle< t_other_type > &angle)
Explicit conversion of an angle from one container type to another.
constexpr bool operator!=(const Angle &angle) const
Inequality operator.
static Angle atan(t_value_type value)
Computes the principal value of the arc tangent of the given value.
static Angle acos(t_value_type value)
Computes the principal value of the arc cosine of the given value.
constexpr Angle normalized() const
returns the normalized angle which lies from 0 to 360 degrees.
constexpr Angle & operator=(const Angle &angle)
constexpr Angle normalizedOffset() const
returns the normalized angle which lies from -180 to 180 degrees.
constexpr bool operator==(const Angle &angle) const
Equality operator.
constexpr fltp08 as() const
Returns a form of this angle as a given type (Radian, Degree, Percent, etc) The template t_type provi...
static Angle atan2(t_value_type x, t_value_type y)
measures the counterclockwise angle between the positive x-axis and the point (x, y)
static constexpr fltp08 INV_INDEX_PI
Precomputed inverse of INDEX_PI used for converting internal angles to other representations.
constexpr t_type internal() const
Gets the internal index angle which is the default storage unit for the angle data.
constexpr fltp08 as(AngleType type) const
Returns a form of this angle as a given type (Radian, Degree, Percent, etc).
static constexpr sint04 INDEX_PI
Optimized angle constant representing PI; allows integers to store angles to some degree of accuracy.
constexpr Angle(t_type value)
Constructor.
constexpr Angle< t_new_type > toTypeAngle() const
Explicit conversion of an angle from one container type to another.
Angle operator-() const
negates the angle
constexpr Angle()
Default constructor, creates an angle with 0 degrees.
The primary namespace for the NDEVR SDK.
EulerPosition
Values that represent euler angles.
@ YAW
Rotation about the vertical axis (Z).
@ PITCH
Rotation about the lateral axis (Y).
@ ROLL
Rotation about the forward axis (X).
@ type
The type identifier string for this model node.
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
static constexpr bool IsValid(const Angle< t_type > &value)
Checks whether the given Angle holds a valid value.
constexpr HSLColor Constant< HSLColor >::Invalid
The invalid HSLColor constant with all components set to invalid.
double fltp08
Defines an alias representing an 8 byte floating-point number.
int32_t sint04
-Defines an alias representing a 4 byte, signed integer.
AngleType
The possible units that can be used by the angle class.
@ PERCENT
Angle measured as a percentage (0.0 to 1.0 for a full circle).
@ DEGREES
Angle measured in degrees (0 to 360 for a full circle).
@ INTERNAL_ANGLE
The angle internally used by the angle class.
@ RADIANS
Angle measured in radians (0 to 2*PI for a full circle).
constexpr HSLColor Constant< HSLColor >::Max
The maximum HSLColor constant with all components at their maximum values.
static constexpr t_float_type PI()
Returns the value of PI to a given precision.
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
static constexpr bool IsInvalid(const Angle< t_type > &value)
Checks whether the given Angle holds an invalid value.
t_type sqrt(const t_type &value)
constexpr HSLColor Constant< HSLColor >::Min
The minimum HSLColor constant with saturation, brightness, and alpha at zero.
Angle< t_type > asqrt(const Angle< t_type > &value)
Computes the square root of the internal representation of an angle.
constexpr t_to cast(const Angle< t_from > &value)
Casts an Angle from one backing type to another.
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...
static const bool Pointer
Whether this type is a pointer.
static const bool Vector
Whether this type is a vector.
static constexpr ObjectInfo< Angle< fltp04 >, false, false > VectorSub()
Returns the ObjectInfo for the sub-element type of a vector.
static const bool Unsigned
Whether this type is unsigned.
static const bool Color
Whether this type is a color.
static const bool Primitive
Whether this type is a primitive value.
static const bool Float
Whether this type behaves as a floating-point value.
static const bool Buffer
Whether this type is a buffer.
static const bool Integer
Whether this type is an integer.
static const bool Number
Whether this type is numeric.
static const uint01 Dimensions
Number of vector dimensions (0 for scalar).
static const bool String
Whether this type is a string.
static const bool Boolean
Whether this type is a boolean.
static const bool String
Whether this type is a string.
static const bool Primitive
Whether this type is a primitive value.
static const uint01 Dimensions
Number of vector dimensions (0 for scalar).
static const bool Buffer
Whether this type is a buffer.
static const bool Pointer
Whether this type is a pointer.
static const bool Unsigned
Whether this type is unsigned.
static constexpr ObjectInfo< Angle< fltp08 >, false, false > VectorSub()
Returns the ObjectInfo for the sub-element type of a vector.
static const bool Float
Whether this type behaves as a floating-point value.
static const bool Integer
Whether this type is an integer.
static const bool Boolean
Whether this type is a boolean.
static const bool Number
Whether this type is numeric.
static const bool Vector
Whether this type is a vector.
static const bool Color
Whether this type is a color.
static const bool Color
Whether this type is a color.
static const bool Number
Whether this type is numeric.
static const bool Pointer
Whether this type is a pointer.
static const bool Float
Whether this type behaves as a floating-point value.
static const bool String
Whether this type is a string.
static constexpr ObjectInfo< Angle< sint04 >, false, false > VectorSub()
Returns the ObjectInfo for the sub-element type of a vector.
static const bool Primitive
Whether this type is a primitive value.
static const bool Vector
Whether this type is a vector.
static const bool Buffer
Whether this type is a buffer.
static const bool Boolean
Whether this type is a boolean.
static const bool Integer
Whether this type is an integer.
static const bool Unsigned
Whether this type is unsigned.
static const uint01 Dimensions
Number of vector dimensions (0 for scalar).
Information about the object.