Geometry

expect object Geometry

Geometry utilities for computing hulls, testing point overlap, building polygons, and performing local ray casts against shape primitives.

Functions

Link copied to clipboard
expect fun computeCapsuleAABB(capsule: Capsule, transform: Transform): AABB

Compute the AABB of a transformed capsule.

Link copied to clipboard
expect fun computeCapsuleMass(capsule: Capsule, density: Float): MassData

Compute mass properties of a capsule.

Link copied to clipboard
expect fun computeCircleAABB(circle: Circle, transform: Transform): AABB

Compute the AABB of a transformed circle.

Link copied to clipboard
expect fun computeCircleMass(circle: Circle, density: Float): MassData

Compute mass properties of a circle.

Link copied to clipboard
expect fun computeHull(points: List<Vec2>): Hull

Compute the convex hull of a set of points. Returns a hull with 0 points on failure.

Link copied to clipboard
expect fun computePolygonAABB(polygon: Polygon, transform: Transform): AABB

Compute the AABB of a transformed polygon.

Link copied to clipboard
expect fun computePolygonMass(polygon: Polygon, density: Float): MassData

Compute mass properties of a convex polygon.

Link copied to clipboard
expect fun computeSegmentAABB(segment: Segment, transform: Transform): AABB

Compute the AABB of a transformed line segment.

Link copied to clipboard
expect fun makeBox(halfWidth: Float, halfHeight: Float): Polygon

Make a box polygon centered at the origin.

Link copied to clipboard
expect fun makeOffsetBox(halfWidth: Float, halfHeight: Float, center: Vec2, rotation: Rot): Polygon

Make an offset box polygon.

Link copied to clipboard
expect fun makeOffsetPolygon(hull: Hull, position: Vec2, rotation: Rot): Polygon

Make an offset convex polygon from a convex hull.

Link copied to clipboard
expect fun makeOffsetRoundedBox(halfWidth: Float, halfHeight: Float, center: Vec2, rotation: Rot, radius: Float): Polygon

Make an offset rounded box polygon.

Link copied to clipboard
expect fun makeOffsetRoundedPolygon(hull: Hull, position: Vec2, rotation: Rot, radius: Float): Polygon

Make an offset rounded convex polygon from a convex hull.

Link copied to clipboard
expect fun makePolygon(hull: Hull, radius: Float = 0.0f): Polygon

Make a convex polygon from a convex hull.

Link copied to clipboard
expect fun makeRoundedBox(halfWidth: Float, halfHeight: Float, radius: Float): Polygon

Make a rounded box polygon centered at the origin.

Link copied to clipboard
expect fun makeSquare(halfWidth: Float): Polygon

Make a square polygon (box with equal half-widths).

Link copied to clipboard
expect fun pointInCapsule(point: Vec2, capsule: Capsule): Boolean

Test a point for overlap with a capsule in local space.

Link copied to clipboard
expect fun pointInCircle(point: Vec2, circle: Circle): Boolean

Test a point for overlap with a circle in local space.

Link copied to clipboard
expect fun pointInPolygon(point: Vec2, polygon: Polygon): Boolean

Test a point for overlap with a convex polygon in local space.

Link copied to clipboard
expect fun rayCastCapsule(input: RayCastInput, capsule: Capsule): CastOutput

Ray cast versus capsule shape in local space. Initial overlap is treated as a miss.

Link copied to clipboard
expect fun rayCastCircle(input: RayCastInput, circle: Circle): CastOutput

Ray cast versus circle shape in local space. Initial overlap is treated as a miss.

Link copied to clipboard
expect fun rayCastPolygon(input: RayCastInput, polygon: Polygon): CastOutput

Ray cast versus polygon shape in local space. Initial overlap is treated as a miss.

Link copied to clipboard
expect fun rayCastSegment(input: RayCastInput, segment: Segment, oneSided: Boolean = false): CastOutput

Ray cast versus segment shape in local space. Initial overlap is treated as a miss.

Link copied to clipboard
expect fun shapeCastCapsule(input: ShapeCastInput, capsule: Capsule): CastOutput

Shape cast versus a capsule. Initial overlap is treated as a miss.

Link copied to clipboard
expect fun shapeCastCircle(input: ShapeCastInput, circle: Circle): CastOutput

Shape cast versus a circle. Initial overlap is treated as a miss.

Link copied to clipboard
expect fun shapeCastPolygon(input: ShapeCastInput, polygon: Polygon): CastOutput

Shape cast versus a polygon. Initial overlap is treated as a miss.

Link copied to clipboard
expect fun shapeCastSegment(input: ShapeCastInput, segment: Segment): CastOutput

Shape cast versus a segment. Initial overlap is treated as a miss.

Link copied to clipboard
expect fun transformPolygon(transform: Transform, polygon: Polygon): Polygon

Transform a polygon. Useful for transferring a shape from one body to another.

Link copied to clipboard
expect fun validateHull(hull: Hull): Boolean

Validate a previously computed hull. This is expensive and should not be called at runtime.