Anonymous user
Ray-casting algorithm: Difference between revisions
m
→{{header|REXX}}: aligned the points and vertices better.
m (→{{header|REXX}}: added a "swap" comment.) |
m (→{{header|REXX}}: aligned the points and vertices better.) |
||
Line 2,532:
seems to indicate that this code considers those points as outside the polygon.
<lang rexx>/*REXX pgm checks to see if a horizontal ray from point P intersects a polygon*/
call points 5 5, 5 8,
call
call
call
call poly 3 0, 7 0, 10 5, 7 10, 3 10, 0 5 ; call test 'hexagon'
exit /*stick a fork in it, we're all done. */
/*────────────────────────────────────────────────────────────────────────────*/
Line 2,551 ⟶ 2,552:
return
/*────────────────────────────────────────────────────────────────────────────*/
do j=1 for arg(); n=n+1; _=arg(j); parse var _ xx yy
Line 2,559 ⟶ 2,560:
call value v||n'.X', word(_,1); call value v||n'.Y', word(_,2)
end /*j*/
/*────────────────────────────────────────────────────────────────────────────*/
ray_intersect: procedure expose point. poly.; parse arg ?,s; sp=s+1
epsilon='1e' || (digits()%2); infinity='1e' || (digits() *2)
Px=point.?.x; Ax=poly.s.x; Ay=poly.s.y
Py=point.?.y; Bx=poly.sp.x; By=poly.sp.y /* [↓] do a swap*/
|