Clever Geek Handbook
📜 ⬆️ ⬇️

Intersection of lines

Intersection of lines.

In Euclidean geometry, the intersection of two lines can be an empty set , point, or line. The distinction between these cases and the search for the intersection point is used, for example, in computer graphics , in and for collision detection .

In three - dimensional Euclidean geometry, if two lines are not in the same plane , they are called intersecting and do not have intersection points. If the lines are in the same plane, there are three possibilities. If they coincide, they have infinitely many common points (namely, all points on these lines). If the lines are different but have the same slope, they are parallel and do not have common points. Otherwise, they have one intersection point.

In non-Euclidean geometry, two lines can intersect at several points, and the number of other lines (parallel) that do not intersect with this line can be more than one.

Content

The intersection of two lines

A necessary condition for the intersection of two lines is that they belong to the same plane, that is, these lines should not be crossed. The fulfillment of this condition is equivalent to the degeneracy of the tetrahedron , in which two vertices lie on one straight line and the other two on the other (i.e., the volume of this tetrahedron is zero). The algebraic form of this condition can be found in the article “ Checking the Cross ”.

If two points on each line are given

Consider the intersection of two linesLone {\ displaystyle L_ {1} \,}   andL2 {\ displaystyle L_ {2} \,}   on the plane where the lineLone {\ displaystyle L_ {1} \,}   defined by two different points(xone,yone) {\ displaystyle (x_ {1}, y_ {1}) \,}   and(x2,y2) {\ displaystyle (x_ {2}, y_ {2}) \,}   , and directL2 {\ displaystyle L_ {2} \,}   - various points(x3,y3) {\ displaystyle (x_ {3}, y_ {3}) \,}   and(xfour,yfour) {\ displaystyle (x_ {4}, y_ {4}) \,}   [1] .

IntersectionP {\ displaystyle P \,}   directLone {\ displaystyle L_ {1} \,}   andL2 {\ displaystyle L_ {2} \,}   can be found using qualifiers .

Px=||xoneyonex2y2||xoneonex2one||x3y3xfouryfour||x3onexfourone||||xoneonex2one||yoneoney2one||x3onexfourone||y3oneyfourone||Py=||xoneyonex2y2||yoneoney2one||x3y3xfouryfour||y3oneyfourone||||xoneonex2one||yoneoney2one||x3onexfourone||y3oneyfourone||{\ displaystyle P_ {x} = {\ frac {\ begin {vmatrix} {\ begin {vmatrix} x_ {1} & y_ {1} \\ x_ {2} & y_ {2} \ end {vmatrix}} & {\ begin {vmatrix} x_ {1} & 1 \\ x_ {2} & 1 \ end {vmatrix}} \\\\ {\ begin {vmatrix} x_ {3} & y_ {3} \\ x_ {4} & y_ {4} \ end {vmatrix}} & {\ begin {vmatrix} x_ {3} & 1 \\ x_ {4} & 1 \ end {vmatrix}} \ end {vmatrix}} {\ begin {vmatrix} {\ begin {vmatrix} x_ {1} & 1 \\ x_ {2} & 1 \ end {vmatrix}} & {\ begin {vmatrix} y_ {1} & 1 \\ y_ {2} & 1 \ end {vmatrix}} \\\\ {\ begin { vmatrix} x_ {3} & 1 \\ x_ {4} & 1 \ end {vmatrix}} & {\ begin {vmatrix} y_ {3} & 1 \\ y_ {4} & 1 \ end {vmatrix}} \ end {vmatrix} }} \, \! \ qquad P_ {y} = {\ frac {\ begin {vmatrix} {\ begin {vmatrix} x_ {1} & y_ {1} \\ x_ {2} & y_ {2} \ end {vmatrix }} & {\ begin {vmatrix} y_ {1} & 1 \\ y_ {2} & 1 \ end {vmatrix}} \\\\ {\ begin {vmatrix} x_ {3} & y_ {3} \\ x_ {4 } & y_ {4} \ end {vmatrix}} & {\ begin {vmatrix} y_ {3} & 1 \\ y_ {4} & 1 \ end {vmatrix}} end {vmatrix}} {\ begin {vmatrix} {\ begin {vmatrix} x_ {1} & 1 \\ x_ {2} & 1 \ end {vmatrix}} & {\ begin {vmatrix} y_ {1} & 1 \\ y_ {2} & 1 \ end {vmatrix}} \\\ \ {\ begin {vmatrix} x_ {3} & 1 \\ x_ {4} & 1 \ end {vmatrix}} & {\ begin {vmatrix} y_ {3} & 1 \\ y_ {4} & 1 \ end {vmatrix}} \ end {vmatrix}}} \, \!}  

