class Geode::Polygon
- Geode::Polygon
- Reference
- Object
Overview
The Polygon
class represents a polygon, i.e. numerous vertices connected by lines.
Direct Known Subclasses
Defined in:
geode/polygon.crConstructors
-
.new(vertices : Array(Point))
Creates a new
Polygon
instance with an array of vertices. -
.new(*vertices : Point)
Creates a new
Polygon
with variadic arguments.
Instance Method Summary
-
#area
Returns the area of a polygon.
-
#include?(other : Point)
Returns whether the given point lies on the polygon's perimeter.
-
#perimeter
Returns the total perimeter of the polygon.
-
#segments
Returns an array of the line segments that make up the polygon.
-
#vertices : Array(Geode::Point)
Returns all the vertices of the polygon.
Constructor Detail
Creates a new Polygon
instance with an array of vertices.
Instance Method Detail
Returns whether the given point lies on the polygon's perimeter.
def segments
#
Returns an array of the line segments that make up the polygon.
The created array is in the form [Segment.new(p1, p2), Segment.new(p2, p3), ..., Segment.new(p(n-1), p(n)), Segment.new(p(n), p1)]
.