Intersection is a JavaScript object used to capture the results of the intersection of two Shape objects. Class methods perform the actual intersections and use only Point2D objects as parameters. This makes this class useful stand-alone uses where you don't want to use the 2D Geometry library.
The Ellipse-Ellipse intersection code is based on code written by David Eberly. That code and many more excellent examples are available at his site. If you are at all interested in 3D gaming algorithms, then I highly recommend his "3D Game Engine Design" book (ISBN 1-55860-593-2).
This code is used in the 2D Geometry section of this site.
intersectShapes(shape1, shape2) : Intersection;
This method determines which of the following intersection methods to call based on the types of the two shape parameters. One special case is tested for paths since these shapes need to be handled differently than all other shapes.
The Intersection object is returned from the resulting intersection method that is called by this method.
intersectPathShape(path, shape) : Intersection;
This method calls the specified path's intersectShape method to find all intersections between the specified path and shape.
intersectBezier2Bezier2(a1, a2, a3, b1, b2, b3) : Intersection;
Find the intersection of two quadratic Beziers. An Intersection object is returned with the following values:
intersectBezier2Bezier3(a1, a2, a3, b1, b2, b3, b4) : Intersection;
Find the intersection of a quadratic Bezier and a cubic Bezier. An Intersection object is returned with the following values:
intersectBezier2Circle(p1, p2, p3, c, r) : Intersection;
Find the intersection of a quadratic Bezier and a circle. Note that this routine uses the intersectBezier2Ellipse() method to find all intersections. An Intersection object is returned with the following values:
intersectBezier2Ellipse(p1, p2, p3, ec, rx, ry) : Intersection;
Find the intersection of a quadratic Bezier and an ellipse. Note that this routine is also used to find the intersection of a quadratic Bezier and an circle (although a separate intersectBezier2Circle may be created in the future). An Intersection object is returned with the following values:
intersectBezier2Line(p1, p2, p3, a1, a2) : Intersection;
Find the intersection of a quadratic Bezier and a line. An Intersection object is returned with the following values:
intersectBezier2Polygon(p1, p2, p3, points) : Intersection;
Find the intersection of a quadratic Bezier and a polygon. An Intersection object is returned with the following values:
intersectBezier2Rectangle(p1, p2, p3, r1, r2) : Intersection;
Find the intersection of a quadratic Bezier and a rectangle. An Intersection object is returned with the following values:
intersectBezier3Bezier3(a1, a2, a3, a4, b1, b2, b3, b4) : Intersection;
Find the intersection of two cubic Beziers. An Intersection object is returned with the following values:
intersectBezier3Circle(p1, p2, p3, p4, c, r) : Intersection;
Find the intersection of a cubic Bezier and a circle. Note that this routine uses the intersectBezier3Ellipse() method to find all intersections. An Intersection object is returned with the following values:
intersectBezier3Ellipse(p1, p2, p3, p4, ec, rx, ry) : Intersection;
Find the intersection of a cubic Bezier and an ellipse. Note that this routine is also used to find the intersection of a cubic Bezier and an circle (although a separate intersectBezier3Circle may be created in the future). An Intersection object is returned with the following values:
intersectBezier3Line(p1, p2, p3, p4, a1, a2) : Intersection;
Find the intersection of a cubic Bezier and a line. An Intersection object is returned with the following values:
intersectBezier3Polygon(p1, p2, p3, p4, points) : Intersection;
Find the intersection of a cubic Bezier and a polygon. An Intersection object is returned with the following values:
intersectBezier3Rectangle(p1, p2, p3, p4, r1, r2) : Intersection;
Find the intersection of a cubic Bezier and a rectangle. An Intersection object is returned with the following values:
intersectCircleCircle(c1, r1, c2, r2) : Intersection;
Find the intersection of two circles. An Intersection object is returned with the following values:
intersectCircleEllipse(cc, r, ec, rx, ry) : Intersection;
Find the intersection of a circle and an ellipse. Note that this routine uses the intersectEllipseEllipse() method to find all intersections. An Intersection object is returned with the following values:
intersectCircleLine(c, r, a1, a2) : Intersection;
Find the intersection of a circle and a line. An Intersection object is returned with the following values:
intersectCirclePolygon(c, r, points) : Intersection;
Find the intersection of a circle and a polygon. An Intersection object is returned with the following values:
intersectCircleRectangle(c, r, r1, r2) : Intersection;
Find the intersection of a circle and a rectangle. An Intersection object is returned with the following values:
intersectEllipseEllipse(c1, rx1, ry1, c2, rx2, ry2) : Intersection;
Find the intersection of two ellipses. Note that this routine is also used to find the intersection of an ellipse and a circle. An Intersection object is returned with the following values:
intersectEllipseLine(c, rx, ry, a1, a2) : Intersection;
Find the intersection of an ellipse and a line. An Intersection object is returned with the following values:
intersectEllipsePolygon(c, rx, ry, points) : Intersection;
Find the intersection of an ellipse and a polygon. An Intersection object is returned with the following values:
intersectEllipseRectangle(c, rx, ry, r1, r2) : Intersection;
Find the intersection of an ellipse and a rectangle. An Intersection object is returned with the following values:
intersectLineLine(a1, a2, b1, b2) : Intersection;
Find the intersection of two lines. An intersection object is returned with the following values:
intersectLinePolygon(a1, a2, points) : Intersection;
Find the intersection of a line and a polygon. An Intersection object is returned with the following values:
intersectLineRectangle(a1, a2, r1, r2) : Intersection;
Find the intersection of a line and a rectangle. An Intersection object is returned with the following values:
intersectPolygonPolygon(points1, points2) : Intersection;
Find the intersection of two polygons. An Intersection object is returned with the following values:
intersectPolygonRectangle(points, r1, r2) : Intersection;
Find the intersection of a polygon and a rectangle. An Intersection object is returned with the following values:
intersectRectangleRectangle(a1, a2, b1, b2) : Intersection;
Find the intersection of two rectangles. An Intersection object is returned with the following values:
bezout() calculates the Bezout determinate for the two specified ellipses. The resulting quadratic polynomial is returned. This method is used by intersectEllipseEllipse.
e1 is an array of the coefficients of an ellipse in general quadratic form: ax^2 + bxy + cy^2 + dx + ey + f = 0. The coefficients are in a,b,c,d,e,f order.
e2 is an array of the coefficients of an ellipse in general quadratic form: ax^2 + bxy + cy^2 + dx + ey + f = 0. The coefficients are in a,b,c,d,e,f order.
constructor - new Intersection(status);
This method creates a new Intersection object. All initialization is handled by the init() method. All parameters for this method are described below
init() initialized all properties for this object.
status is a string which returns a brief description of the results of an intersection.
appendPoint() adds a new point to the point array.
point is the new Point2D object that is to be added to the points array.
appendPoint() adds a new point to the point array.
points is an array of Point2D objects to be added to the points array.
status is a string used to categorize the results of an intersection.
points is an array of Point2D objects; one point for each intersection point.
Intersection.js - the Intersection object only
2D.js.gz - all objects needed to use this object and other 2D geometry objects