/**
 * Calculate the area of a polygon given its coordinates.
 *
 * @param coordinates A list of tuples representing the coordinates of the vertices of the polygon.
 * @return The area of the polygon.
 */
fun calculatePolygonArea(coordinates: List<Pair<Double, Double>>): Double {

    var area = 0.0
    val n = coordinates.size

    for (i in 0 until n) {
        val (x_i, y_i) = coordinates[i]
        val (x_j, y_j) = coordinates[(i + 1) % n]

        area += (x_i * y_j) - (x_j * y_i)
    }

    area = Math.abs(area) / 2

    return area
}
/**
 * Calculate the area of a polygon given its coordinates.
 *
 * @param coordinates A list of tuples representing the coordinates of the vertices of the polygon.
 * @return The area of the polygon.
 */
fun calculatePolygonArea(coordinates: List<Pair<Double, Double>>): Double {
/**
 * Calculate the area of a polygon given its coordinates.
 *
 * @param coordinates A list of tuples representing the coordinates of the vertices of the polygon.
 * @return The area of the polygon.
 */
fun calculatePolygonArea(coordinates: List<Pair<Double, Double>>): Double {

    var area = 0.0
    val n = coordinates.size

    for (i in 0 until n) {
        val (x_i, y_i) = coordinates[i]
        val (x_j, y_j) = coordinates[(i + 1) % n]

        area += (x_i * y_j) - (x_j * y_i)
    }

    area = Math.abs(area) / 2

    return area
}