Next: Regular Polygon Operators, Previous: Regular Polygon Data Members, Up: Regular Polygon Reference
Creates a
Reg_Polygon
in the x-z plane, centered at the origin, with the number of sides specified by ssides and withradius
= 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, theReg_Polygon
is shifted such that its center is located at ccenter.Reg_Polygon r(origin, 3, 2.75, 10, 15, 12.5); r.draw();
![]()
Fig. 145.
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 thatset()
can be used to change aReg_Polygon
.Reg_Polygon r; real j = .5; for (int i = 3; i <= 16; ++i) { r.set(origin, i, j); r.draw(); j += .5; }
![]()
Fig. 146.
Pseudo-constructors for dynamic allocation of
Reg_Polygons
. They create aReg_Polygon
on the free store and allocate memory for it usingnew(Reg_Polygon)
. They return a pointer to the newReg_Polygon
. If r is a non-zero pointer or a reference, the newReg_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 tocreate_new<Reg_Polygon>()
as its argument. See Dynamic Allocation of Shapes, for more information.