Enumeration

# PolyJoinType

Geometry2D.swift:43
``enum PolyJoinType``

## Cases

• `case square`

Squaring is applied uniformally at all convex edge joins at `1 * delta`.

• `case round`

While flattened paths can never perfectly trace an arc, they are approximated by a series of arc chords.

• `case miter`

There’s a necessary limit to mitered joins since offsetting edges that join at very acute angles will produce excessively long and narrow “spikes”. For any given edge join, when miter offsetting would exceed that maximum distance, “square” joining is applied.

## Other members in extension

View members

Hide members

This section is hidden by default because it contains too many (27) members.

### Types

• `enum PolyBooleanOperation`
• `enum PolyEndType`

### Type members

• `static var shared: Geometry2D`

The shared instance of this class

• `static func clipPolygons(polygonA: PackedVector2Array, polygonB: PackedVector2Array) -> VariantCollection<PackedVector2Array>`

Clips `polygonA` against `polygonB` and returns an array of clipped polygons. This performs .operationDifference between polygons. Returns an empty array if `polygonB` completely overlaps `polygonA`.

• `static func clipPolylineWithPolygon(polyline: PackedVector2Array, polygon: PackedVector2Array) -> VariantCollection<PackedVector2Array>`

Clips `polyline` against `polygon` and returns an array of clipped polylines. This performs .operationDifference between the polyline and the polygon. This operation can be thought of as cutting a line with a closed shape.

• `static func convexHull(points: PackedVector2Array) -> PackedVector2Array`

Given an array of `Vector2`s, returns the convex hull as a list of points in counterclockwise order. The last point is the same as the first one.

• `static func decomposePolygonInConvex(polygon: PackedVector2Array) -> VariantCollection<PackedVector2Array>`

Decomposes the `polygon` into multiple convex hulls and returns an array of `PackedVector2Array`.

• `static func excludePolygons(polygonA: PackedVector2Array, polygonB: PackedVector2Array) -> VariantCollection<PackedVector2Array>`

Mutually excludes common area defined by intersection of `polygonA` and `polygonB` (see `intersectPolygons(polygonA:polygonB:)`) and returns an array of excluded polygons. This performs .operationXor between polygons. In other words, returns all but common area between polygons.

• `static func getClosestPointToSegment(point: Vector2, s1: Vector2, s2: Vector2) -> Vector2`

Returns the 2D point on the 2D segment (`s1`, `s2`) that is closest to `point`. The returned point will always be inside the specified segment.

• `static func getClosestPointToSegmentUncapped(point: Vector2, s1: Vector2, s2: Vector2) -> Vector2`

Returns the 2D point on the 2D line defined by (`s1`, `s2`) that is closest to `point`. The returned point can be inside the segment (`s1`, `s2`) or outside of it, i.e. somewhere on the line extending from the segment.

• `static func getClosestPointsBetweenSegments(p1: Vector2, q1: Vector2, p2: Vector2, q2: Vector2) -> PackedVector2Array`

Given the two 2D segments (`p1`, `q1`) and (`p2`, `q2`), finds those two points on the two segments that are closest to each other. Returns a `PackedVector2Array` that contains this point on (`p1`, `q1`) as well the accompanying point on (`p2`, `q2`).

• `static func intersectPolygons(polygonA: PackedVector2Array, polygonB: PackedVector2Array) -> VariantCollection<PackedVector2Array>`

Intersects `polygonA` with `polygonB` and returns an array of intersected polygons. This performs .operationIntersection between polygons. In other words, returns common area shared by polygons. Returns an empty array if no intersection occurs.

• `static func intersectPolylineWithPolygon(polyline: PackedVector2Array, polygon: PackedVector2Array) -> VariantCollection<PackedVector2Array>`

Intersects `polyline` with `polygon` and returns an array of intersected polylines. This performs .operationIntersection between the polyline and the polygon. This operation can be thought of as chopping a line with a closed shape.

• `static func isPointInCircle(point: Vector2, circlePosition: Vector2, circleRadius: Double) -> Bool`

Returns `true` if `point` is inside the circle or if it’s located exactly on the circle’s boundary, otherwise returns `false`.

• `static func isPointInPolygon(point: Vector2, polygon: PackedVector2Array) -> Bool`

Returns `true` if `point` is inside `polygon` or if it’s located exactly on polygon’s boundary, otherwise returns `false`.

• `static func isPolygonClockwise(polygon: PackedVector2Array) -> Bool`

Returns `true` if `polygon`’s vertices are ordered in clockwise order, otherwise returns `false`.

• `static func lineIntersectsLine(fromA: Vector2, dirA: Vector2, fromB: Vector2, dirB: Vector2) -> Variant`

