All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.casperix.math.geometry.CustomPolygon.kt Maven / Gradle / Ivy

package casperix.math.geometry

import casperix.math.collection.getLooped
import kotlinx.serialization.Serializable

@Serializable
data class CustomPolygon(val points: List) : Polygon {

    constructor(vararg points: Point) : this(points.toList())

    override fun getVertices(): List {
        return points
    }

    override fun  convert(converter: (Point) -> TargetPoint): CustomPolygon {
        val points = getVertices()
        return CustomPolygon(points.map(converter))
    }

    override fun getEdgeList(): List> {
        return points.mapIndexed { index, point ->
            Line(point, points.getLooped(index + 1))
        }
    }

}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy