class Geode::Polygon

Overview

The Polygon class represents a polygon, i.e. numerous vertices connected by lines.

Direct Known Subclasses

Defined in:

geode/polygon.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(vertices : Array(Point)) #

Creates a new Polygon instance with an array of vertices.


[View source]
def self.new(*vertices : Point) #

Creates a new Polygon with variadic arguments.


[View source]

Instance Method Detail

def area #

Returns the area of a polygon.


[View source]
def include?(other : Point) #

Returns whether the given point lies on the polygon's perimeter.


[View source]
def perimeter #

Returns the total perimeter of the polygon.


[View source]
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)].


[View source]
def vertices : Array(Geode::Point) #

Returns all the vertices of the polygon.


[View source]