AngelCAD  1.5-00
Public Member Functions | List of all members
polygon Class Reference

polygon, vertices in CCW order More...

#include <angelcad.h>

Inheritance diagram for polygon:
shape2d shape

Public Member Functions

 polygon (const pos2d@ p1, const pos2d@ p2, const pos2d@ p3)
 Create triangular polygon, points must be given in CCW order. More...
 
 polygon (const pos2d@ p1, const pos2d@ p2, const pos2d@ p3, const pos2d@ p4)
 Create quadrilateral polygon, points must be given in CCW order. More...
 
 polygon (const pos2d@ p1, const pos2d@ p2, const pos2d@ p3, const pos2d@ p4, const pos2d@ p5)
 Create 5-sided polygon, points must be given in CCW order. More...
 
 polygon (const spline2d@ spline, uint nseg=30)
 Create polygon from spline curve and number of straight segments, points must be given in CCW order. More...
 
 polygon (double r, uint np)
 Create a circular polygon from a radius and np points. More...
 
 polygon (array< pos2d@>@ points, bool check=true)
 Create a polygon from an array of points. More...
 
double area () const
 Polygon area. More...
 
double signed_area () const
 Signed polygon area, return negative area for polygons oriented CW. More...
 
pos2dvertex (uint iv) const
 Return polygon vertex from zero based vertex index iv. More...
 
uint size () const
 number of polygon points More...
 
- Public Member Functions inherited from shape2d
shape2dopAdd (shape2d@ b)
 Boolean union operator+ overload. More...
 
shape2dopAnd (shape2d@ b)
 Boolean intersection operator& overload. More...
 
shape2dopMul (tmatrix@ matrix)
 Transform object by matrix multiplication: shape2d@ o2 = T * o1. More...
 
shape2dopSub (shape2d@ b)
 Boolean difference operator- overload. More...
 
- Public Member Functions inherited from shape
boundingboxbox () const
 Return bounding box of object. More...
 
tmatrixtransform () const
 Return transformation matrix of object. More...
 
void write_csg (string path)
 Write object to OpenSCAD .csg file. More...
 
void write_xcsg (string path, double secant_tolerance=- 1.0)
 Write object to .xcsg file for processing by xcsg program. More...
 

Detailed Description

polygon, vertices in CCW order

a polygon is a 2d object. It is defined by vertex positions listed in CCW sequence.

Constructor & Destructor Documentation

◆ polygon() [1/6]

polygon::polygon ( const pos2d p1,
const pos2d p2,
const pos2d p3 
)

Create triangular polygon, points must be given in CCW order.

Parameters
p1pos2d@, position
p2pos2d@, position
p3pos2d@, position

◆ polygon() [2/6]

polygon::polygon ( const pos2d p1,
const pos2d p2,
const pos2d p3,
const pos2d p4 
)

Create quadrilateral polygon, points must be given in CCW order.

Parameters
p1pos2d@, position
p2pos2d@, position
p3pos2d@, position
p4pos2d@, position

◆ polygon() [3/6]

polygon::polygon ( const pos2d p1,
const pos2d p2,
const pos2d p3,
const pos2d p4,
const pos2d p5 
)

Create 5-sided polygon, points must be given in CCW order.

Parameters
p1pos2d@, position
p2pos2d@, position
p3pos2d@, position
p4pos2d@, position
p5pos2d@, position

◆ polygon() [4/6]

polygon::polygon ( const spline2d spline,
uint  nseg = 30 
)

Create polygon from spline curve and number of straight segments, points must be given in CCW order.

Parameters
splinespline2d@, 2d spline curve defining polygon profile
nseguint, number of straight segments for spline

◆ polygon() [5/6]

polygon::polygon ( double  r,
uint  np 
)

Create a circular polygon from a radius and np points.

Parameters
rdouble
npuint

◆ polygon() [6/6]

polygon::polygon ( array< pos2d@>@  points,
bool  check = true 
)

Create a polygon from an array of points.

Parameters
pointsarray@
checkbool

Member Function Documentation

◆ area()

double polygon::area ( ) const

Polygon area.

return computed area of polygon

Returns
double

◆ signed_area()

double polygon::signed_area ( ) const

Signed polygon area, return negative area for polygons oriented CW.

return signed computed area of polygon

Returns
double

◆ size()

uint polygon::size ( ) const

number of polygon points

Returns
uint, number of polygon points

◆ vertex()

pos2d@ polygon::vertex ( uint  iv) const

Return polygon vertex from zero based vertex index iv.

Parameters
ivuint
Returns
pos2d@

The documentation for this class was generated from the following file: