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 11:55, 5 December 2023
, 6 months ago→{{header|Wren}}: Added libheader.
(add RPL) |
m (→{{header|Wren}}: Added libheader.) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 591:
{{out}}
<pre>The ray intersects the plane at (0.000000,-5.000000,5.000000)</pre>
=={{header|EasyLang}}==
{{trans|Lua}}
proc minus . l[] r[] res[] .
len res[] 3
for i to 3
res[i] = l[i] - r[i]
.
func dot l[] r[] .
for i to 3
.
return res
.
proc scale f . l[] .
for i to 3
.
.
proc inter_point rv[] rp[] pn[] pp[] . res[] .
minus rp[] pp[] dif[]
prd1 = dot dif[] pn[]
prd2 = dot rv[] pn[]
scale (prd1 / prd2) rv[]
minus rp[] rv[] res[]
.
rv[] = [ 0.0 -1.0 -1.0 ]
rp[] = [ 0.0 0.0 10.0 ]
pn[] = [ 0.0 0.0 1.0 ]
pp[] = [ 0.0 0.0 5.0 ]
inter_point rv[] rp[] pn[] pp[] res[]
print res[]
</syntaxhighlight>
=={{header|Evaldraw}}==
Line 2,053 ⟶ 2,088:
=={{header|Wren}}==
{{trans|Kotlin}}
{{libheader|Wren-vector}}
▲<syntaxhighlight lang="ecmascript">class Vector3D {
<syntaxhighlight lang="wren">import "./vector" for Vector3
▲ _x = x
▲ _y = y
▲ }
var intersectPoint = Fn.new { |rayVector, rayPoint, planeNormal, planePoint|
Line 2,083 ⟶ 2,099:
}
var rv =
var rp =
var pn =
var pp =
var ip = intersectPoint.call(rv, rp, pn, pp)
System.print("The ray intersects the plane at %(ip).")</syntaxhighlight>
|