Function angles::shortest_angular_distance_with_limits
Defined in File angles.h
Function Documentation
-
static inline bool angles::shortest_angular_distance_with_limits(double from, double to, double left_limit, double right_limit, double &shortest_angle)
Returns the delta from “from_angle” to “to_angle” making sure it does not violate limits specified by left_limit and right_limit. The valid interval of angular positions is [left_limit,right_limit]. E.g., [-0.25,0.25] is a 0.5 radians wide interval that contains 0. But [0.25,-0.25] is a 2*M_PI-0.5 wide interval that contains M_PI (but not 0). The value of shortest_angle is the angular difference between “from” and “to” that lies within the defined valid interval. E.g. shortest_angular_distance_with_limits(-0.5,0.5,0.25,-0.25,ss) evaluates ss to 2*M_PI-1.0 and returns true while shortest_angular_distance_with_limits(-0.5,0.5,-0.25,0.25,ss) returns false since -0.5 and 0.5 do not lie in the interval [-0.25,0.25].
\function
- Parameters:
from – - “from” angle
to – - “to” angle
left_limit – - left limit of valid interval for angular position, left and right limits are specified on the unit circle w.r.t to a reference pointing inwards
right_limit – - right limit of valid interval for angular position, left and right limits are specified on the unit circle w.r.t to a reference pointing inwards
shortest_angle – - result of the shortest angle calculation
- Returns:
true if “from” and “to” positions are within the limit interval, false otherwise