Find the intersection of a line with a plane: Difference between revisions

m
Line 22:
 
=={{header|APL}}==
<lang APL>⍝ Find Intersectionthe intersection of a line with a plane
⍝ The intersection I belongs to a line defined by point L and vector V, meanstranslates that t exists, so that I = L + tVto:
⍝ A real parameter t exists, that satisfies I = L + tV
⍝ I belongs to the plan defined by point P and normal vector N. This means that any two points of the plane make a vector normal ⍝ to vector N, I and P belong to the plane, so the vector IP is normal to vector N.
⍝ This translates to: theirThe scalar product beingIP.N zero= 0.
⍝ (P - I).N = 0 <=> (P - L - tV).N = 0
⍝ Using distributivity, then associativity, the following equations are established:
⍝ (P - L - tV).N = (P - L).N - (tV).N = (P - L).N - t(V.N) = 0
soWhich thatallows to resolve t: t = ((P - L).N) ÷ (V.N)
⍝ In APL, A.B is coded +/A x B
V ← 0 ¯1 ¯1
Line 35 ⟶ 36:
N ← 0 0 1
P ← 0 0 5
dot ← { +/⍺×⍵ ⍺ × ⍵ }
t ← ((P - L) dot N) ÷ V dot N
I ← L + t × V
Anonymous user