Polygon

class Polygon : Shape

Class for representing polygon shape.

Constructors

Link copied to clipboard
fun Polygon(vertList: Array<Vec2>)

Constructor takes a supplied list of vertices and generates a convex hull around them.

Link copied to clipboard
fun Polygon(width: Double, height: Double)

Constructor to generate a rectangle.

Link copied to clipboard
fun Polygon(radius: Int, noOfSides: Int)

Generate a regular polygon with a specified number of sides and size.

Functions

Link copied to clipboard
open override fun calcMass(density: Double)

Implementation of calculating the mass of a polygon.

Link copied to clipboard
open override fun createAABB()

Generates an AABB encompassing the polygon and binds it to the body.

Link copied to clipboard
open override fun isPointInside(startPoint: Vec2): Boolean

Method to check if point is inside a body in world space.

Link copied to clipboard
open override fun rayIntersect(startPoint: Vec2, endPoint: Vec2, maxDistance: Double, rayLength: Double): Shape.IntersectionReturnElement

Checks if a ray intersects with the shape.

Properties

Link copied to clipboard
lateinit var body: CollisionBodyInterface
Link copied to clipboard
lateinit var normals: Array<Vec2>
Link copied to clipboard
var orientation: Mat2
Link copied to clipboard
var vertices: Array<Vec2>