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 twoPoint
arguments. 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
Ellipse
are 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
. TwoEllipses
can intersect at at most four points.Let bpq be the
bool_point_quadruple
returned byintersection_points()
. If one or more intersection points are found, the correspondingPoints
are stored in thept
elements of the fourbool_points
belonging to bpq, otherwiseINVALID_POINT
. If aPoint
is found, theb
element of thebool_point
will betrue
, otherwisefalse
.The step argument is used when the
Ellipses
are coplanar and either have different centers or the vertical axis of oneEllipse
is colinear with the horizontal axis of the other (and vice versa). In these cases, the intersection points must be found by an iterative routine. APoint
p 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 theEllipses
differ 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
Ellipses
e 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
Ellipses
are parallel, there are, of course, no intersection points. If theEllipses
are 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 thePoints
of intersection of this line with theEllipses
, if they exist. If the verbose argument istrue
, information about thePoints
is printed to standard output.In [next figure] , the two
Ellipses
lie in skew planes. The plane of f intersects with e at thePoints
labelled “1” and “2”, while the plane of e intersects with f at thePoints
labelled “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
Ellipses
lie in skew planes. The plane of f intersects with e at thePoints
labelled “1” and “2”. The plane of e does not intersect with f, sobpq.third.pt
andbpq.fourth.pt
areINVALID_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.