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_angletoto_angle, making sure it does not violate limits specified byleft_limitandright_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_limitsmaller thanright_limit. Note also thatfrommust lie inside the valid range, whiletodoes not need to. In fact, this function will evaluate the shortest (valid) angleshortest_angleso thatfrom+shortest_angleequalstoup 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 becausefromandfrom+shortest_angleare 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, sincefromis 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_anglein 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_limitand if “from” and “from+shortest_angle” positions are within the valid interval, false otherwise.