Qualifiers can be rewritten as:

(Px,Py)=((xoney2-yonex2)(x3-xfour)-(xone-x2)(x3yfour-y3xfour)(xone-x2)(y3-yfour)-(yone-y2)(x3-xfour),(xoney2-yonex2)(y3-yfour)-(yone-y2)(x3yfour-y3xfour)(xone-x2)(y3-yfour)-(yone-y2)(x3-xfour)){\ displaystyle {\ begin {aligned} (P_ {x}, P_ {y}) = {\ bigg (} & {\ frac {(x_ {1} y_ {2} -y_ {1} x_ {2}) (x_ {3} -x_ {4}) - (x_ {1} -x_ {2}) (x_ {3} y_ {4} -y_ {3} x_ {4})} {(x_ {1} - x_ {2}) (y_ {3} -y_ {4}) - (y_ {1} -y_ {2}) (x_ {3} -x_ {4})}}, \\ & {\ frac {( x_ {1} y_ {2} -y_ {1} x_ {2}) (y_ {3} -y_ {4}) - (y_ {1} -y_ {2}) (x_ {3} y_ {4} -y_ {3} x_ {4})} {(x_ {1} -x_ {2}) (y_ {3} -y_ {4}) - (y_ {1} -y_ {2}) (x_ {3 } -x_ {4})}} {\ bigg)} \ end {aligned}}}  

Note that the intersection point refers to infinite lines, not segments between points, and it can lie outside the segments. If (instead of solving in one step) to look for a solution in terms of first-order Bezier curves, then we can check the parameters of these curves 0.0 ≤ t ≤ 1.0 and 0.0 ≤ u ≤ 1.0 ( t and u are parameters).

If two lines are parallel or coincide, the denominator vanishes:

(xone-x2)(y3-yfour)-(yone-y2)(x3-xfour)=0.{\ displaystyle (x_ {1} -x_ {2}) (y_ {3} -y_ {4}) - (y_ {1} -y_ {2}) (x_ {3} -x_ {4}) = 0 .}  

If the lines are very close to parallelism (almost parallel), when calculating on a computer, numerical problems may arise and recognition of such a condition may require a suitable “uncertainty” test for the application. A more stable and general solution can be obtained by rotating the segments in such a way that one of them becomes horizontal, and then the parametric solution of the second line is easy to obtain. When solving, careful consideration of special cases is necessary (parallelism / coincidence of lines, overlapping of segments).

If equations of lines are given

Coordinatesx {\ displaystyle x}   andy {\ displaystyle y}   the intersection points of two non-vertical lines can be easily found using the following permutations and transformations.

Suppose two lines have equationsy=ax+c {\ displaystyle y = ax + c}   andy=bx+d {\ displaystyle y = bx + d}   wherea {\ displaystyle a}   andb {\ displaystyle b}   Are the angular coefficients of the lines, andc {\ displaystyle c}   andd {\ displaystyle d}   - intersections of lines with the y axis. At the point of intersection of the lines (if they intersect), both coordinatesy {\ displaystyle y}   will coincide, whence we get the equality:

ax+c=bx+d{\ displaystyle ax + c = bx + d}   .

We can transform this equality in order to highlightx {\ displaystyle x}   ,

ax-bx=d-c{\ displaystyle ax-bx = dc}   ,

and then

x=d-ca-b{\ displaystyle x = {\ frac {dc} {ab}}}   .

To find the y coordinate, all we need is to substitute the value of x into one of the line formulas, for example, in the first:

y=ad-ca-b+c{\ displaystyle y = a {\ frac {dc} {ab}} + c}   .

Hence we get the intersection point of the lines

