Anonymous user
Find the intersection of a line with a plane: Difference between revisions
Find the intersection of a line with a plane (view source)
Revision as of 14:39, 16 December 2020
, 3 years ago→{{header|APL}}
m (→{{header|APL}}) |
m (→{{header|APL}}) |
||
Line 22:
=={{header|APL}}==
<lang APL>⍝ Find
⍝ The intersection I belongs to a line defined by point L and vector V,
⍝ 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
⍝ This translates to:
⍝ (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
⍝
⍝ 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
|