Skip to content

Instantly share code, notes, and snippets.

@AlfredQin
AlfredQin / ray_caster.py
Created February 21, 2022 02:34 — forked from JiamingSuen/ray_caster.py
Ray casting in python with Trimesh and pyembree
"""
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
@AlfredQin
AlfredQin / dict_merge.py
Created September 16, 2021 12:57 — forked from angstwad/dict_merge.py
Recursive dictionary merge in Python
# 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
@AlfredQin
AlfredQin / Ray_Casting_Algorithm.py
Created June 25, 2021 01:58 — forked from aidenprice/Ray_Casting_Algorithm.py
A Python implementation of the Ray-Casting algorithm solution to the point-in-polygon problem. Originally a method in the APPolygonObject class written for my Curtin University, Masters of Geospatial Science, Spatial Computations 100, second assignment, BoreholeWrangler V3.0.
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