| Line get_line (const Point& p) | const function |
Returns the Line l corresponding to the line from *this to
p. l.position will be *this, and
l.direction will be p - *this.
See Line Reference.
|
| real slope (Point p, [char m = 'x', [char n = 'y']]) | const function |
Returns a real number representing the slope of the trace
of the line defined by
*this and p on the plane indicated by the arguments m
and n.
Point p0(3, 4, 5);
Point p1(2, 7, 12);
real r = p0.slope(p1, 'x', 'y');
=> r == -3
r = p0.slope(p1, 'x', 'z');
=> r == -7
r = p0.slope(p1, 'z', 'y');
=> r == 0.428571
|
| bool_real is_on_segment (Point p0, Point p1) | Function |
| bool_real is_on_segment (const Point& p0, const Point& p1) | const function |
These functions return a bool_real, where the bool part is
true, if
the Point lies on the line segment between p0 and p1,
otherwise false. If the Point lies on the line segment, the
real part is a value
r such that
0 <= r <= 1
indicating how far the Point is along the way from
p0 to p1. For example, if the Point is half of the way
from p0 to p1, r will be .5. If the Point
does not lie on the line
segment, but on the line passing through p0 and p1,
r will be <0 or >1.
If the Point p0(-1, -2, 1);
Point p1(3, 2, 5);
Point p2(p0.mediate(p1, .75));
Point p3(p0.mediate(p1, 1.5));
Point p4(p2);
p4.shift(-2, 1, -1);
bool_real br = p2.is_on_segment(p0, p1);
cout << br.first;
-| 1
cout << br.second;
-| 0.75
bool_real br = p3.is_on_segment(p0, p1);
cout << br.first;
-| 0
cout << br.second;
-| 1.5
bool_real br = p4.is_on_segment(p0, p1);
cout << br.first;
-| 0
cout << br.second;
-| 3.40282e+38
cout << (br.second == INVALID_REAL)
-| 1
|
| bool_real is_on_line (const Point& p0, const Point& p1) | const function |
Returns a bool_real where the bool part is true, if
the Point lies on the line passing through p0 and p1,
otherwise false. If the Point lies on the line, the
real part is a value r indicating how how far the Point
is along the way from p0 to p1, otherwise
INVALID_REAL. The following
values of r are possible for a call to P.is_on_line(A, B),
where the Point P lies on the line
AB:
P == A ---> r== 0.
P == B ---> r== 1.
P lies on the opposite side of A from B ---> r < 0.
P lies between A and B ---> 0 < r < 1.
P lies on the opposite side of A from B ---> r > 1
Point A(-1, -2);
Point B(2, 3);
Point C(B.mediate(A, 1.25));
bool_real br = C.is_on_line(A, B);
Point D(A.mediate(B));
br = D.is_on_line(A, B);
Point E(A.mediate(B, 1.25));
br = E.is_on_line(A, B);
Point F(D);
F.shift(-1, 1);
br = F.is_on_line(A, B);
|
| Point mediate (Point p, [const real r = .5]) | const function |
Returns a Point r of the way from *this to p.
Point p0(-1, 0, -1);
Point p1(10, 0, 10);
Point p2(5, 5, 5);
Point p3 = p0.mediate(p1, 1.5);
p3.show("p3:");
-| p3: (15.5, 0, 15.5)
Point p4 = p0.mediate(p2, 1/3.0);
p4.show("p4:");
-| p4: (1, 1.66667, 1)
|