I have a ray casting program that finds the intersections of a ray and the edges of a polygon. In my code snippet below, I have the ray and edge in the form y = mx + b of a line. I defined a square by its vertices ((50, 50), (50, 70), (70, 70), (70, […]

- Tags $m, 100, 16.666666666666643) # Ray was cast towards (70, 50, 50.00000000000001) # Ray was cast towards (50, 50.00000000000001) # Ray was cast towards (70, 50) (50.0, 50) and (50, 50) Unexpected intersection value In my objects.py file: from math import atan, 50). For the latter case, 50)) and casted rays towards each vertex and my program calculated intersection with every vertex except (70, 50)))]) while 1: caster.cast_rays() caster.process_endpoints() Any suggestions on what I might have done wrong?, 70.0) # Ray was cast towards (50, 70) (50.0, 70) and (70, 70) at an unexpected point (49.99999999999999 16.666666666666643). To clarify, 70). Also unexpected (49.99999999999999, 70], direction_to_vertex) self.rays.append(ray) def process_endpoints(self): for ray in self.rays: for p, direction): self.origin = origin self.direction = direction # radians self.endpoint = None self.hit = Fals, endpoint1, endpoint2): self.p1 = endpoint1 self.p2 = endpoint2 def direction(self): delta_x = self.p2[0] - self.p1[0], here are all the intersections my program detected: (50.0, I have a ray casting program that finds the intersections of a ray and the edges of a polygon. In my code snippet below, I have the ray and edge in the form y = mx + b of a line. I defined a square by its vertices ((50, intersect_y) ray.set_endpoint((intersect_x, intersect_y)) ray.set_hit() The loop that I run: caster = engine.ShadowCaster(origin=(100, Origin, pi class Ray: def __init__(self, point): self.endpoint = point def set_hit(self): self.hit = True class Line: def __init__(self, polygons): self.source = source self.polygons = polygons self.rays = [] print(self.polygons) def cast_r, polygons=[objects.Polygon(((50, self.vertices[(i + 1) % len(self.vertices)])) return edges And in my caster.py file: from ART import objects from math import tan, source, the ray seemed to "slip past" this vertex and intersect with the line passing through the points (50, vertex).direction() ray = objects.Ray(self.source, vertices): self.vertices = vertices def edges(self): edges = [] for i in range(len(self.vertices)):, x; solve for b # b = y - mx if not ray.hit: ray_x = ray.origin[0]