1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/// Transforms a global rotation angle to the local reference frame of a specified component.
///
/// This function converts a rotation angle specified in the global coordinate system to the
/// local reference frame of the robot component identified by `component_id`. It adjusts the
/// angle based on the orientation/location of the component within the robot's structure.
///
/// # Arguments
///
/// * `component_id` - The identifier of the robot component whose reference frame to use for transformation.
/// * `angle` - The rotation angle in degrees in the global coordinate system.
///
/// # Returns
///
/// The transformed rotation angle adjusted to the local reference frame of the specified component,
/// represented as a floating-point number in degrees.
///
/// # Examples
///
/// ```
/// let component_id = 1;
/// let global_angle = 45.0;
/// let local_angle = transform_rotation_to_component(component_id, global_angle);
/// ```
/// Transforms a rotation angle from the local reference frame of a component to the global coordinate system.
///
/// This function converts a rotation angle specified in the local reference frame of a robot component
/// (identified by `component_id`) to the global coordinate system. It adjusts the angle based on the
/// orientation of the component within the robot's structure.
///
/// # Arguments
///
/// * `component_id` - The identifier of the robot component whose local reference frame to use for transformation.
/// * `angle` - The rotation angle in degrees in the local reference frame of the component.
///
/// # Returns
///
/// The transformed rotation angle adjusted to the global coordinate system, represented as a floating-point number in degrees.
///
/// # Examples
///
/// ```
/// let component_id = 1;
/// let local_angle = 30.0;
/// let global_angle = transform_rotation_from_component(component_id, local_angle);
/// ```
/// Computes the angular distance between two angles.
///
/// This function calculates the smallest angular difference (distance) between two given angles,
/// taking into account the circular nature of angle measurements (0 to 360 degrees).
///
/// # Arguments
///
/// * `angle` - The first angle in degrees.
/// * `other_angle` - The second angle in degrees.
///
/// # Returns
///
/// The angular distance between the two angles as a floating-point number.
/// The returned value represents the smallest magnitude difference between the angles,
/// ranging from 0 to 180 degrees.
///
/// # Examples
///
/// ```
/// let angle1 = 30.0;
/// let angle2 = 350.0;
/// let distance = rbot::rotations::angle_distance(angle1, angle2);
/// rbot::print(&format!("Angular distance: {:.2} degrees", distance));
/// ```