/**
 * Convert cartesian coordinates to polar coordinates.
 *
 * @param x x-coordinate of the point.
 * @param y y-coordinate of the point.
 * @return Pair where first element is the distance from the origin to the point (r) and
 *         second element is the angle made with the x-axis (theta).
 */
fun cartesianToPolar(x: Double, y: Double): Pair<Double, Double> {

    // Calculate distance from origin using Pythagoras' theorem
    val r = Math.sqrt(x * x + y * y)

    // Calculate the angle made with the x-axis using arctan2
    val theta = Math.atan2(y, x)

    return Pair(r, theta)
}
/**
 * Convert cartesian coordinates to polar coordinates.
 *
 * @param x x-coordinate of the point.
 * @param y y-coordinate of the point.
 * @return Pair where first element is the distance from the origin to the point (r) and
 *         second element is the angle made with the x-axis (theta).
 */
fun cartesianToPolar(x: Double, y: Double): Pair<Double, Double> {
/**
 * Convert cartesian coordinates to polar coordinates.
 *
 * @param x x-coordinate of the point.
 * @param y y-coordinate of the point.
 * @return Pair where first element is the distance from the origin to the point (r) and
 *         second element is the angle made with the x-axis (theta).
 */
fun cartesianToPolar(x: Double, y: Double): Pair<Double, Double> {

    // Calculate distance from origin using Pythagoras' theorem
    val r = Math.sqrt(x * x + y * y)

    // Calculate the angle made with the x-axis using arctan2
    val theta = Math.atan2(y, x)

    return Pair(r, theta)
}