Skip to content

Commit a038402

Browse files
committed
Add param C and D
1 parent aee3bd9 commit a038402

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

examples/create_flightpath.jl

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
using ControlPlots
22

3-
function figure_eight_path(A, B, x0, y0, theta, num_points)
3+
function figure_eight_path(A, B, C, D, x0, y0, theta, num_points)
44
t = range(0, 2π, length=num_points)
5-
x = A .* sin.(t)
6-
y = B .* sin.(t) .* cos.(t)
5+
x = A * sin.(t)
6+
y = B * sin.(t) .* cos.(t) .+ C .* cos.(t) .+ D .* cos.(2t)
77
# Apply rotation
8-
x_rot = x .* cos(theta) .- y .* sin(theta)
8+
x_rot = x .* cos(theta) .- y .* sin(theta)
99
y_rot = x .* sin(theta) .+ y .* cos(theta)
10+
y_rot = y_rot / (maximum(y_rot)/(B/2))
1011
# Apply translation
1112
x_final = x_rot .+ x0
1213
y_final = y_rot .+ y0
@@ -16,12 +17,14 @@ end
1617
# Example usage:
1718
A = 10.0 # width of the figure-eight
1819
B = 5.0 # height of the figure-eight
20+
C = 0.0 # size of right part of the figure-eight
21+
D = -1.0 # asymmetry factor
1922
x0 = 0.0 # center x-coordinate
2023
y0 = 0.0 # center y-coordinate
21-
theta = π/6 # rotation angle in radians
24+
theta = 0*π/6 # rotation angle in radians
2225
num_points = 200
2326

24-
x_path, y_path = figure_eight_path(A, B, x0, y0, theta, num_points)
27+
x_path, y_path = figure_eight_path(A, B, C, D, x0, y0, theta, num_points)
2528

2629
plt.figure("Figure-of-Eight Path")
2730
ax = plt.gca()

0 commit comments

Comments
 (0)