const
function: real_short get_distance (const Point& p)const
function: real_short get_distance (void)The version of this function taking a
Point
argument returns areal_short
r, whosereal
part (r.first
) represents the distance of p from thePlane
. This value is always positive. r.second
can take on three values:
- 0
- If the
Point
lies in thePlane
.- 1
- If it lies on the side of the
Plane
pointed at by the normal to thePlane
, considered to be the “outside”.- -1
- If it lies on the side of the
Plane
not pointed at by the normal to thePlane
, considered to be the “inside”.The version taking no argument returns the absolute of the data member
distance
and its sign, i.e., the distance oforigin
to thePlane
, and which side of thePlane
it lies on.It would have been possible to use
origin
as the default for an optionalPoint
argument, but I've chosen to overload this function, because of problems that may arise, when I implementuser_coordinates
andview_coordinates
(see Point Reference; Data Members).Point N(0, 1); N.rotate(-10, 20, 20); Point P(1, 1, 1); Plane q(P, N); Point A(4, -2, 4); Point B(-1, 3, 2); Point C = q.intersection_point(A, B).pt; real_short bp; bp = q.get_distance(); cout << bp.first; -| 0.675646 cout << bp.second -| -1 bp = q.get_distance(A) cout << bp.first; -| 3.40368 cout << bp.second; -| -1 bp = q.get_distance(B) cout << bp.first; -| 2.75865 cout << bp.second; -| 1 bp = q.get_distance(C) cout << bp.first; -| 0 cout << bp.second; -| 0
![]()
Fig. 106.