| bool_point_pair intersection_points (const Point& p0, const Point& p1) | const function |
| bool_point_pair intersection_points (const Path& p) | const function |
These functions find the intersections of the
Polygon and a line.
In the first version, the Point arguments are the end points of
the line. The argument to the second version must be a linear
Path.
A line and a regular polygon or rectangle1
can intersect at two points at most.
Let When the Point A(1, 1, 1);
Reg_Polygon r(origin, 5, 3);
Transform t;
t.rotate(15, 12, 11);
t.shift(A);
Point P(-2, 0, -1);
Point Q(2, 0, 1);
P *= Q *= r *= t;
bool_point_pair bpp = r.intersection_points(P, Q);
bpp.first.pt.dotlabel("$f$", "rt");
bpp.second.pt.dotlabel("$s$");
In [next figure] , the lines BC and PQ are not coplanar with the Point B(r.get_point(3).mediate(r.get_point(4)));
Point C(B);
B.shift(0, 2, .5);
C.shift(0, -2, -.5);
Point P(-1, -2, -1);
Point Q(0, 2, 1);
B *= C *= P *= Q *= r *= t;
bool_point_pair bpp = r.intersection_points(B, C);
bpp.first.pt.dotlabel("$i_0$", "rt");
bpp = r.intersection_points(P, Q);
bpp.first.pt.dotlabel("$i_1$", "rt");
In [next figure] , the intersection point of r with the line PQ does not lie on the line segment PQ. bpp = r.intersection_points(P, Q);
bpp.first.pt.dotlabel("$i$", "rt");
cout << "bpp.first.b == " << bpp.first.b << endl << flush;
-| bpp.first.b == 0
|
| vector<Point> intersection_points (const Polygon& r) | const function |
Finds the intersection points of two Polygons.
Let v be the vector<Point> returned by
intersection_points(). If the Polygons are coplanar,
v
will contain the intersection points of the edges of the
Polygons, as in [next figure]
.
Rectangle r(origin, 4, 4);
Reg_Polygon rp(origin, 5, 5, 0, 36);
rp.shift(0, 0, .25);
vector <Point> v = r.intersection_points(rp);
If the Point A(1, 1, 1);
Rectangle r(A, 4, 4);
Reg_Polygon p(A, 5, 5);
p.rotate(90, 30);
p.shift(2, 0, 3);
vector <Point> v = r.intersection_points(p);
In [next figure]
, the Point A(1, 1, 1);
Rectangle r(A, 4, 4);
Reg_Polygon p(A, 5, 5);
p.rotate(90, 30);
p.shift(4, 3, 3);
vector <Point> v = r.intersection_points(p);
int i = 0;
for (vector<Point>::iterator iter = v.begin();
iter != v.end(); ++iter)
iter->dotlabel(i++, "bot");
|