const
function: Line get_line (const Point& p)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.
const
function: real slope (Point p, [char m = 'x', [char n = 'y']])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
const
function: bool_real is_on_segment (const Point& p0, const Point& p1)These functions return a
bool_real
, where thebool
part istrue
, if thePoint
lies on the line segment between p0 and p1, otherwisefalse
. If thePoint
lies on the line segment, thereal
part is a value r such that 0 <= r <= 1 indicating how far thePoint
is along the way from p0 to p1. For example, if thePoint
is half of the way from p0 to p1, r will be .5. If thePoint
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
doesn't lie on the line passing through p0 and p1, r will beINVALID_REAL
.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
![]()
Fig. 91.
const
function: bool_real is_on_line (const Point& p0, const Point& p1)Returns a
bool_real
where thebool
part istrue
, if thePoint
lies on the line passing through p0 and p1, otherwisefalse
. If thePoint
lies on the line, thereal
part is a value r indicating how how far thePoint
is along the way from p0 to p1, otherwiseINVALID_REAL
. The following values of r are possible for a call toP.is_on_line(A, B)
, where thePoint
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 > 1Point 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);
![]()
Fig. 92.
const
function: Point mediate (Point p, [const real r = .5])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)
![]()
Fig. 93.