Polygon3

class Polygon3(vertices: List<Vec3>, val precision: DoubleEquivalence = DEFAULT_DOUBLE_EQUIVALENCE) : Polygon<Vec3> (source)

Represents a planar polygon in three-dimensional space.

The vertices are copied on construction and must include at least one non-collinear triple. The polygon may begin with collinear vertices; the plane is inferred from any valid triple and all vertices must lie in that plane.

Constructors

Link copied to clipboard
constructor(vertices: List<Vec3>, precision: DoubleEquivalence = DEFAULT_DOUBLE_EQUIVALENCE)

Properties

Link copied to clipboard
Link copied to clipboard

The normal vector of the polygon's plane.

Link copied to clipboard

The precision used for geometric computations.

Link copied to clipboard
open val vertexCount: Int

Returns the number of vertices in the polygon.

Link copied to clipboard
open override val vertices: List<Vec3>

An immutable snapshot of the vertices supplied to the constructor.

Functions

Link copied to clipboard
open override fun area(): Double

Computes the area of the polygon.

Link copied to clipboard

Computes the axis-aligned bounding box of the polygon.

Link copied to clipboard
open override fun centroid(): Vec3

Computes the centroid (geometric center) of the polygon.

Link copied to clipboard
operator fun component1(): List<Vec3>
Link copied to clipboard
Link copied to clipboard
open override fun contains(point: Vec3): Boolean

Checks if a point is inside the polygon.

Link copied to clipboard
fun copy(vertices: List<Vec3> = this.vertices, precision: DoubleEquivalence = this.precision): Polygon3

Returns a polygon with the supplied vertices and precision.

Link copied to clipboard
open override fun dimensions(): Int

Returns the number of dimensions of the spatial object.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun isConvex(): Boolean

Checks if the polygon is convex.

Link copied to clipboard
open override fun isFinite(): Boolean

Returns true if all values in the spatial are finite.

Link copied to clipboard
open override fun isInfinite(): Boolean

Returns true if any value in the spatial is infinite.

Link copied to clipboard
open override fun isNaN(): Boolean

Returns true if any value in the spatial is NaN (Not a Number).

Link copied to clipboard
open override fun isSimple(): Boolean

Checks if the polygon is simple (non-self-intersecting).

Link copied to clipboard
open override fun perimeter(): Double

Computes the perimeter of the polygon.

Link copied to clipboard
open override fun reverse(): Polygon<Vec3>

Reverses the order of vertices, effectively reversing the orientation of the polygon.

Link copied to clipboard
open override fun scale(factor: Double, center: Vec3): Polygon<Vec3>

Scales the polygon by a given factor around a center point.

Link copied to clipboard
open override fun signedArea(): Double

Computes the signed area of the polygon.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
open override fun transform(transformer: Transformer<Vec3>): Polygon<Vec3>

Transforms the polygon by applying a transformation to all vertices.

Link copied to clipboard
open override fun translate(offset: Vec3): Polygon<Vec3>

Translates the polygon by a given offset vector.