Returns a ray with wavelength, position and divergence sampled from the delegates. Parameters ---------- num_rays : int of None The maximum number of rays this light source will generate. If set to None then th
(self, num_rays=None)
| 135 | self.name = name |
| 136 | |
| 137 | def emit(self, num_rays=None) -> Iterator[Ray]: |
| 138 | """ Returns a ray with wavelength, position and divergence sampled from the |
| 139 | delegates. |
| 140 | |
| 141 | Parameters |
| 142 | ---------- |
| 143 | num_rays : int of None |
| 144 | The maximum number of rays this light source will generate. If set to |
| 145 | None then the light will generate until manually terminated. |
| 146 | """ |
| 147 | if num_rays is None or num_rays == 0: |
| 148 | return |
| 149 | count = 0 |
| 150 | while True: |
| 151 | count += 1 |
| 152 | if num_rays is not None and count > num_rays: |
| 153 | break |
| 154 | ray = Ray( |
| 155 | wavelength=self.wavelength(), |
| 156 | position=self.position(), |
| 157 | direction=self.direction(), |
| 158 | is_alive=True, |
| 159 | source=self.name, |
| 160 | ) |
| 161 | yield ray |