55. plugins.polygon — Polygonal facets.

55.1. Classes defined in module plugins.polygon

class plugins.polygon.Polygon(border, normal=2, holes=[])[source]

A Polygon is a flat surface bounded by a closed PolyLine.

The border is specified as a Coords object with shape (nvertex,3) specifying the vertex coordinates in order. While the Coords are 3d, only the first 2 components are used.

nelems()[source]

Return the number of elements in the Geometry.

Returns:int – The number of elements in the Geometry. This is an abstract method that should be reimplemented by the derived class.
npoints()[source]

Return the number of points and edges.

vectors()[source]

Return the vectors from each point to the next one.

angles()[source]

Return the angles of the line segments with the x-axis.

externalAngles()[source]

Return the angles between subsequent line segments.

The returned angles are the change in direction between the segment ending at the vertex and the segment leaving. The angles are given in degrees, in the range ]-180,180]. The sum of the external angles is always (a multiple of) 360. A convex polygon has all angles of the same sign.

isConvex()[source]

Check if the polygon is convex and turning anticlockwise.

Returns:

  • +1 if the Polygon is convex and turning anticlockwise,
  • -1 if the Polygon is convex, but turning clockwise,
  • 0 if the Polygon is not convex.
internalAngles()[source]

Return the internal angles.

The returned angles are those between the two line segments at each vertex. The angles are given in degrees, in the range ]-180,180]. These angles are the complement of the

reverse()[source]

Return the Polygon with reversed order of vertices.

fill()[source]

Fill the surface inside the polygon with triangles.

Returns a TriSurface filling the surface inside the polygon.

area()[source]

Compute area inside a polygon.

55.2. Functions defined in module plugins.polygon

plugins.polygon.projected(X, N)[source]

Returns 2-D coordinates of a set of 3D coordinates.

The returned 2D coordinates are still stored in a 3D Coords object. The last coordinate will however (approximately) be zero.