33#include <NDEVR/BaseValues.h>
34#include <NDEVR/LibAssert.h>
55 template <
typename t_type>
56 constexpr t_type
getMin(
const t_type& left,
const t_type& right) {
return left < right ? left : right; }
57 template <
typename t_type>
58 constexpr t_type
getMin(
const t_type& left,
const t_type& middle,
const t_type& right) {
return getMin(
getMin(left, middle), right); }
61 constexpr sint01 getMin(
const sint01& left,
const sint01& right) {
return left ^ ((right ^ left) & -(right < left)); }
66 constexpr sint02 getMin(
const sint02& left,
const sint02& right) {
return left ^ ((right ^ left) & -(right < left)); }
71 constexpr sint04 getMin(
const sint04& left,
const sint04& right) {
return left ^ ((right ^ left) & -(right < left)); }
76 constexpr sint08 getMin(
const sint08& left,
const sint08& right) {
return left ^ ((right ^ left) & -(right < left)); }
93 template <
typename t_type>
94 constexpr t_type
getMax(
const t_type& left,
const t_type& right) {
return left > right ? left : right; }
95 template <
typename t_type>
96 constexpr t_type
getMax(
const t_type& left,
const t_type& middle,
const t_type& right) {
return getMax(
getMax(left, middle), right); }
99 constexpr sint01 getMax(
const sint01& left,
const sint01& right) {
return left ^ ((left ^ right) & -(left < right)); }
104 constexpr sint02 getMax(
const sint02& left,
const sint02& right) {
return left ^ ((left ^ right) & -(left < right)); }
109 constexpr sint04 getMax(
const sint04& left,
const sint04& right) {
return left ^ ((left ^ right) & -(left < right)); }
114 constexpr sint08 getMax(
const sint08& left,
const sint08& right) {
return left ^ ((left ^ right) & -(left < right)); }
133 template <
typename t_type>
150 template <
typename t_type>
151 constexpr t_type
sign(t_type value)
156 template<
typename t_type>
157 constexpr t_type makeNiceNumberA(t_type value)
159 t_type magnitude = pow(10, std::floor(std::log10(value)));
160 t_type normalized_step = value / magnitude;
161 if (normalized_step <= 1.5)
162 normalized_step = 1.0;
163 else if (normalized_step <= 3.0)
164 normalized_step = 2.0;
165 else if (normalized_step <= 7.5)
166 normalized_step = 5.0;
168 normalized_step = 10.0;
169 return normalized_step * magnitude;
171 template<
typename t_type>
172 constexpr t_type makeNiceNumberB(t_type value)
174 t_type magnitude = pow(10, std::floor(std::log10(value)));
175 t_type normalized_step = value / magnitude;
176 if (normalized_step <= 1.025)
177 normalized_step = 1.0;
178 else if (normalized_step <= 1.075)
179 normalized_step = 1.05;
181 normalized_step = 0.1 * std::round(10.0 * normalized_step);
182 return normalized_step * magnitude;
196 template<
class t_type>
199 return value == Constant<t_type>::Invalid;
205 return value != value;
211 return value != value;
213 template<
class t_type>
214 constexpr bool IsValid(
const t_type& value)
237 template <
typename t_type>
238 constexpr t_type
clip(
const t_type& value,
const t_type& lower_bound,
const t_type& upper_bound)
240 lib_assert(
IsInvalid(lower_bound) ||
IsInvalid(upper_bound) || (lower_bound <= upper_bound),
"Invalid clip: upper bound is less than lower bound");
The primary namespace for the NDEVR SDK.
constexpr t_type getMin(const t_type &left, const t_type &right)
Finds the minimum of the given arguments based on the < operator Author: Tyler Parke Date: 2017-11-05...
constexpr t_type sign(t_type value)
A simple function that returns 1 for all values greater than or equal to 0 and -1 for all values less...
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
constexpr t_type getMax(const t_type &left, const t_type &right)
Finds the max of the given arguments using the > operator The only requirement is that t_type have > ...
static constexpr bool IsValid(const Angle< t_type > &value)
Checks whether the given Angle holds a valid value.
uint16_t uint02
-Defines an alias representing a 2 byte, unsigned integer -Can represent exact integer values 0 throu...
uint64_t uint08
-Defines an alias representing an 8 byte, unsigned integer
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))
Quantizes a Vector of Angles to the nearest multiple of a given step size.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
double fltp08
Defines an alias representing an 8 byte floating-point number.
int16_t sint02
-Defines an alias representing a 2 byte, signed integer.
int32_t sint04
-Defines an alias representing a 4 byte, signed integer.
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.
int8_t sint01
-Defines an alias representing a 1 byte, signed integer.
constexpr t_type clip(const t_type &value, const t_type &lower_bound, const t_type &upper_bound)
Clips the value given so that that the returned value falls between upper and lower bound.
int64_t sint08
-Defines an alias representing an 8 byte, signed integer -Can represent exact integer values -9223372...
constexpr t_to cast(const Angle< t_from > &value)
Casts an Angle from one backing type to another.