@@ -14,21 +14,27 @@ function figure_eight_path(A, B, C, D, x0, y0, theta, num_points)
1414 return x_final, y_final
1515end
1616
17- # Example usage:
1817A = 10.0 # width of the figure-eight
1918B = 5.0 # height of the figure-eight
20- C = Observable (1 .0 ) # size of right part of the figure-eight
21- D = Observable (1 .0 ) # asymmetry factor
19+ C = Observable (0 .0 ) # size of right part of the figure-eight
20+ D = Observable (0 .0 ) # asymmetry factor
2221x0 = 0.0 # center x-coordinate
2322y0 = 0.0 # center y-coordinate
2423theta = 0 * π/ 6 # rotation angle in radians
2524num_points = 200
2625
27- # Define the x range
28- x = LinRange (0 , 6 π, 500 )
26+ function figure_eight_y (C, D)
27+ x, y = figure_eight_path (A, B, C, D, x0, y0, theta, num_points)
28+ return y
29+ end
30+
31+ function figure_eight_x (C, D)
32+ x, y = figure_eight_path (A, B, C, D, x0, y0, theta, num_points)
33+ return x
34+ end
2935
30- # Observable for the y values
31- y = @lift ($ C .* sin .( $ D .* x ))
36+ y = @lift ( figure_eight_y ( $ C, $ D))
37+ x = @lift (figure_eight_x ( $ C, $ D ))
3238
3339# Create the figure and axis
3440fig = Figure ()
@@ -40,8 +46,8 @@ lineplot = lines!(ax, x, y)
4046# Create sliders for amplitude and frequency
4147sg = SliderGrid (
4248 fig[2 , 1 ],
43- (label = " C" , range = 0 .0: 0.01 : 2 .0 , startvalue = 1 .0 ),
44- (label = " D" , range = 0.5 : 0.01 : 3 .0 , startvalue = 1 .0 )
49+ (label = " C" , range = - 1 .0: 0.01 : 1 .0 , startvalue = 0 .0 ),
50+ (label = " D" , range = - 1 : 0.01 : 1 .0 , startvalue = 0 .0 )
4551)
4652
4753# Connect sliders to observables
0 commit comments