Node: Getting Shape Centers Solids, Next: Getting Shapes Solids, Previous: Returning Elements and Information Solids, Up: Returning Elements and Information Solids
const Point& get_shape_center (const unsigned short shape_type, const unsigned short s) | const virtual function |
Returns the center of a Shape belonging to the Solid .
Currently, the object can be a Circle , Ellipse ,
Rectangle , or Reg_Polygon , and it is accessed through a pointer
on one of the following vectors of pointers to Shape :
circles , ellipses ,
rectangles , or reg_polygons .
The type of
object is specified
using the shape_type argument.
The following public static const data members of Solid
can (and probably should) be passed as the shape_type argument:
CIRCLE , ELLIPSE , RECTANGLE , and
REG_POLYGON .
The argument s is used to index the vector. This function is called within the more specialized functions in this
section, namely: Dodecahedron d(origin, 3); d.filldraw(); Point C = d.get_shape_center(Solid::REG_POLYGON, 1); C.dotlabel("C");
Note that this function will have to be changed, if new vectors of
|
const Point& get_circle_center (const unsigned short s) | const virtual functions |
const Point& get_ellipse_center (const unsigned short s) | |
const Point& get_rectangle_center (const unsigned short s) | |
const Point& get_reg_polygon_center (const unsigned short s) |
These functions all return the center of the Shape pointed to by a pointer on
one of the vectors of Shapes belonging to the Solid . The argument s
indicates which element on the vector is to be accessed. For example,
get_rectangle_center(2) returns the center of the
Rectangle pointed to by rectangles[2] .
Cuboid c(origin, 3, 4, 5, 0, 30); c.draw(); for (int i = 0; i < 6; ++i) c.get_rectangle_center(i).label(i, "");
|