Template Function nebula::drivers::angle_is_between
Defined in File angles.hpp
Function Documentation
-
template<typename T>
inline bool nebula::drivers::angle_is_between(T start_angle, T end_angle, T angle, bool start_inclusive = true, bool end_inclusive = true) Tests if
angleis in the angular sector defined bystart_angleandend_angle.Assumes that all three angles are normalized to the interval [0; max_angle) before comparison. This function is unit-independent (max_angle can be 360 for degrees, 2 * M_PI for radians, 36000 for centi-degrees, etc.) as long as the above assumption is fulfilled.
If
start_angleequalsend_angle, the sector is considered to cover the full circle. In this case, anangleis always considered to be in the sector, except when it coincides with thestart_angle/end_angleand both boundaries are exclusive. There is no way to define a zero-width sector.When
start_angleandend_anglediffer,angleis considered to be in the sector ifstart_angle <= angle <= end_angle, orend_angle < start_angleand (angle <= end_angleorstart_angle <= angle)
Examples:
{c++} assert(angle_is_between(90, 270, 180) == true); assert(angle_is_between(270, 90, 0) == true); // wrap-around case assert(angle_is_between(0, 0, 0) == true); assert(angle_is_between(0, 0, 0, false, false) == false);