Skip to content

Commit 04c259f

Browse files
committed
Add screenshot
1 parent df27ad3 commit 04c259f

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ include("examples/create_flightpath.jl")
2929
```
3030
You should see a tilted figure of eight.
3131

32-
The second example uses sliders to modify the parameters B, C and D.
32+
The second example uses sliders to modify 7 parameters:
3333
```julia
3434
include("examples/sliders.jl")
3535
```
36+
![Screenshot](./docs/screenshot.png)
3637

3738

docs/screenshot.png

49.9 KB
Loading

examples/sliders.jl

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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.(2t)
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
2020
D = Observable(0.0) # asymmetry factor
2121
x0 = Observable(0.0) # center x-coordinate
2222
y0 = Observable(25.0) # center y-coordinate
23-
theta = 0*π/6 # rotation angle in radians
23+
theta = Observable(0.0) # rotation angle in degrees
2424
num_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
2929
end
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
3434
end
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
4040
fig = 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
8384
end
8485

86+
on(sg.sliders[7].value) do val
87+
theta[] = val
88+
end
89+
90+
8591

8692
fig

0 commit comments

Comments
 (0)