Ray-casting algorithm: Difference between revisions

Content added Content deleted
m (→‎{{header|REXX}}: added/changed comments and whitespace, optimized a function.)
m (→‎{{header|REXX}}: used a better over/under statement construct.)
Line 3,106: Line 3,106:
intersect: procedure expose point. poly.; parse arg ?,s; sp=s + 1
intersect: procedure expose point. poly.; parse arg ?,s; sp=s + 1
epsilon= '1e' || (-digits() %2); infinity= "1e" || (digits() *2)
epsilon= '1e' || (-digits() %2); infinity= "1e" || (digits() *2)
Px=point.?.x; Ax=poly.s.x; Ay=poly.s.y
Px=point.?.x; Ax=poly.s.x; Bx=poly.sp.x
Py=point.?.y; Bx=poly.sp.x; By=poly.sp.y /* [↓] do a swap.*/
Py=point.?.y; Ay=poly.s.y; By=poly.sp.y /* [↓] do a vertex swap*/
if Ay>By then parse value Ax Ay Bx By with Bx By Ax Ay
if Ay>By then parse value Ax Ay Bx By with Bx By Ax Ay
if Py=Ay | Py=By then Py=Py + epsilon
if Py=Ay | Py=By then Py=Py + epsilon