Next: Solving Ellipses, Previous: Returning Elements and Information for Ellipses, Up: Ellipse Reference
const virtual function: bool_point_pair intersection_points (const Point& p0, const Point& p1)const virtual function: bool_point_pair intersection_points (const Path& p)These functions return the intersection points of a line with an
Ellipse. In the first version, the line is specified by the twoPointarguments. In the second version, p.is_linear()must returntrue, otherwise,intersection_points()issues an error message and returnsINVALID_BOOL_POINT_PAIR.If the line and the
Ellipseare coplanar, there can be at most two intersection points. Otherwise, there can be at most one.Ellipse e(origin, 5, 7, 30, 30, 30); e.shift(3, 0, 3); Point p0 = e.get_center().mediate(e.get_point(3)); Point normal = e.get_normal(); Point A = normal; A *= 2.5; A.shift(p0); Point B = normal; B *= -2.5; B.shift(p0); bool_point_pair bpp = e.intersection_points(A, B); bpp.first.pt.dotlabel("$i_0$", "rt"); Point C = e.get_point(15).mediate(e.get_point(11), 1.25); Point D = e.get_point(11).mediate(e.get_point(15), 1.5); Path q = C.draw(D); bpp = e.intersection_points(q); bpp.first.pt.dotlabel("$i_1$", "llft"); bpp.second.pt.dotlabel("$i_2$", "ulft");
![]()
Fig. 167.
const virtual function: bool_point_quadruple intersection_points (Ellipse e, [const real step = 3, [bool verbose = false]])Returns the intersection points of two
Ellipses. TwoEllipsescan intersect at at most four points.Let bpq be the
bool_point_quadruplereturned byintersection_points(). If one or more intersection points are found, the correspondingPointsare stored in theptelements of the fourbool_pointsbelonging to bpq, otherwiseINVALID_POINT. If aPointis found, thebelement of thebool_pointwill betrue, otherwisefalse.The step argument is used when the
Ellipsesare coplanar and either have different centers or the vertical axis of oneEllipseis colinear with the horizontal axis of the other (and vice versa). In these cases, the intersection points must be found by an iterative routine. APointp travels around the perimeter of*this, and its location with respect to e is tested. step is the angle of rotation used for stepping around the perimeter of*this. The default value, 3, should be adequate, unless theEllipsesdiffer greatly in size.If the verbose argument is
true,intersection_points()will print information about the intersection points to standard output.In [next figure] , the
Ellipsese and f both lie in the x-z plane, are centered at the origin, and intersect at four points.Ellipse e(origin, 5, 2); Ellipse f(origin, 2, 5); bool_point_quadruple bpq = e.intersection_points(f); bpq.first.pt.dotlabel(1, "llft"); bpq.second.pt.dotlabel(2, "urt"); bpq.third.pt.dotlabel(3, "ulft"); bpq.fourth.pt.dotlabel(4, "lrt");
![]()
Fig. 168.
In [next figure] , e and f are coplanar, but don't lie in a major plane, have different centers, and only intersect at two points.
Ellipse e(origin, 4, 2); Ellipse f(origin, 2, 5); f.shift(0, 0, 1); f.rotate(0, 15); f.shift(1, 0, 1); e *= f.shift(-.25, 1, -1); e *= f.rotate(10, -12.5, 3); bool_point_quadruple bpq = e.intersection_points(f, true); bpq.first.pt.dotlabel(1, "urt"); bpq.second.pt.dotlabel(2, "ulft");
![]()
Fig. 169.
If the planes of the
Ellipsesare parallel, there are, of course, no intersection points. If theEllipsesare non-coplanar, and their planes are not parallel to each other,intersection_points()first finds the line of intersection of the planes of theEllipses. It then returns thePointsof intersection of this line with theEllipses, if they exist. If the verbose argument istrue, information about thePointsis printed to standard output.In [next figure] , the two
Ellipseslie in skew planes. The plane of f intersects with e at thePointslabelled “1” and “2”, while the plane of e intersects with f at thePointslabelled “3” and “4”.Ellipse e(origin, 5, 3); Ellipse f(origin, 2, 5); f.rotate(0, 0, 30); f.rotate(0, 10); f.rotate(45); f.shift(1.5, 1); bool_point_quadruple bpq = e.intersection_points(f, true); bpq.first.pt.dotlabel(1); bpq.second.pt.dotlabel(2); bpq.third.pt.dotlabel(3, "rt"); bpq.fourth.pt.dotlabel(4, "urt"); -| First point lies on the perimeter of *this. First point lies inside e. Second point lies on the perimeter of *this. Second point lies outside e. Third point lies outside *this. Third point lies on the perimeter of e. Fourth point lies inside *this. Fourth point lies on the perimeter of e.
![]()
Fig. 170.
In [next figure] , the two
Ellipseslie in skew planes. The plane of f intersects with e at thePointslabelled “1” and “2”. The plane of e does not intersect with f, sobpq.third.ptandbpq.fourth.ptareINVALID_POINT.Ellipse e(origin, 5, 3); Ellipse f(origin, 2, 5, 45); f.shift(0, 2.5, 3); bool_point_quadruple bpq = e.intersection_points(f, true); bpq.first.pt.dotlabel(1); bpq.second.pt.dotlabel(2); -| First point lies on the perimeter of *this. First point lies outside e. Second point lies on the perimeter of *this. Second point lies outside e. Third intersection point is INVALID_POINT. Fourth intersection point is INVALID_POINT.
![]()
Fig. 171.