Function angles::shortest_angular_distance_with_large_limits
Defined in File angles.h
Function Documentation
-
static inline bool angles::shortest_angular_distance_with_large_limits(double from, double to, double left_limit, double right_limit, double &shortest_angle)
Returns the delta from
from_angle
toto_angle
, making sure it does not violate limits specified byleft_limit
andright_limit
. This function is similar toshortest_angular_distance_with_limits()
, with the main difference that it accepts limits outside the[-M_PI, M_PI]
range. Even if this is quite uncommon, one could indeed consider revolute joints with large rotation limits, e.g., in the range[-2*M_PI, 2*M_PI]
.\function
In this case, a strict requirement is to have
left_limit
smaller thanright_limit
. Note also thatfrom
must lie inside the valid range, whileto
does not need to. In fact, this function will evaluate the shortest (valid) angleshortest_angle
so thatfrom+shortest_angle
equalsto
up to an integer multiple of2*M_PI
. As an example, a call toshortest_angular_distance_with_large_limits(0, 10.5*M_PI, -2*M_PI, 2*M_PI, shortest_angle)
will returntrue
, withshortest_angle=0.5*M_PI
. This is becausefrom
andfrom+shortest_angle
are both inside the limits, andfmod(to+shortest_angle, 2*M_PI)
equalsfmod(to, 2*M_PI)
. On the other hand,shortest_angular_distance_with_large_limits(10.5*M_PI, 0, -2*M_PI, 2*M_PI, shortest_angle)
will return false, sincefrom
is not in the valid range. Finally, note that the callshortest_angular_distance_with_large_limits(0, 10.5*M_PI, -2*M_PI, 0.1*M_PI, shortest_angle)
will also returntrue
. However,shortest_angle
in this case will be-1.5*M_PI
.- Parameters:
from – - “from” angle.
to – - “to” angle.
left_limit – - left limit of valid interval, must be smaller than right_limit.
right_limit – - right limit of valid interval, must be greater than left_limit.
shortest_angle – - result of the shortest angle calculation.
- Returns:
true if
left_limit < right_limit
and if “from” and “from+shortest_angle” positions are within the valid interval, false otherwise.