P(d-ca-b,ad-ca-b+c)=P(d-ca-b,ad-bca-b){\ displaystyle P \ left ({\ frac {dc} {ab}}, a {\ frac {dc} {ab}} + c \ right) = P \ left ({\ frac {dc} {ab}}, {\ frac {ad-bc} {ab}} \ right)}   .

Note that for a = b the two lines are parallel. If, in addition, c ≠ d , the lines are different and have no intersections, otherwise the lines coincide [2] .

Using uniform coordinates

When using homogeneous coordinates , the intersection point of two clearly defined lines can be found quite simply. In 2-dimensional space, any point can be defined as the projection of a 3-dimensional point defined by a triple(x,y,w) {\ displaystyle (x, y, w)}   . The mapping of 3D coordinates to 2D takes place according to the formula(x′,y′)=(x/w,y/w) {\ displaystyle (x ', y') = (x / w, y / w)}   . We can transform points in 2-dimensional space into homogeneous coordinates, equating the third coordinate to unity -(x,y,one) {\ displaystyle (x, y, 1)}   .

Suppose we want to find the intersection of two infinite lines in 2-dimensional space that are given by the formulasaonex+boney+cone=0 {\ displaystyle a_ {1} x + b_ {1} y + c_ {1} = 0}   anda2x+b2y+c2=0 {\ displaystyle a_ {2} x + b_ {2} y + c_ {2} = 0}   . We can represent these two lines in asUone=(aone,bone,cone) {\ displaystyle U_ {1} = (a_ {1}, b_ {1}, c_ {1})}   andU2=(a2,b2,c2) {\ displaystyle U_ {2} = (a_ {2}, b_ {2}, c_ {2})}   ,

