const function: real_short get_distance (const Point& p)const function: real_short get_distance (void)The version of this function taking a
Pointargument returns areal_shortr, whoserealpart (r.first) represents the distance of p from thePlane. This value is always positive. r.secondcan take on three values:
- 0
- If the
Pointlies in thePlane.- 1
- If it lies on the side of the
Planepointed at by the normal to thePlane, considered to be the “outside”.- -1
- If it lies on the side of the
Planenot pointed at by the normal to thePlane, considered to be the “inside”.The version taking no argument returns the absolute of the data member
distanceand its sign, i.e., the distance oforiginto thePlane, and which side of thePlaneit lies on.It would have been possible to use
originas the default for an optionalPointargument, but I've chosen to overload this function, because of problems that may arise, when I implementuser_coordinatesandview_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.