Checks if the two lines (`fromA`, `dirA`) and (`fromB`, `dirB`) intersect. If yes, return the point of intersection as `Vector2`. If no intersection takes place, returns `null`.

• `static func makeAtlas(sizes: PackedVector2Array) -> GDictionary`

Given an array of `Vector2`s representing tiles, builds an atlas. The returned dictionary has two keys: `points` is a `PackedVector2Array` that specifies the positions of each tile, `size` contains the overall size of the whole atlas as `Vector2i`.

• `static func mergePolygons(polygonA: PackedVector2Array, polygonB: PackedVector2Array) -> VariantCollection<PackedVector2Array>`

Merges (combines) `polygonA` and `polygonB` and returns an array of merged polygons. This performs .operationUnion between polygons.

• `static func offsetPolygon(PackedVector2Array, delta: Double, joinType: Geometry2D.PolyJoinType) -> VariantCollection<PackedVector2Array>`

Inflates or deflates `polygon` by `delta` units (pixels). If `delta` is positive, makes the polygon grow outward. If `delta` is negative, shrinks the polygon inward. Returns an array of polygons because inflating/deflating may result in multiple discrete polygons. Returns an empty array if `delta` is negative and the absolute value of it approximately exceeds the minimum bounding rectangle dimensions of the polygon.

• `static func offsetPolyline(PackedVector2Array, delta: Double, joinType: Geometry2D.PolyJoinType, endType: Geometry2D.PolyEndType) -> VariantCollection<PackedVector2Array>`

Inflates or deflates `polyline` by `delta` units (pixels), producing polygons. If `delta` is positive, makes the polyline grow outward. Returns an array of polygons because inflating/deflating may result in multiple discrete polygons. If `delta` is negative, returns an empty array.

• `static func pointIsInsideTriangle(point: Vector2, a: Vector2, b: Vector2, c: Vector2) -> Bool`

Returns if `point` is inside the triangle specified by `a`, `b` and `c`.

• `static func segmentIntersectsCircle(segmentFrom: Vector2, segmentTo: Vector2, circlePosition: Vector2, circleRadius: Double) -> Double`

Given the 2D segment (`segmentFrom`, `segmentTo`), returns the position on the segment (as a number between 0 and 1) at which the segment hits the circle that is located at position `circlePosition` and has radius `circleRadius`. If the segment does not intersect the circle, -1 is returned (this is also the case if the line extending the segment would intersect the circle, but the segment does not).

• `static func segmentIntersectsSegment(fromA: Vector2, toA: Vector2, fromB: Vector2, toB: Vector2) -> Variant`

Checks if the two segments (`fromA`, `toA`) and (`fromB`, `toB`) intersect. If yes, return the point of intersection as `Vector2`. If no intersection takes place, returns `null`.

• `static func triangulateDelaunay(points: PackedVector2Array) -> PackedInt32Array`

Triangulates the area specified by discrete set of `points` such that no point is inside the circumcircle of any resulting triangle. Returns a `PackedInt32Array` where each triangle consists of three consecutive point indices into `points` (i.e. the returned array will have `n * 3` elements, with `n` being the number of found triangles). If the triangulation did not succeed, an empty `PackedInt32Array` is returned.

• `static func triangulatePolygon(PackedVector2Array) -> PackedInt32Array`

Triangulates the polygon specified by the points in `polygon`. Returns a `PackedInt32Array` where each triangle consists of three consecutive point indices into `polygon` (i.e. the returned array will have `n * 3` elements, with `n` being the number of found triangles). Output triangles will always be counter clockwise, and the contour will be flipped if it’s clockwise. If the triangulation did not succeed, an empty `PackedInt32Array` is returned.

• `class var godotClassName: StringName`

## Citizens in SwiftGodot

### Conformances

• `protocol CaseIterable`

A type that provides a collection of all of its values.

• `protocol CustomDebugStringConvertible`

A type with a customized textual representation suitable for debugging purposes.

• `protocol Equatable`

A type that can be compared for value equality.

• `protocol Hashable`

A type that can be hashed into a `Hasher` to produce an integer hash value.

• `protocol RawRepresentable<RawValue>`

A type that can be converted to and from an associated raw value.

### Type members

• `init?(rawValue: Int64)`

### Instance members

• `var debugDescription: String`

A textual representation of this instance, suitable for debugging

### Type features

• `static func != (lhs: Self, rhs: Self) -> Bool`

Returns a Boolean value indicating whether two values are not equal.

### Instance features

• `var hashValue: Int`
• `func hash(into: inout Hasher)`