const
function: bool is_on_free_store (void)Returns
true
, if thePath
was 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 thePath
is 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 thePath
is planar or not.
const
function: bool is_linear ([const bool verbose = false
, [string text = ""]])Returns
true
, ifline_switch
istrue
. Otherwise,is_linear()
usesget_normal()
to determine whether thePath
is linear. If it is,is_linear()
returnstrue
, otherwisefalse
.
const
function: bool is_cycle (void)Returns
true
if thePath
is cyclical, i.e.,cycle_switch = true
, otherwisefalse
. Only cyclicalPaths
are fillable.
const
function: bool get_line_switch (void)Returns the value of
line_switch
.line_switch
is only true, if thePath
was created, directly or indirectly, using the constructor taking twoPoint
arguments only. See Path Reference; Constructors and Setting Functions.
Returns the slope of the
Path
in 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
Path
usingpoints[
start]
throughpoints[
end- 1]
. If cycle istrue
, then the newPath
will be a cycle, whether*this
is or not. One optional connector argument can be used. If it is, it will be the only connector. Otherwise, the appropriate connectors from*this
are used.start must be < end. It is not possible to have start > end, even if
*this
is a cycle.
const
function: const Point& get_point (const unsigned short a)Returns the
Point
*points[
a]
, if a <points.size()
and thePath
is non-empty, otherwiseINVALID_POINT
.
const
function: const Point& get_last_point (void)Returns the
Point
pointed to by the last pointer onpoints
. Equivalent toget_point(get_size() - 1)
, but more convenient to type. ReturnsINVALID_POINT
, if thePath
is empty.
const
function: Line get_line (void)Returns a
Line
corresponding to thePath
, if the latter is linear. Otherwise,INVALID_LINE
is returned. See Line Reference.
const
virtual function: Point get_normal (void)Returns a
Point
representing a unit vector in the direction of the normal to the plane of thePath
, orINVALID_POINT
, if thePath
is 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
Points
are generated to be traversed in the counter-clockwise direction, when seen from aPoint
with 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 thePoints
are 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
Plane
p corresponding to thePath
, if the latter is planar, otherwiseINVALID_PLANE
. If thePath
is planar, p.point
will be thePoint
pointed 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
Path
with the samePoints
and connectors as*this
, but in reversed order.reverse()
can only be applied to non-cyclicalPaths
. If*this
is a cycle,reverse()
issues an error message and returns*this
unreversed.If the first version is called with assign =
true
,*this
itself is reversed. If*this
should remain unchanged, theconst
version 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 reversedPath
is returned just the same, leaving*this
unchanged.