Line–line intersection
   HOME

TheInfoList



OR:

In
Euclidean geometry Euclidean geometry is a mathematical system attributed to ancient Greek mathematics, Greek mathematician Euclid, which he described in his textbook on geometry, ''Euclid's Elements, Elements''. Euclid's approach consists in assuming a small set ...
, the intersection of a line and a line can be the
empty set In mathematics, the empty set or void set is the unique Set (mathematics), set having no Element (mathematics), elements; its size or cardinality (count of elements in a set) is 0, zero. Some axiomatic set theories ensure that the empty set exi ...
, a point, or another line. Distinguishing these cases and finding the
intersection In mathematics, the intersection of two or more objects is another object consisting of everything that is contained in all of the objects simultaneously. For example, in Euclidean geometry, when two lines in a plane are not parallel, their ...
have uses, for example, in
computer graphics Computer graphics deals with generating images and art with the aid of computers. Computer graphics is a core technology in digital photography, film, video games, digital art, cell phone and computer displays, and many specialized applications. ...
,
motion planning Motion planning, also path planning (also known as the navigation problem or the piano mover's problem) is a computational problem to find a sequence of valid configurations that moves the object from the source to destination. The term is used ...
, and
collision detection Collision detection is the computational problem of detecting an intersection of two or more objects in virtual space. More precisely, it deals with the questions of ''if'', ''when'' and ''where'' two or more objects intersect. Collision detect ...
. In
three-dimensional In geometry, a three-dimensional space (3D space, 3-space or, rarely, tri-dimensional space) is a mathematical space in which three values (''coordinates'') are required to determine the position (geometry), position of a point (geometry), poi ...
Euclidean geometry, if two lines are not in the same
plane Plane most often refers to: * Aero- or airplane, a powered, fixed-wing aircraft * Plane (geometry), a flat, 2-dimensional surface * Plane (mathematics), generalizations of a geometrical plane Plane or planes may also refer to: Biology * Plane ...
, they have no point of intersection and are called
skew lines In three-dimensional geometry, skew lines are two Line (geometry), lines that do not Line-line intersection, intersect and are not Parallel (geometry), parallel. A simple example of a pair of skew lines is the pair of lines through opposite edges ...
. If they are in the same plane, however, there are three possibilities: if they coincide (are not distinct lines), they have an infinitude of points in common (namely all of the points on either of them); if they are distinct but have the same
slope In mathematics, the slope or gradient of a Line (mathematics), line is a number that describes the direction (geometry), direction of the line on a plane (geometry), plane. Often denoted by the letter ''m'', slope is calculated as the ratio of t ...
, they are said to be
parallel Parallel may refer to: Mathematics * Parallel (geometry), two lines in the Euclidean plane which never intersect * Parallel (operator), mathematical operation named after the composition of electrical resistance in parallel circuits Science a ...
and have no points in common; otherwise, they have a single point of intersection. The distinguishing features of
non-Euclidean geometry In mathematics, non-Euclidean geometry consists of two geometries based on axioms closely related to those that specify Euclidean geometry. As Euclidean geometry lies at the intersection of metric geometry and affine geometry, non-Euclidean ge ...
are the number and locations of possible intersections between two lines and the number of possible lines with no intersections (parallel lines) with a given line.


Formulas

A
necessary condition In logic and mathematics, necessity and sufficiency are terms used to describe a conditional or implicational relationship between two statements. For example, in the conditional statement: "If then ", is necessary for , because the truth of ...
for two lines to intersect is that they are in the same plane—that is, are not skew lines. Satisfaction of this condition is equivalent to the
tetrahedron In geometry, a tetrahedron (: tetrahedra or tetrahedrons), also known as a triangular pyramid, is a polyhedron composed of four triangular Face (geometry), faces, six straight Edge (geometry), edges, and four vertex (geometry), vertices. The tet ...
with vertices at two of the points on one line and two of the points on the other line being degenerate in the sense of having zero
volume Volume is a measure of regions in three-dimensional space. It is often quantified numerically using SI derived units (such as the cubic metre and litre) or by various imperial or US customary units (such as the gallon, quart, cubic inch) ...
. For the algebraic form of this condition, see .


Given two points on each line

First we consider the intersection of two lines and in two-dimensional space, with line being defined by two distinct points and , and line being defined by two distinct points and . The intersection of line and can be defined using
determinant In mathematics, the determinant is a Scalar (mathematics), scalar-valued function (mathematics), function of the entries of a square matrix. The determinant of a matrix is commonly denoted , , or . Its value characterizes some properties of the ...
s. : P_x = \frac \,\! \qquad P_y = \frac \,\! The determinants can be written out as: : \begin P_x&= \frac \\ pxP_y&= \frac \end When the two lines are parallel or coincident, the denominator is zero.


Given two points on each line segment

The intersection point above is for the infinitely long lines defined by the points, rather than the
line segment In geometry, a line segment is a part of a line (mathematics), straight line that is bounded by two distinct endpoints (its extreme points), and contains every Point (geometry), point on the line that is between its endpoints. It is a special c ...
s between the points, and can produce an intersection point not contained in either of the two line segments. In order to find the position of the intersection in respect to the line segments, we can define lines and in terms of first degree Bézier parameters: : L_1 = \beginx_1 \\ y_1\end + t \beginx_2-x_1 \\ y_2-y_1\end, \qquad L_2 = \beginx_3 \\ y_3\end + u \beginx_4-x_3 \\ y_4-y_3\end (where and are real numbers). The intersection point of the lines is found with one of the following values of or , where : t = \frac = \frac and : u = - \frac = -\frac, with : (P_x, P_y)= \bigl(x_1 + t (x_2-x_1),\; y_1 + t (y_2-y_1)\bigr) \quad \text \quad (P_x, P_y) = \bigl(x_3 + u (x_4-x_3),\; y_3 + u (y_4-y_3)\bigr) There will be an intersection if and . The intersection point falls within the first line segment if , and it falls within the second line segment if . These inequalities can be tested without the need for division, allowing rapid determination of the existence of any line segment intersection before calculating its exact point. In the case where the two line segments share an x axis and x_2 = x_1 + 1 , t and u simplify to t = u = \frac, with (P_x, P_y)= \bigl(x_1 + t,\; y_1 + t (y_2-y_1)\bigr) \quad \text \quad (P_x, P_y) = \bigl(x_1 + t,\; y_3 + t (y_4-y_3)\bigr).


Given two line equations

The and coordinates of the point of intersection of two non-vertical lines can easily be found using the following substitutions and rearrangements. Suppose that two lines have the equations and where and are the
slope In mathematics, the slope or gradient of a Line (mathematics), line is a number that describes the direction (geometry), direction of the line on a plane (geometry), plane. Often denoted by the letter ''m'', slope is calculated as the ratio of t ...
s (gradients) of the lines and where and are the -intercepts of the lines. At the point where the two lines intersect (if they do), both coordinates will be the same, hence the following equality: :ax+c = bx+d. We can rearrange this expression in order to extract the value of , :ax-bx = d-c, and so, :x = \frac. To find the coordinate, all we need to do is substitute the value of into either one of the two line equations, for example, into the first: :y = a\frac+c. Hence, the point of intersection is :P = \left( \frac, a\frac+c \right) . Note that if then the two lines are
parallel Parallel may refer to: Mathematics * Parallel (geometry), two lines in the Euclidean plane which never intersect * Parallel (operator), mathematical operation named after the composition of electrical resistance in parallel circuits Science a ...
and they do not intersect, unless as well, in which case the lines are coincident and they intersect at every point.


Using homogeneous coordinates

By using
homogeneous coordinates In mathematics, homogeneous coordinates or projective coordinates, introduced by August Ferdinand Möbius in his 1827 work , are a system of coordinates used in projective geometry, just as Cartesian coordinates are used in Euclidean geometry. ...
, the intersection point of two implicitly defined lines can be determined quite easily. In 2D, every point can be defined as a projection of a 3D point, given as the ordered triple . The mapping from 3D to 2D coordinates is . We can convert 2D points to homogeneous coordinates by defining them as . Assume that we want to find intersection of two infinite lines in 2-dimensional space, defined as and . We can represent these two lines in
line coordinates In geometry, line coordinates are used to specify the position of a line just as point coordinates (or simply coordinates) are used to specify the position of a point. Lines in the plane There are several possible ways to specify the position of ...
as and . The intersection of two lines is then simply given by :P' = (a_p, b_p, c_p) = U_1 \times U_2 = (b_1 c_2 - b_2 c_1, a_2 c_1-a_1 c_2, a_1 b_2 - a_2 b_1) If , the lines do not intersect.


More than two lines

The intersection of two lines can be generalized to involve additional lines. The existence of and expression for the -line intersection problem are as follows.


In two dimensions

In two dimensions, more than two lines almost certainly do not intersect at a single point. To determine if they do and, if so, to find the intersection point, write the th equation () as :\begin a_ & a_ \end \begin x \\ y \end = b_i, and stack these equations into matrix form as :\mathbf\mathbf=\mathbf, where the th row of the matrix is , is the 2 × 1 vector , and the th element of the column vector is . If has independent columns, its
rank A rank is a position in a hierarchy. It can be formally recognized—for example, cardinal, chief executive officer, general, professor—or unofficial. People Formal ranks * Academic rank * Corporate title * Diplomatic rank * Hierarchy ...
is 2. Then if and only if the rank of the
augmented matrix In linear algebra, an augmented matrix (A \vert B) is a k \times (n+1) matrix obtained by appending a k-dimensional column vector B, on the right, as a further column to a k \times n-dimensional matrix A. This is usually done for the purpose of p ...
is also 2, there exists a solution of the matrix equation and thus an intersection point of the lines. The intersection point, if it exists, is given by :\mathbf = \mathbf^\mathrm \mathbf = \left(\mathbf^\mathsf \mathbf\right)^ \mathbf^\mathsf \mathbf, where is the Moore–Penrose generalized inverse of (which has the form shown because has full column rank). Alternatively, the solution can be found by jointly solving any two independent equations. But if the rank of is only 1, then if the rank of the augmented matrix is 2 there is no solution but if its rank is 1 then all of the lines coincide with each other.


In three dimensions

The above approach can be readily extended to three dimensions. In three or more dimensions, even two lines almost certainly do not intersect; pairs of non-parallel lines that do not intersect are called
skew lines In three-dimensional geometry, skew lines are two Line (geometry), lines that do not Line-line intersection, intersect and are not Parallel (geometry), parallel. A simple example of a pair of skew lines is the pair of lines through opposite edges ...
. But if an intersection does exist it can be found, as follows. In three dimensions a line is represented by the intersection of two planes, each of which has an equation of the form :\begin a_ & a_ & a_ \end \beginx \\ y \\ z\end = b_i. Thus a set of lines can be represented by equations in the 3-dimensional coordinate vector : :\mathbf\mathbf=\mathbf where now is and is . As before there is a unique intersection point if and only if has full column rank and the augmented matrix does not, and the unique intersection if it exists is given by :\mathbf = \left(\mathbf^\mathsf \mathbf \right)^ \mathbf^\mathsf \mathbf.


Nearest points to skew lines

In two or more dimensions, we can usually find a point that is mutually closest to two or more lines in a
least-squares The method of least squares is a mathematical optimization technique that aims to determine the best fit function by minimizing the sum of the squares of the differences between the observed values and the predicted values of the model. The me ...
sense.


In two dimensions

In the two-dimensional case, first, represent line as a point on the line and a
unit Unit may refer to: General measurement * Unit of measurement, a definite magnitude of a physical quantity, defined and adopted by convention or by law **International System of Units (SI), modern form of the metric system **English units, histo ...
normal vector In geometry, a normal is an object (e.g. a line, ray, or vector) that is perpendicular to a given object. For example, the normal line to a plane curve at a given point is the infinite straight line perpendicular to the tangent line to the cu ...
, perpendicular to that line. That is, if and are points on line 1, then let and let :\mathbf_1:= \begin 0 & -1 \\ 1 & 0 \end \frac which is the unit vector along the line, rotated by a right angle. The distance from a point to the line is given by :d\bigl(\mathbf,(\mathbf,\mathbf)\bigr) = \bigl, (\mathbf-\mathbf)\cdot \mathbf\bigr, = \left, (\mathbf-\mathbf)^\mathsf \mathbf\ = \left, \mathbf ^\mathsf (\mathbf-\mathbf)\ = \sqrt. And so the squared distance from a point to a line is :d\bigl(\mathbf,(\mathbf,\mathbf)\bigr)^2 = (\mathbf-\mathbf)^\mathsf \left(\mathbf \mathbf^\mathsf \right) (\mathbf-\mathbf). The sum of squared distances to many lines is the cost function: :E(\mathbf) = \sum_i (\mathbf-\mathbf_i)^\mathsf \left(\mathbf_i \mathbf_i^\mathsf\right) (\mathbf-\mathbf_i). This can be rearranged: : \begin E(\mathbf) & = \sum_i \mathbf^\mathsf \mathbf_i \mathbf_i^\mathsf \mathbf - \mathbf^\mathsf \mathbf_i \mathbf_i^\mathsf \mathbf_i - \mathbf_i^\mathsf \mathbf_i \mathbf_i^\mathsf \mathbf + \mathbf_i^\mathsf \mathbf_i \mathbf_i^\mathsf \mathbf_i \\ & = \mathbf^\mathsf \left(\sum_i \mathbf_i \mathbf_i^\mathsf\right) \mathbf - 2 \mathbf^\mathsf \left(\sum_i \mathbf_i \mathbf_i^\mathsf \mathbf_i\right) + \sum_i \mathbf_i^\mathsf \mathbf_i \mathbf_i^\mathsf \mathbf_i. \end To find the minimum, we differentiate with respect to and set the result equal to the zero vector: :\frac = \boldsymbol = 2 \left(\sum_i \mathbf_i \mathbf_i^\mathsf\right) \mathbf - 2 \left(\sum_i \mathbf_i \mathbf_i^\mathsf \mathbf_i\right) so :\left(\sum_i \mathbf_i \mathbf_i^\mathsf\right) \mathbf = \sum_i \mathbf_i \mathbf_i^\mathsf \mathbf_i and so :\mathbf = \left(\sum_i \mathbf_i \mathbf_i^\mathsf\right)^ \left(\sum_i \mathbf_i \mathbf_i^\mathsf \mathbf_i\right).


In more than two dimensions

While is not well-defined in more than two dimensions, this can be generalized to any number of dimensions by noting that is simply the symmetric matrix with all eigenvalues unity except for a zero eigenvalue in the direction along the line providing a
seminorm In mathematics, particularly in functional analysis, a seminorm is like a Norm (mathematics), norm but need not be positive definite. Seminorms are intimately connected with convex sets: every seminorm is the Minkowski functional of some Absorbing ...
on the distance between and another point giving the distance to the line. In any number of dimensions, if is a unit vector ''along'' the th line, then : \mathbf_i \mathbf_i^\mathsf becomes \mathbf - \mathbf_i \mathbf_i^\mathsf where is the
identity matrix In linear algebra, the identity matrix of size n is the n\times n square matrix with ones on the main diagonal and zeros elsewhere. It has unique properties, for example when the identity matrix represents a geometric transformation, the obje ...
, and so : x= \left(\sum_i \mathbf-\mathbf_i \mathbf_i^\mathsf\right)^ \left(\sum_i \left(\mathbf-\mathbf_i \mathbf_i^\mathsf \right) \mathbf_i\right).


General derivation

In order to find the intersection point of a set of lines, we calculate the point with minimum distance to them. Each line is defined by an origin and a unit direction vector . The square of the distance from a point to one of the lines is given from Pythagoras: : d_i^2 = \left\, \mathbf - \mathbf_i \right\, ^2 - \left( \left( \mathbf - \mathbf_i \right)^\mathsf \mathbf_i \right)^2 = \left( \mathbf - \mathbf_i \right)^\mathsf \left( \mathbf - \mathbf_i \right) - \left( \left( \mathbf - \mathbf_i \right)^\mathsf \mathbf_i \right)^2 where is the projection of on line . The sum of distances to the square to all lines is : \sum_i d_i^2 = \sum_i \left( \left( \mathbf- \mathbf_i \right)- \right) To minimize this expression, we differentiate it with respect to . : \sum_i \left( 2\left( \mathbf - \mathbf_i \right)- 2 \left(\left( \mathbf - \mathbf_i \right)^\mathsf \mathbf_i\right) \mathbf_i\right)=\boldsymbol : \sum_i \left( \mathbf - \mathbf_i \right) = \sum_i \left( \mathbf_i \mathbf_i^\mathsf \right) \left( \mathbf - \mathbf_i \right) which results in : \left(\sum_i\left(\mathbf - \mathbf_i \mathbf_i^\mathsf \right)\right) \mathbf = \sum_i \left(\mathbf - \mathbf_i \mathbf_i^\mathsf \right) \mathbf_i where is the
identity matrix In linear algebra, the identity matrix of size n is the n\times n square matrix with ones on the main diagonal and zeros elsewhere. It has unique properties, for example when the identity matrix represents a geometric transformation, the obje ...
. This is a matrix , with solution , where is the pseudo-inverse of .


Non-Euclidean geometry

In
spherical geometry 300px, A sphere with a spherical triangle on it. Spherical geometry or spherics () is the geometry of the two-dimensional surface of a sphere or the -dimensional surface of higher dimensional spheres. Long studied for its practical applicati ...
, any two great circles intersect. In
hyperbolic geometry In mathematics, hyperbolic geometry (also called Lobachevskian geometry or János Bolyai, Bolyai–Nikolai Lobachevsky, Lobachevskian geometry) is a non-Euclidean geometry. The parallel postulate of Euclidean geometry is replaced with: :For a ...
, given any line and any point, there are infinitely many lines through that point that do not intersect the given line.


See also

*
Line segment intersection In geometry, an intersection is a point, line, or curve common to two or more objects (such as lines, curves, planes, and surfaces). The simplest case in Euclidean geometry is the line–line intersection between two distinct lines, which eith ...
* Line intersection in projective space *
Distance between two parallel lines The distance Distance is a numerical or occasionally qualitative measurement of how far apart objects, points, people, or ideas are. In physics or everyday usage, distance may refer to a physical length or an estimation based on other criter ...
*
Distance from a point to a line The distance (or perpendicular distance) from a point to a line is the shortest Euclidean distance, distance from a fixed Point (geometry), point to any point on a fixed infinite Line (mathematics), line in Euclidean geometry. It is the length of t ...
*
Line–plane intersection In analytic geometry, the intersection of a line and a plane in three-dimensional space can be the empty set, a point, or a line. It is the entire line if that line is embedded in the plane, and is the empty set if the line is parallel to the ...
*
Parallel postulate In geometry, the parallel postulate is the fifth postulate in Euclid's ''Elements'' and a distinctive axiom in Euclidean geometry. It states that, in two-dimensional geometry: If a line segment intersects two straight lines forming two interior ...
*
Triangulation (computer vision) In computer vision, triangulation refers to the process of determining a point in 3D space given its projections onto two, or more, images. In order to solve this problem it is necessary to know the parameters of the camera projection function ...
*


References


External links


Distance between Lines and Segments with their Closest Point of Approach
applicable to two, three, or more dimensions. {{DEFAULTSORT:Line-line intersection Euclidean geometry Linear algebra Geometric algorithms Geometric intersection