Find the intersection of two lines: Difference between revisions

Content added Content deleted
Line 255: Line 255:
⍝ The following solver will take ⍵ the matrix of coordinates, one point per row, then massage the argument to extract x,y
⍝ The following solver will take ⍵ the matrix of coordinates, one point per row, then massage the argument to extract x,y
⍝ and inject 1, where needed
⍝ and inject 1, where needed
⍝ Applied twice, we now have a, b and a', b' defining the two lines, we need to resolve it in x and y
⍝ Applied twice, we now have a, b and a', b' defining the two lines, we need to resolve it in x and y, in order to determine
⍝ their intersection
⍝ y = ax + b
⍝ y = ax + b
⍝ y = a'x + b'
⍝ y = a'x + b'
⍝ In order to reuse the same solver, we need to format it a little bit, and change the sign of a and a', and multiply (a,b) by (-1, 1):
⍝ In order to reuse the same solver, we need to format a little bit the arguments, and change the sign of a and a', therefore
⍝ multiply (a,b) by (-1, 1):
⍝ b = -ax + y
⍝ b = -ax + y
⍝ b' = -a'x + y
⍝ b' = -a'x + y