The main ray-tracing function. Provide a scene and a ray and get a full photon path history and list of events. Parameters ---------- scene: Scene The `Scene` to trace. ray: Ray The `Ray` to trace through the scene. maxste
(scene, ray, maxsteps=1000, maxpathlength=np.inf, emit_method="kT")
| 110 | |
| 111 | |
| 112 | def follow(scene, ray, maxsteps=1000, maxpathlength=np.inf, emit_method="kT"): |
| 113 | """ The main ray-tracing function. Provide a scene and a ray and get a full photon |
| 114 | path history and list of events. |
| 115 | |
| 116 | Parameters |
| 117 | ---------- |
| 118 | scene: Scene |
| 119 | The `Scene` to trace. |
| 120 | ray: Ray |
| 121 | The `Ray` to trace through the scene. |
| 122 | maxsteps: int |
| 123 | Abort ray tracing after this number of steps. Default is 1000. |
| 124 | maxpathlength: float |
| 125 | Abort ray tracing after ray has travelled more than this distance. Default |
| 126 | is infinity. |
| 127 | emit_method: str |
| 128 | Either `'kT'`, `'redshift'` or `'full'`. |
| 129 | |
| 130 | `'kT'` option allowed emitted rays to have a wavelength |
| 131 | within 3kT of the absorbed value. |
| 132 | |
| 133 | `'redshift'` option ensures the emitted ray has a longer of equal |
| 134 | wavelength. |
| 135 | |
| 136 | `'full'` option samples the full emission spectrum allowing the emitted |
| 137 | ray to take any value. |
| 138 | |
| 139 | Returns |
| 140 | ------- |
| 141 | history: tuple |
| 142 | Elements are 2-tuples (Ray, Event) |
| 143 | |
| 144 | Example |
| 145 | ------- |
| 146 | |
| 147 | Trace a scene with 10 rays:: |
| 148 | |
| 149 | for ray in scene.emit(10): |
| 150 | history = photon_tracer.follow(ray, scene) |
| 151 | rays, events = zip(*history) |
| 152 | """ |
| 153 | count = 0 |
| 154 | history = [(ray, Event.GENERATE)] |
| 155 | while True: |
| 156 | count += 1 |
| 157 | if count > maxsteps or ray.travelled > maxpathlength: |
| 158 | history.append([ray, Event.KILL]) |
| 159 | break |
| 160 | |
| 161 | info = next_hit(scene, ray) |
| 162 | if info is None: |
| 163 | break |
| 164 | |
| 165 | hit, (container, adjacent), point, full_distance = info |
| 166 | if hit is scene.root: |
| 167 | history.append((ray.propagate(full_distance), Event.EXIT)) |
| 168 | break |
| 169 |
nothing calls this directly
no test coverage detected