File size: 3,102 Bytes
8666e0f 5ee263c 8666e0f 46251b7 8666e0f adc8d2e 8666e0f cc6e945 0956288 5ee263c 8666e0f 46251b7 5ee263c adc8d2e cc6e945 5ee263c 8666e0f |
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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
import gradio as gr
from backend.nonreflecting_ray_tracing import nonreflecting_plotter
from backend.reflecting_ray_tracing import reflecting_plotter
description1 = (
"A source of **light** placed at the **origin**. A spherical **non-Reflecting** surface placed in front it."
"**Change ANY Parameter to get it working.**"
)
iface1 = gr.Interface(
fn = nonreflecting_plotter,
inputs=[
gr.Number(label="Circle Center X (a)", value=20, info="X coordinate of Circle center"),
gr.Number(label="Circle Center Y (b)", value=20, info="Y coordinate of Circle center"),
gr.Number(label="Radius (r)", value=15, info="Radius of the circle"),
gr.Slider(minimum=3, maximum=1000, step=1, label="Number of Rays", value=50, info="Number of rays to be plotted in total"),
gr.Radio(label="Remove Clutter", choices=["Yes", "No"], value="No", info="Only keep rays that are INCIDENT by the surface."),
],
outputs=[
gr.Image(label="Ray Tracing Output"),
gr.Number(label="Fraction of Incident Rays", info="Out of 100 rays, how many are incident on the surface"),
],
live=True,
title="Non-Reflective Ray Tracing",
description=description1,
)
description2 = ("A source of **light** placed at the **origin**. A spherical **Reflecting surface** placed in front it. This interface simulates the rays interaction with the Reflecting surface."
"**Change ANY Parameter to get it working.**"
)
iface2 = gr.Interface(
fn = reflecting_plotter,
inputs=[
gr.Number(label="Circle Center X (a)", value=20, info="X coordinate of Circle center"),
gr.Number(label="Circle Center Y (b)", value=20, info="Y coordinate of Circle center"),
gr.Number(label="Radius (r)", value=15, info="Radius of the circle"),
gr.Slider(minimum=3, maximum=1000, step=1, label="Number of Rays", value=50, info="Number of rays to be plotted in total"),
gr.Radio(label="Remove Clutter", choices=["Yes", "No"], value="No", info="Only keep rays that are REFLECTED to the surface."),
],
outputs=[
gr.Image(label="Ray Tracing Output"),
gr.Number(label="Fraction of Reflected Rays", info="Out of 100 rays, how many get reflected by the surface"),
],
live=True,
title="Reflective Ray Tracing",
description=description2,
)
combinedInterface = gr.TabbedInterface([iface1, iface2],
['Non-Reflective Ray Tracing', 'Reflective Ray Tracing']
)
combinedInterface.launch(share=False) |