Ray-casting algorithm: Difference between revisions
Content added Content deleted
(Add Python) |
(→{{header|Python}}: scroll regions to reduce length) |
||
Line 366: | Line 366: | ||
=={{header|Python}}== |
=={{header|Python}}== |
||
<lang python>from collections import namedtuple |
<div style="height:70ex;overflow:scroll"><lang python>from collections import namedtuple |
||
from pprint import pprint as pp |
from pprint import pprint as pp |
||
import sys |
import sys |
||
Line 468: | Line 468: | ||
print ' ', '\t'.join("%s: %s" % (p, ispointinside(p, poly)) |
print ' ', '\t'.join("%s: %s" % (p, ispointinside(p, poly)) |
||
for p in testpoints[6:]) |
for p in testpoints[6:]) |
||
</lang> |
</lang></div> |
||
'''Sample output''' |
'''Sample output''' |
||
<pre style="height:30ex;overflow:scroll"> |
|||
<pre> |
|||
TESTING WHETHER POINTS ARE WITHIN POLYGONS |
TESTING WHETHER POINTS ARE WITHIN POLYGONS |
||
Line 524: | Line 524: | ||
'''Helper routine to convert Fortran Polygons and points to Python''' |
'''Helper routine to convert Fortran Polygons and points to Python''' |
||
<div style="height:30ex;overflow:scroll"> |
|||
<lang python>def _convert_fortran_shapes(): |
<lang python>def _convert_fortran_shapes(): |
||
point = Pt |
point = Pt |
||
Line 550: | Line 551: | ||
print ' ', ',\n '.join(str(e) for e in p.edges) + '\n )),' |
print ' ', ',\n '.join(str(e) for e in p.edges) + '\n )),' |
||
print ' ]' |
print ' ]' |
||
_convert_fortran_shapes()</lang> |
_convert_fortran_shapes()</lang></div> |
||
=={{header|Smalltalk}}== |
=={{header|Smalltalk}}== |