/**
 * Convert cartesian coordinates to polar coordinates.
 *
 * @param x The x-coordinate.
 * @param y The y-coordinate.
 * @return The (theta, r) polar coordinates in radians and distance from the origin.
 */
import kotlin.math.atan2
import kotlin.math.sqrt


fun cartesianToPolar(x: Double, y: Double): Pair<Double, Double> {

    val theta = atan2(y, x)
    val r = sqrt(x * x + y * y)
    return Pair(theta, r)
}
import kotlin.math.atan2
import kotlin.math.sqrt

/**
 * Convert cartesian coordinates to polar coordinates.
 *
 * @param x The x-coordinate.
 * @param y The y-coordinate.
 * @return The (theta, r) polar coordinates in radians and distance from the origin.
 */
fun cartesianToPolar(x: Double, y: Double): Pair<Double, Double> {
import kotlin.math.atan2
import kotlin.math.sqrt

/**
 * Convert cartesian coordinates to polar coordinates.
 *
 * @param x The x-coordinate.
 * @param y The y-coordinate.
 * @return The (theta, r) polar coordinates in radians and distance from the origin.
 */
fun cartesianToPolar(x: Double, y: Double): Pair<Double, Double> {

    val theta = atan2(y, x)
    val r = sqrt(x * x + y * y)
    return Pair(theta, r)
}