@@ -14,7 +14,7 @@ function figure_eight_path(A, B, C, D, x0, y0, theta, num_points)
1414 return x_final, y_final
1515end
1616
17- A = 20.0 # width of the figure-eight
17+ A = Observable ( 20.0 ) # width of the figure-eight
1818B = Observable (10.0 ) # height of the figure-eight
1919C = Observable (0.0 ) # size of right part of the figure-eight
2020D = Observable (0.0 ) # asymmetry factor
@@ -23,18 +23,18 @@ y0 = 25.0 # center y-coordinate
2323theta = 0 * π/ 6 # rotation angle in radians
2424num_points = 200
2525
26- function figure_eight_y (B, C, D)
26+ function figure_eight_y (A, B, C, D)
2727 x, y = figure_eight_path (A, B, C, D, x0, y0, theta, num_points)
2828 return y
2929end
3030
31- function figure_eight_x (B, C, D)
31+ function figure_eight_x (A, B, C, D)
3232 x, y = figure_eight_path (A, B, C, D, x0, y0, theta, num_points)
3333 return x
3434end
3535
36- y = @lift (figure_eight_y ($ B, $ C, $ D))
37- x = @lift (figure_eight_x ($ B, $ C, $ D))
36+ y = @lift (figure_eight_y ($ A, $ B, $ C, $ D))
37+ x = @lift (figure_eight_x ($ A, $ B, $ C, $ D))
3838
3939# Create the figure and axis
4040fig = Figure ()
@@ -44,29 +44,32 @@ ax = Axis(fig[1, 1], xlabel = "azimuth [°]", ylabel = "elevation [°]",
4444# Plot the sine wave
4545lineplot = lines! (ax, x, y)
4646ylims! (ax, 10 , 40 )
47+ xlims! (ax, - 30 , 30 )
4748
4849# Create sliders for amplitude and frequency
4950sg = SliderGrid (
5051 fig[2 , 1 ],
52+ (label = " A" , range = 10 : 0.01 : 30.0 , startvalue = 20.0 ),
5153 (label = " B" , range = 5 : 0.01 : 20.0 , startvalue = 10.0 ),
5254 (label = " C" , range = - 2.0 : 0.01 : 2.0 , startvalue = 0.0 ),
5355 (label = " D" , range = - 3 : 0.01 : 3.0 , startvalue = 0.0 )
5456)
5557
5658# Connect sliders to observables
5759on (sg. sliders[1 ]. value) do val
58- B [] = val
60+ A [] = val
5961end
6062
6163on (sg. sliders[2 ]. value) do val
62- C [] = val
64+ B [] = val
6365end
6466
6567on (sg. sliders[3 ]. value) do val
66- D [] = val
68+ C [] = val
6769end
6870
69- # Optional: keep axis limits stable if amplitude changes a lot
70- # ax.ylims = (-2, 2) # or use autolimits! if you prefer dynamic limits
71+ on (sg. sliders[4 ]. value) do val
72+ D[] = val
73+ end
7174
7275fig
0 commit comments