IntersectionP′ {\ displaystyle P '}   of two lines then is simply given by the formulas [3]

P′=(ap,bp,cp)=Uone×U2=(bonec2-b2cone,a2cone-aonec2,aoneb2-a2bone){\ displaystyle 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 acp=0 {\ displaystyle c_ {p} = 0}   , lines do not intersect.

Intersection of n lines

Existence and expression of intersection

In two-dimensional space

In two-dimensional space, lines with a number greater than two do not almost reliably intersect at one point. To determine if they intersect at one point, and if they intersect, to find the intersection point, we write the ith equation ( i = 1, ..., n ) as(aioneai2)(xy)T=bi, {\ displaystyle (a_ {i1} \ quad a_ {i2}) (x \ quad y) ^ {T} = b_ {i},}   and compose these equations in matrix form

Aw=b,{\ displaystyle Aw = b,}  

where the ith row n × 2 of matrix A is(aione,ai2) {\ displaystyle (a_ {i1}, a_ {i2})}   , w is the 2 × 1 vector ( x, y ) T , and the i- th element of the column vector b is equal to b i . If the columns of the matrix A are independent, the rank of the matrix is 2. Then and only if the rank of the [ A | b ] is also equal to 2, there is a solution to the matrix equation, and then there is the intersection point of n lines. The intersection point, if one exists, is given by the formula

w=Agb=(ATA)-oneATb,{\ displaystyle w = A ^ {g} b = (A ^ {T} A) ^ {- 1} A ^ {T} b,}  

WhereAg {\ displaystyle A ^ {g}}   - pseudoinverse matrix matrixA {\ displaystyle A}   . Alternatively, a solution can be found by solving any two independent equations. But if the rank of the matrix A is 1 and the rank of the extended matrix is ​​2, there are no solutions. In the case when the rank of the extended matrix is ​​1, all lines coincide.

In three-dimensional space

The approach presented above easily extends to three-dimensional space. In three-dimensional and higher spaces, even two straight lines almost certainly do not intersect. Pairs of non-parallel disjoint lines are called crossed . But when the intersection exists, it can be found as follows.

In three-dimensional space, the line is represented by the intersection of two planes, each of which is given by the formula(aioneai2ai3)(xyz)T=bi. {\ displaystyle (a_ {i1} \ quad a_ {i2} \ quad a_ {i3}) (x \ quad y \ quad z) ^ {T} = b_ {i}.}   Then the set of n lines can be represented as 2 n equations of the 3-dimensional coordinate vector w = ( x , y , z ) T :

Aw=b{\ displaystyle Aw = b}   ,

where A is a 2 n × 3 matrix and b is 2 n × 1. As before, a unique intersection point exists if and only if A has a full rank in the columns and the extended matrix [ A | b ] it is not. The only intersection point, if exists, is given by the formula

w=(ATA)-oneATb.{\ displaystyle w = (A ^ {T} A) ^ {- 1} A ^ {T} b.}  

Closest point to disjoint straight lines

In dimensions two and above, you can find a point that is closest to these two (or more) lines in the sense of the least sum of squares .

In two-dimensional space

In the case of two-dimensional space, we represent the line i as a pointpi {\ displaystyle p_ {i}}   on direct and unit normaln^i {\ displaystyle {\ hat {n}} _ {i}}   perpendicular to the line. That is, ifxone {\ displaystyle x_ {1}}   andx2 {\ displaystyle x_ {2}}   Are points on line 1, then letpone=xone {\ displaystyle p_ {1} = x_ {1}}   and

n^one: =[0-oneone0](x2-xone)/‖x2-xone‖{\ displaystyle {\ hat {n}} _ {1}: = {\ begin {bmatrix} 0 & -1 \\ 1 & 0 \ end {bmatrix}} (x_ {2} -x_ {1}) / \ | x_ { 2} -x_ {1} \ |}   ,

which is a unit vector along a line rotated 90º.

Note that the distance from the point x to the line(p,n^) {\ displaystyle (p, {\ hat {n}})}   is given by the formula

d(x,(p,n))=‖(x-p)⋅n^‖=‖(x-p)⊤n^‖=(x-p)⊤n^n^⊤(x-p).{\ displaystyle d (x, (p, n)) = \ | (xp) \ cdot {\ hat {n}} \ | = \ | (xp) ^ {\ top} {\ hat {n}} \ | = {\ sqrt {(xp) ^ {\ top} {\ hat {n}} {\ hat {n}} ^ {\ top} (xp)}}.}  

Therefore, the square of the distance from x to the line is

d(x,(p,n))2=(x-p)⊤(n^n^⊤)(x-p).{\ displaystyle d (x, (p, n)) ^ {2} = (xp) ^ {\ top} ({\ hat {n}} {\ hat {n}} ^ {\ top}) (xp) .}  

The sum of the squares of the distances to the set of lines is the objective function :

E(x)=∑i(x-pi)⊤(n^in^i⊤)(x-pi).{\ displaystyle E (x) = \ sum _ {i} (x-p_ {i}) ^ {\ top} ({\ hat {n}} _ {i} {\ hat {n}} _ {i} ^ {\ top}) (x-p_ {i}).}  

An expression can be converted:

E(x)=∑ix⊤n^in^i⊤x-x⊤n^in^i⊤pi-pi⊤n^in^i⊤x+pi⊤n^in^i⊤pi=x⊤(∑in^in^i⊤)x-2x⊤(∑in^in^i⊤pi)+∑ipi⊤n^in^i⊤pi.{\ displaystyle {\ begin {aligned} E (x) & = \ sum _ {i} x ^ {\ top} {\ hat {n}} _ {i} {\ hat {n}} _ {i} ^ {\ top} xx ^ {\ top} {\ hat {n}} _ {i} {\ hat {n}} _ {i} ^ {\ top} p_ {i} -p_ {i} ^ {\ top } {\ hat {n}} _ {i} {\ hat {n}} _ {i} ^ {\ top} x + p_ {i} ^ {\ top} {\ hat {n}} _ {i} {\ hat {n}} _ {i} ^ {\ top} p_ {i} \\ & = x ^ {\ top} \ left (\ sum _ {i} {\ hat {n}} _ {i} {\ hat {n}} _ {i} ^ {\ top} \ right) x-2x ^ {\ top} \ left (\ sum _ {i} {\ hat {n}} _ {i} {\ hat {n}} _ {i} ^ {\ top} p_ {i} \ right) + \ sum _ {i} p_ {i} ^ {\ top} {\ hat {n}} _ {i} {\ hat {n}} _ {i} ^ {\ top} p_ {i}. \ end {aligned}}}  

To find the minimum, we differentiate with respect to x and equate the result to zero:

∂E(x)∂x=0=2(∑in^in^i⊤)x-2(∑in^in^i⊤pi){\ displaystyle {\ frac {\ partial E (x)} {\ partial x}} = 0 = 2 \ left (\ sum _ {i} {\ hat {n}} _ {i} {\ hat {n} } _ {i} ^ {\ top} \ right) x-2 \ left (\ sum _ {i} {\ hat {n}} _ {i} {\ hat {n}} _ {i} ^ {\ top} p_ {i} \ right)}  

In this way,

(∑in^in^i⊤)x=∑in^in^i⊤pi{\ displaystyle \ left (\ sum _ {i} {\ hat {n}} _ {i} {\ hat {n}} _ {i} ^ {\ top} \ right) x = \ sum _ {i} {\ hat {n}} _ {i} {\ hat {n}} _ {i} ^ {\ top} p_ {i}}  

where from

x=(∑in^in^i⊤)-one(∑in^in^i⊤pi).{\ displaystyle x = \ left (\ sum _ {i} {\ hat {n}} _ {i} {\ hat {n}} _ {i} ^ {\ top} \ right) ^ {- 1} \ left (\ sum _ {i} {\ hat {n}} _ {i} {\ hat {n}} _ {i} ^ {\ top} p_ {i} \ right).}  

In three-dimensional space

Although in dimensions above two normaln^i {\ displaystyle {\ hat {n}} _ {i}}   not defined, it can be generalized to any dimension, if you notice thatn^in^i⊤ {\ displaystyle {\ hat {n}} _ {i} {\ hat {n}} _ {i} ^ {\ top}}   is a simple (symmetric) matrix with all eigenvalues ​​equal to unity, except for the zero eigenvalue in the direction of the line, which defines the seminorm between the pointpi {\ displaystyle p_ {i}}   and another point. In space of any dimension ifv^i {\ displaystyle {\ hat {v}} _ {i}}   is the unit vector along the i- th line, then

n^in^i⊤{\ displaystyle {\ hat {n}} _ {i} {\ hat {n}} _ {i} ^ {\ top}}   turns intoE-v^iv^i⊤ {\ displaystyle E - {\ hat {v}} _ {i} {\ hat {v}} _ {i} ^ {\ top}}   ,

where E is the identity matrix, and then

x=(∑iE-v^iv^i⊤)-one(∑i(E-v^iv^i⊤)pi).{\ displaystyle x = \ left (\ sum _ {i} E - {\ hat {v}} _ {i} {\ hat {v}} _ {i} ^ {\ top} \ right) ^ {- 1 } \ left (\ sum _ {i} (E - {\ hat {v}} _ {i} {\ hat {v}} _ {i} ^ {\ top}) p_ {i} \ right).}  

See also

  • The distance from a point to a line on a plane
  • Axiom of Euclidean parallelism

Notes

  1. ↑ Weisstein, Eric W. "Line-Line Intersection." From MathWorld (Neopr.) . A Wolfram Web Resource . Date of treatment January 10, 2008.
  2. ↑ Similar calculations can be found in the book of Delaunay and Raikov (p. 202-203)
  3. ↑ Homogeneous coordinates ( unspecified ) . robotics.stanford.edu . Date accessed August 18, 2015.

Literature

  • B.N. Delone, D.A. Raikov. Analytic geometry. - M., L .: OGIZ, State Publishing House of technical and theoretical literature, 1948. - T. 1.


Links

  • Distance between Lines and Segments with their Closest Point of Approach , applicable to two, three, or more dimensions.


Source - https://ru.wikipedia.org/w/index.php?title=Direct Intersection&oldid = 80975992


More articles:

  • Species of the genus Buzulnik
  • Kubas, Adrian
  • Krasnaya Gorka (Yemeshevskoe rural settlement)
  • Trumpet, Jacob
  • Enmity (TV series)
  • 517 year
  • LAZ-695NG
  • + (Ed Sheeran album)
  • Bakulin Motors Group
  • XOTcl

All articles

Clever Geek | 2019