Node:Regular Polygon Constructors and Setting Functions, Next:, Previous:Regular Polygon Data Members, Up:Regular Polygon Reference



Constructors and Setting Functions

void Reg_Polygon (void) Default constructor
Creates an empty Reg_Polygon.

void Reg_Polygon (const Point& ccenter, const unsigned short ssides, const real ddiameter, [const real angle_x = 0, [const real angle_y = 0, [const real angle_z = 0]]]) Constructor
Creates a Reg_Polygon in the x-z plane, centered at the origin, with the number of sides specified by ssides and with radius = ddiameter / 2.

The Reg_Polygon is rotated about the x, y, and z-axes in that order by the angles given by angle_x, angle_y, and angle_z, respectively, if any one of them is non-zero. Finally, the Reg_Polygon is shifted such that its center is located at ccenter.

          Reg_Polygon r(origin, 3, 2.75, 10, 15, 12.5);
          r.draw();
          


[Figure 145. Not displayed.]

Fig. 145.

void set (const Point& ccenter, const unsigned short ssides, const real ddiameter, [const real angle_x = 0, [const real angle_y = 0, [const real angle_z = 0]]]) Setting function
Corresponds to the constructor above.

A Reg_Polygon can theoretically have any number of sides, however I haven't tested it for unreasonably large values. The following example demonstrates that set() can be used to change a Reg_Polygon.

          Reg_Polygon r;
          real j = .5;
          for (int i = 3; i <= 16; ++i)
            {
              r.set(origin, i, j);
              r.draw();
              j += .5;
            }
          


[Figure 146. Not displayed.]

Fig. 146.

Reg_Polygon* create_new<Reg_Polygon> (const Reg_Polygon* r) Template specializations
Reg_Polygon* create_new<Reg_Polygon> (const Reg_Polygon& r)
Pseudo-constructors for dynamic allocation of Reg_Polygons. They create a Reg_Polygon on the free store and allocate memory for it using new(Reg_Polygon). They return a pointer to the new Reg_Polygon. If r is a non-zero pointer or a reference, the new Reg_Polygon will be a copy of r. If the new object is not meant to be a copy of an existing one, 0 must be passed to create_new<Reg_Polygon>() as its argument. See Dynamic Allocation of Shapes, for more information.