Jump to content

Ray-casting algorithm: Difference between revisions

m
→‎{{header|REXX}}: added a "swap" comment.
m (→‎{{header|REXX}}: corrected a typo, changed some comments.)
m (→‎{{header|REXX}}: added a "swap" comment.)
Line 2,565:
ray_intersect: procedure expose point. poly.; parse arg ?,s; sp=s+1
epsilon='1e' || (digits()%2); infinity='1e' || (digits()*2)
Px=point.?.x; Py Ax=pointpoly.?s.x; Ay=poly.s.y
AxPy=polypoint.s?.xy; Bx=poly.sp.x; AyBy=poly.ssp.y; /* By=poly.sp.y[↓] do a swap*/
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 | Px>max(Ax,Bx) then return 0
if Px<min(Ax,Bx) then return 1
if Ax\=Bx then m_red =(By-Ay)/(Bx-Ax)
else m_red =infinity
if Ax\=Px then m_blue=(Py-Ay)/(Px-Ax)
else return 1
Cookies help us deliver our services. By using our services, you agree to our use of cookies.