class
Eagle::Physics2D::Polygon
- Eagle::Physics2D::Polygon
- Eagle::Physics2D::Shape
- Reference
- Object
Overview
A convex polygon collision shape. Points can be in either winding order. Concave input isn't supported; split it into several convex polygons.
Physics2D::Polygon.box(32, 48)
Physics2D::Polygon.new([v2(0, -20), v2(15, 10), v2(-15, 10)]) # triangle
Defined in:
eagle/physics/shapes2d.crConstructors
-
.box(w : Number, h : Number, offset : Vec2 = Vec2::ZERO) : Polygon
A w by h box centered on offset.
-
.new(points : Array(Vec2), offset : Vec2 = Vec2::ZERO)
Creates a polygon from convex points.
-
.regular(sides : Int32, radius : Number, offset : Vec2 = Vec2::ZERO) : Polygon
A regular polygon with sides corners.
Instance Method Summary
-
#aabb : Rect
Bounds in world space.
-
#area : Float32
Area of the polygon.
-
#centroid : Vec2
The polygon's center of mass.
-
#contains?(p : Vec2) : Bool
True when p is inside the polygon.
-
#inertia_factor : Float32
Inertia per unit mass.
-
#local_aabb : Rect
Bounds in local space.
-
#normals : Array(Vec2)
Outward edge normals.
-
#points : Array(Vec2)
Vertices in local space, stored clockwise.
-
#support(d : Vec2) : Vec2
The vertex furthest in direction d, used by collision tests.
-
#transformed(t : Transform2D) : Shape
A world-space copy.
Instance methods inherited from class Eagle::Physics2D::Shape
aabb : Rect
aabb,
area : Float32
area,
inertia_factor : Float32
inertia_factor,
local_aabb : Rect
local_aabb,
offset : Vec2
offset,
offset=(offset : Vec2)
offset=,
transformed(t : Transform2D) : Shape
transformed
Constructor Detail
A w by h box centered on offset.
Creates a polygon from convex points.
A regular polygon with sides corners.