LinePolygon2
public extension LinePolygon2
extension LinePolygon2 where Vector: Vector2Multiplicative
extension LinePolygon2 where Vector: Vector2Multiplicative, Vector.Scalar: DivisibleArithmetic
extension LinePolygon2 where Vector: Vector2Multiplicative & VectorComparable
extension LinePolygon2: VolumetricType where Vector: VectorDivisible & VectorComparable
-
Adds a new 2D vertex at the end of this polygon’s vertices list
Declaration
Swift
mutating func addVertex(x: Scalar, y: Scalar)
-
Returns the winding number for this polygon.
The winding number is the sum of the cross products of each adjacent edge’s slope.
Positive values indicate clockwise orientation in an (X-Right, Y-Up) space, while negative indicate counter-clockwise.
If this polygon has less than 3 points,
.zero
is returned instead.Declaration
Swift
public func winding() -> Vector.Scalar
-
Returns the signed area of this 2D polygon.
Positive values indicate clockwise orientation in an (X-Right, Y-Up) space, while negative indicate counter-clockwise.
Declaration
Swift
public func area() -> Vector.Scalar
-
Returns
true
if this polygon is convex.A polygon must have at least 3 points to be considered convex.
If the polygon self-intersects,
false
is returned.Declaration
Swift
public func isConvex() -> Bool
-
Assuming this
LinePolygon2
represents a clockwise closed polygon, performs a vector-containment check against the polygon formed by this polygon’s vertices.Declaration
Swift
@inlinable public func contains(_ vector: Vector) -> Bool