This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Adapted from trimesh example raytrace.py | |
| ---------------- | |
| Install `pyembree` for a speedup (600k+ rays per second) | |
| """ | |
| import PIL.Image | |
| import trimesh | |
| import numpy as np | |
| from typing import List |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Recursive dictionary merge | |
| # Copyright (C) 2016 Paul Durivage <pauldurivage+github@gmail.com> | |
| # | |
| # This program is free software: you can redistribute it and/or modify | |
| # it under the terms of the GNU General Public License as published by | |
| # the Free Software Foundation, either version 3 of the License, or | |
| # (at your option) any later version. | |
| # | |
| # This program is distributed in the hope that it will be useful, | |
| # but WITHOUT ANY WARRANTY; without even the implied warranty of |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def determineIfPointLiesWithinPolygon(self, locationToTest): | |
| # Check that the argument is actually a LocationObject. | |
| if isinstance(locationToTest, LocationObject): | |
| # Set crossings value to initial zero value. | |
| iCrossings = 0 | |
| # For each segment of the polygon (i.e. line drawn between each of the polygon's vertices) check whether | |
| # a ray cast straight down from the test location intersects the segment (keep in mind that the segment | |
| # may be intersected either coming or going). If the ray does cross the segment, increment the iCrossings |