EasyGeometry::D2::Polygon

A two-dimensional polygon.

.new(*args)

A simple polygon in space can be constructed from a sequence of points.

Polygons are treated as closed paths rather than 2D areas so some calculations can be be negative or positive (e.g., area) based on the orientation of the points.

Any consecutive identical points are reduced to a single point and any points collinear and between two points will be removed unless they are needed to define an explicit intersection (see specs).

Must be at least 3 points.

.is_right?(a, b, c)

Return True/False for cw/ccw orientation.

#==(other)

Returns True if self and otherare the same mathematical entities.

#area

The area of the polygon.

The area calculation can be positive or negative based on the orientation of the points. If any side of the polygon crosses any other side, there will be areas having opposite signs.

#perimeter

The perimeter of the polygon.

#centroid

The centroid of the polygon.

#sides

The directed line segments that form the sides of the polygon.

#bounds

Return an array (xmin, ymin, xmax, ymax) representing the bounding rectangle for the geometric figure.

#is_convex?

Is the polygon convex?

A polygon is convex if all its interior angles are less than 180 degrees and there are no intersections between sides.

#is_encloses_point?(point)

Return True if p is enclosed by (is inside of) self, False otherwise.

Being on the border of self is considered False.

http://paulbourke.net/geometry/polygonmesh/#insidepoly

#intersection?(entity)

The intersection of polygon and geometry entity.

The intersection may be empty and can contain individual Points and complete Line Segments.

#distance(other)

Returns the shortest distance between self and other.

If other is a point, then self does not need to be convex.

If other is another polygon self and other must be convex.

Last updated

Was this helpful?