const function: bool is_on_free_store (void)Returns
true, if thePathwas dynamically allocated on the free store, otherwisefalse.
const virtual function: bool is_planar ([const bool verbose = false, [string text = ""]])Uses
get_normal()to determine whether thePathis planar or not. Returnstrue, if it is, otherwisefalse. If verbose istrue, text is written to standard output, or “Path:”, if text is the empty string, followed by a message saying whether thePathis planar or not.
const function: bool is_linear ([const bool verbose = false, [string text = ""]])Returns
true, ifline_switchistrue. Otherwise,is_linear()usesget_normal()to determine whether thePathis linear. If it is,is_linear()returnstrue, otherwisefalse.
const function: bool is_cycle (void)Returns
trueif thePathis cyclical, i.e.,cycle_switch = true, otherwisefalse. Only cyclicalPathsare fillable.
const function: bool get_line_switch (void)Returns the value of
line_switch.line_switchis only true, if thePathwas created, directly or indirectly, using the constructor taking twoPointarguments only. See Path Reference; Constructors and Setting Functions.
Returns the slope of the
Pathin the plane indicated by the arguments, ifis_linear()returnstrue. Otherwise,slope()issues an error message and returnsINVALID_REAL.
const function: Path subpath (size_t start, size_t end, [const bool cycle = false, [const string connector = ""]])Returns a new
Pathusingpoints[start]throughpoints[end- 1]. If cycle istrue, then the newPathwill be a cycle, whether*thisis or not. One optional connector argument can be used. If it is, it will be the only connector. Otherwise, the appropriate connectors from*thisare used.start must be < end. It is not possible to have start > end, even if
*thisis a cycle.
const function: const Point& get_point (const unsigned short a)Returns the
Point*points[a], if a <points.size()and thePathis non-empty, otherwiseINVALID_POINT.
const function: const Point& get_last_point (void)Returns the
Pointpointed to by the last pointer onpoints. Equivalent toget_point(get_size() - 1), but more convenient to type. ReturnsINVALID_POINT, if thePathis empty.
const function: Line get_line (void)Returns a
Linecorresponding to thePath, if the latter is linear. Otherwise,INVALID_LINEis returned. See Line Reference.
const virtual function: Point get_normal (void)Returns a
Pointrepresenting a unit vector in the direction of the normal to the plane of thePath, orINVALID_POINT, if thePathis non-planar.Point P(1, 1, 1); Rectangle r(P, 4, 4, 30, 30, 30); Point N = r.get_normal();
![]()
Fig. 136.
In 3DLDF, plane figures generally have constructors taking a |Point| argument for the center, a variable number of |real| arguments for the dimensions, and three |real| arguments for the rotation about the major axes. The object is first created in the x-z plane, and the
Pointsare generated to be traversed in the counter-clockwise direction, when seen from aPointwith a positive y-coordinate. If no rotation is specified, the normal will point in the direction of the positive y-axis. If non-zero arguments are used for rotation, the normal will be rotated accordingly. This direction considered to be “outside”. However, according to Huw Jones, Computer Graphics Through Key Mathematics, p. 197, “outside” is considered to be the side of a plane, where thePointsare meant to be traversed in the clockwise direction. I hope that no problems arise from this discrepancy!
const virtual function: Plane get_plane (void)Creates and returns a
Planep corresponding to thePath, if the latter is planar, otherwiseINVALID_PLANE. If thePathis planar, p.pointwill be thePointpointed to bythis->points[0]. See Plane Reference.Point P(1, 1, 1); Rectangle r(P, 4, 4, 45, 20, 15); Plane q = r.get_plane(); q.show("q:"); -| q: normal: (0.0505914, 0.745607, -0.664463) point: (0.0178869, -0.727258, -1.01297) distance == -0.131735
![]()
Fig. 137.
const function: Path reverse (void)These functions return a
Pathwith the samePointsand connectors as*this, but in reversed order.reverse()can only be applied to non-cyclicalPaths. If*thisis a cycle,reverse()issues an error message and returns*thisunreversed.If the first version is called with assign =
true,*thisitself is reversed. If*thisshould remain unchanged, theconstversion without an argument should be called. If, on the other hand, the first version is called with assign =false, a warning message is issued, but the reversedPathis returned just the same, leaving*thisunchanged.