Ray-casting algorithm: Difference between revisions
Content added Content deleted
(Updated D code) |
(Updated D entry) |
||
Line 502: | Line 502: | ||
} |
} |
||
return count!(e => raySegI(p, e))( |
return poly.edges.count!(e => raySegI(p, e))() % 2; |
||
} |
} |
||
Line 531: | Line 531: | ||
writefln(`Is point inside figure "%s"?`, poly.name); |
writefln(`Is point inside figure "%s"?`, poly.name); |
||
foreach (p; testPoints) |
foreach (p; testPoints) |
||
writefln(" (%3s, %2s): %s", p.x, p.y, contains(poly,p)); |
writefln(" (%3s, %2s): %s", p.x, p.y, contains(poly, p)); |
||
writeln(); |
writeln(); |
||
} |
} |