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
use PI;
/// Computes the angle (in degrees) from the positive x-axis to a point (x, y) in the Cartesian plane.
///
/// This function calculates the angle formed by the positive x-axis and the vector pointing from the origin
/// (0, 0) to the point (x, y) specified by the coordinates `x` and `y`. The angle is measured in degrees
/// counter-clockwise from the positive x-axis.
///
/// # Arguments
///
/// * `x` - The x-coordinate of the point.
/// * `y` - The y-coordinate of the point.
///
/// # Returns
///
/// The angle in degrees from the positive x-axis to the point (x, y). The angle is in the range (-180, 180],
/// where positive angles represent counter-clockwise rotations and negative angles represent clockwise rotations.
///
/// # Examples
///
/// ```
/// let x = 1.0;
/// let y = 1.0;
/// let angle = xy_to_angle(x, y);
/// ```
/// Computes the Cartesian coordinates (x, y) corresponding to a given angle (in degrees) from the positive x-axis.
///
/// This function calculates the Cartesian coordinates (x, y) corresponding to a specified angle measured
/// in degrees from the positive x-axis. The angle determines the direction of a vector from the origin (0, 0)
/// to the point (x, y), where the length of the vector is 1 (unit vector).
///
/// # Arguments
///
/// * `angle` - The angle in degrees from the positive x-axis.
///
/// # Returns
///
/// An array `[x, y]` containing the Cartesian coordinates corresponding to the specified angle.
/// - `x` is the cosine of the angle.
/// - `y` is the sine of the angle.
///
/// # Examples
///
/// ```
/// let angle = 45.0;
/// let [x, y] = angle_to_xy(angle);
/// ```