-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathex05.py
More file actions
37 lines (24 loc) · 1.13 KB
/
ex05.py
File metadata and controls
37 lines (24 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import env # noqa: F401
from pytissueoptics import * # noqa: F403
TITLE = "Sphere inside a cube"
DESCRIPTION = """ Propagation of a directional light source through a highly scattering medium scene composed of a
sphere inside a cube. """
def exampleCode():
N = 10000 if hardwareAccelerationIsAvailable() else 200
material1 = ScatteringMaterial(mu_s=20, mu_a=0.1, g=0.9, n=1.4)
material2 = ScatteringMaterial(mu_s=30, mu_a=0.2, g=0.9, n=1.7)
cube = Cuboid(a=3, b=3, c=3, position=Vector(0, 0, 0), material=material1, label="cube")
sphere = Sphere(radius=1, order=3, position=Vector(0, 0, 0), material=material2, label="sphere", smooth=True)
scene = ScatteringScene([cube, sphere])
logger = EnergyLogger(scene)
source = DirectionalSource(
position=Vector(0, 0, -2), direction=Vector(0, 0, 1), N=N, diameter=0.5, displaySize=0.25
)
source.propagate(scene, logger)
viewer = Viewer(scene, source, logger)
viewer.reportStats()
viewer.show2D(View2DProjectionY())
viewer.show2D(View2DProjectionY(solidLabel="sphere"))
viewer.show3D()
if __name__ == "__main__":
exampleCode()