@@ -4,10 +4,10 @@ function figure_eight_path(A, B, C, D, x0, y0, theta, num_points)
44 t = range (0 , 2 π, length= num_points)
55 x = A * sin .(t)
66 y = B * sin .(t) .* cos .(t) .+ C .* cos .(t) .+ D .* cos .(2 t)
7+ y = y / (maximum (y)/ (B/ 2 ))
78 # Apply rotation
89 x_rot = x .* cos (theta) .- y .* sin (theta)
910 y_rot = x .* sin (theta) .+ y .* cos (theta)
10- y_rot = y_rot / (maximum (y_rot)/ (B/ 2 ))
1111 # Apply translation
1212 x_final = x_rot .+ x0
1313 y_final = y_rot .+ y0
@@ -20,21 +20,21 @@ C = Observable(0.0) # size of right part of the figure-eight
2020D = Observable (0.0 ) # asymmetry factor
2121x0 = Observable (0.0 ) # center x-coordinate
2222y0 = Observable (25.0 ) # center y-coordinate
23- theta = 0 * π / 6 # rotation angle in radians
23+ theta = Observable ( 0.0 ) # rotation angle in degrees
2424num_points = 200
2525
26- function figure_eight_y (A, B, C, D, x0, y0)
27- x, y = figure_eight_path (A, B, C, D, x0, y0, theta, num_points)
26+ function figure_eight_y (A, B, C, D, x0, y0, theta )
27+ x, y = figure_eight_path (A, B, C, D, x0, y0, deg2rad ( theta) , num_points)
2828 return y
2929end
3030
31- function figure_eight_x (A, B, C, D, x0, y0)
32- x, y = figure_eight_path (A, B, C, D, x0, y0, theta, num_points)
31+ function figure_eight_x (A, B, C, D, x0, y0, theta )
32+ x, y = figure_eight_path (A, B, C, D, x0, y0, deg2rad ( theta) , num_points)
3333 return x
3434end
3535
36- y = @lift (figure_eight_y ($ A, $ B, $ C, $ D, $ x0, $ y0))
37- x = @lift (figure_eight_x ($ A, $ B, $ C, $ D, $ x0, $ y0))
36+ y = @lift (figure_eight_y ($ A, $ B, $ C, $ D, $ x0, $ y0, $ theta ))
37+ x = @lift (figure_eight_x ($ A, $ B, $ C, $ D, $ x0, $ y0, $ theta ))
3838
3939# Create the figure and axis
4040fig = Figure ()
@@ -54,7 +54,8 @@ sg = SliderGrid(
5454 (label = " C (right_size)" , range = - 2.0 : 0.01 : 2.0 , startvalue = 0.0 ),
5555 (label = " D (asymmetry)" , range = - 3 : 0.01 : 3.0 , startvalue = 0.0 ),
5656 (label = " x0" , range = - 10 : 0.01 : 10.0 , startvalue = 0.0 ),
57- (label = " y0" , range = 20 : 0.01 : 30.0 , startvalue = 25.0 )
57+ (label = " y0" , range = 20 : 0.01 : 30.0 , startvalue = 25.0 ),
58+ (label = " theta [°]" , range = - 90 : 0.01 : 90 , startvalue = 0.0 )
5859)
5960
6061# Connect sliders to observables
@@ -82,5 +83,10 @@ on(sg.sliders[6].value) do val
8283 y0[] = val
8384end
8485
86+ on (sg. sliders[7 ]. value) do val
87+ theta[] = val
88+ end
89+
90+
8591
8692fig
0 commit comments