MCPcopy Create free account
hub / github.com/danieljfarrell/pvtrace / intersections

Method intersections

pvtrace/scene/node.py:102–139  ·  view source on GitHub ↗

Returns intersections with node's geometry and child subtree. Parameters ---------- ray_origin : tuple of float The ray position `(x, y, z)`. ray_direction : tuple of float The ray position `(a, b, c)`.

(self, ray_origin, ray_direction)

Source from the content-addressed store, hash-verified

100 return path
101
102 def intersections(self, ray_origin, ray_direction) -> Sequence[Intersection]:
103 """ Returns intersections with node's geometry and child subtree.
104
105 Parameters
106 ----------
107 ray_origin : tuple of float
108 The ray position `(x, y, z)`.
109 ray_direction : tuple of float
110 The ray position `(a, b, c)`.
111
112 Returns
113 -------
114 all_intersections : tuple of Intersection
115 All intersection with this scene and a list of Intersection objects.
116 """
117 all_intersections = []
118 if self.geometry is not None:
119 points = self.geometry.intersections(ray_origin, ray_direction)
120 for point in points:
121 intersection = Intersection(
122 coordsys=self,
123 point=point,
124 hit=self,
125 distance=distance_between(ray_origin, point),
126 )
127 all_intersections.append(intersection)
128 all_intersections = tuple(all_intersections)
129
130 for child in self.children:
131 # Intersections with node's geometry
132 ray_origin_in_child = self.point_to_node(ray_origin, child)
133 ray_direction_in_child = self.vector_to_node(ray_direction, child)
134 # Intersections with node's subtree
135 intersections_in_child = child.intersections(
136 ray_origin_in_child, ray_direction_in_child
137 )
138 all_intersections = all_intersections + intersections_in_child
139 return all_intersections
140
141 def emit(self, num_rays=None) -> Iterator[Ray]:
142 """ Generator of rays using the node's light object.

Calls 4

point_to_nodeMethod · 0.95
vector_to_nodeMethod · 0.95
IntersectionClass · 0.90
distance_betweenFunction · 0.90