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
extension LinePolygon2 where Vector: VectorFloatingPoint
extension LinePolygon2 where Vector: Vector2FloatingPoint
-
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,
.zerois 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 the squared perimeter of this 2D polygon.
Declaration
Swift
@inlinable public func perimeterSquared() -> Vector.Scalar
-
Returns
trueif this polygon is convex.A polygon must have at least 3 points to be considered convex.
If the polygon self-intersects,
falseis returned.Declaration
Swift
public func isConvex() -> Bool
-
Assuming this
LinePolygon2represents 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
-
Returns
trueif the given point lies within an edge of the polygon represented byself, up to a giventoleranceSquaredvalue.Points lie within the edges of the polygon if the distance between the point and any two adjacent vertices is equal to the distance of the adjacent vertices, up to
√(toleranceSquared).Declaration
Swift
@inlinable public func isPointOnEdge(_ point: Vector, toleranceSquared: Scalar) -> Bool
-
Returns the perimeter of this 2D polygon.
Declaration
Swift
public func perimeter() -> Vector.Scalar