Antiprism 0.19
Public Member Functions | Protected Attributes

polygon Class Reference

Make a uniform polygon. More...

#include <polygons.h>

Inheritance diagram for polygon:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 polygon (int N, int D=1)
 Constructor.
virtual ~polygon ()
 Destructor.
void set_radius (double r)
 Set the circumradius.
virtual bool set_radius2 (double r, char *msg=0)
 Set second radius.
void set_edge (double len)
 Set the edge (polygon side) length.
double get_edge ()
 Get the edge (polygon side) length.
double angle ()
 Get the angle that an edge makes at the centre.
int get_num_sides ()
 Get the number of sides of the (component) polygon.
int get_step ()
 Get the number of vertices stepped by a side of the (component) polygon.
int get_parts ()
 Get the number of component parts of a polygon.
void add_polygon (geom_if &geom, double ht=0)
 Add a polygon aligned with the xy plane and at a given z-height.
virtual void make_poly (geom_if &geom)
 Make a polygon based polyhedron.
virtual bool set_height (double ht, char *msg=0)
 Set the height.
double get_height ()
 Get the height.
virtual bool set_height2 (double ht, char *msg=0)
 Set second height.
virtual bool set_edge2 (double len2, char *msg=0)
 Set the edge length of the non-polygon edges.
virtual bool set_subtype (int typ, char *msg=0)
 Set the subtype of the polygon based polyhedron.
virtual bool set_twist_angle (double ang=NAN, char *msg=0)
 Set the twist angle of the polygon based polyhedron.
virtual void make_poly_part (geom_if &geom)
 Make a part of (or a complete) polygon-based polyhedron.
void dump ()
 Dump polygon data to stderr.

Protected Attributes

int num_sides
 The number of sides of the polygon (n of {n/d})
int step
 The number of verts stepped by an side (m of {n/d})
int parts
 The number of parts (polygon may be compound).
double radius
 The polygon circumradius.
double radius2
 A second radius.
double height
 The primary height of a polyhedron.
double height2
 A second height used for a polyhedron.
double twist_angle
 An angle to twist a polyhedron.
int subtype
 The subtype of a polygon based polyhedron.
int max_subtype
 The highest number for a subtype.

Detailed Description

Make a uniform polygon.


Constructor & Destructor Documentation

polygon::polygon ( int  N,
int  D = 1 
)

Constructor.

Polygon in form {N/D} (with N/D not necessarily in lowest form.)

Parameters:
Nnumber of sides to the (compound) polygon.
Dthe number of vertices stepped by an edge (default 1)

Member Function Documentation

void polygon::add_polygon ( geom_if geom,
double  ht = 0 
)

Add a polygon aligned with the xy plane and at a given z-height.

Parameters:
geomthe geometry to add the polygon to.
htthe height on the z-axis to place the polygon.
double polygon::angle ( ) [inline]

Get the angle that an edge makes at the centre.

Returns:
the angle, in radians.
double polygon::get_edge ( ) [inline]

Get the edge (polygon side) length.

Returns:
len the edge length.
double polygon::get_height ( ) [inline]

Get the height.

Returns:
the height.
int polygon::get_num_sides ( ) [inline]

Get the number of sides of the (component) polygon.

Returns:
the number of sides.
int polygon::get_parts ( ) [inline]

Get the number of component parts of a polygon.

If the polygon step is not in lowest form the polygon will be compound and have more than one part.

Returns:
the number of sides.
int polygon::get_step ( ) [inline]

Get the number of vertices stepped by a side of the (component) polygon.

Returns:
the number of vertices stepped.
void polygon::make_poly ( geom_if geom) [virtual]

Make a polygon based polyhedron.

Parameters:
geoma geometry to return the polyhedron.
virtual void polygon::make_poly_part ( geom_if geom) [inline, virtual]

Make a part of (or a complete) polygon-based polyhedron.

Make a non-compound polyhedron, using num_sides and step for {n/d}. If parts is greater than 1 then polygon::make_poly will make a compound by repeating this polyhedron parts times.

Parameters:
geoma geometry to return the polyhedron.

Reimplemented in dihedron, prism, antiprism, snub_antiprism, pyramid, dipyramid, cupola, orthobicupola, and gyrobicupola.

void polygon::set_edge ( double  len) [inline]

Set the edge (polygon side) length.

Parameters:
lenthe edge length.
bool polygon::set_edge2 ( double  len2,
char *  msg = 0 
) [inline, virtual]

Set the edge length of the non-polygon edges.

These are the vertical edges of a prism, the slanting edges of a pyramid, etc.

Parameters:
len2the edge length of the non-polygon edges.
msga string with length at least MSG_SZ to hold the error message if the edge length was not valid.
Returns:
true if the edge length was valid, otherwise false and msg contains the error messge.

Reimplemented in prism, antiprism, snub_antiprism, pyramid, and cupola.

bool polygon::set_height ( double  ht,
char *  msg = 0 
) [inline, virtual]

Set the height.

Parameters:
htthe height.
msga string with length at least MSG_SZ to hold the error message if the height was not valid.
Returns:
true if the height was valid, otherwise false and msg contains the error messge.

Reimplemented in antiprism, and snub_antiprism.

bool polygon::set_height2 ( double  ht,
char *  msg = 0 
) [inline, virtual]

Set second height.

Parameters:
htthe height.
msga string with length at least MSG_SZ to hold the error message if the height was not valid.
Returns:
true if the height was valid, otherwise false and msg contains the error messge.
void polygon::set_radius ( double  r) [inline]

Set the circumradius.

Parameters:
rthe circumradius.
bool polygon::set_radius2 ( double  r,
char *  msg = 0 
) [inline, virtual]

Set second radius.

Parameters:
rthe radius.
msga string with length at least MSG_SZ to hold the error message if the height was not valid.
Returns:
true if the radius was valid, otherwise false and msg contains the error messge.
bool polygon::set_subtype ( int  typ,
char *  msg = 0 
) [virtual]

Set the subtype of the polygon based polyhedron.

Some polygon based polyhedra come in several forms, and setting the sub-type can select a particular form.

Parameters:
typthe sub-type number.
msga string with length at least MSG_SZ to hold the error message if the edge length was not valid.
Returns:
true if the sub-type was valid, otherwise false and msg contains the error messge.
bool polygon::set_twist_angle ( double  ang = NAN,
char *  msg = 0 
) [inline, virtual]

Set the twist angle of the polygon based polyhedron.

Some polyhedra can be transformed by a twist, controlled by this angle. NAN indicates that no twist should be considered.

Parameters:
angthe angle of twist (default: NAN for no twist).
msga string with length at least MSG_SZ to hold the error message if the edge length was not valid.
Returns:
true if the polyhedron could be twisted, otherwise false and msg contains the error messge.

Reimplemented in prism, antiprism, pyramid, and cupola.


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