Ray-casting algorithm: Difference between revisions

→‎{{header|Wren}}: Now uses new core library method.
(→‎{{header|Lua}}: added Lua solution)
(→‎{{header|Wren}}: Now uses new core library method.)
Line 4,256:
=={{header|Wren}}==
{{trans|Java}}
{{libheader|Wren-math}}
{{libheader|Wren-fmt}}
<lang ecmascript>import "/mathfmt" for MathFmt
import "/fmt" for Fmt
 
class RayCasting {
Line 4,265 ⟶ 4,263:
if (a[1] > b[1]) return intersects(b, a, p)
if (p[1] == a[1] || p[1] == b[1]) p[1] = p[1] + 0.0001
if (p[1] > b[1] || p[1] < a[1] || p[0] >= Math.max(a[0], .max(b[0])) return false
if (p[0] < Math.min(a[0], .min(b[0])) return true
var red = (p[1] - a[1]) / (p[0] - a[0])
var blue = (b[1] - a[1]) / (b[0] - a[0])
9,488

edits