 # Problem with 3d graph

I have a project where I have to show the magnus effect on a flying ball. I created a graph in 3d, unfortunately I don’t know how to change the code to make the graph rotate, I also wanted to add a background, does anyone know how to do it? ``````# data
g = 9.81
m = 0.045
v₀ = 35
α = π / 9
p = 1.2
n = 20
r = 0.02

# calculations
hₘ = ((v₀ * sin(α))^ 2) / (2 * g)
time = (2 * v₀ * sin(α)) / g
range= (v₀ ^ 2 * sin(2 * α)) / g

F = 2 * n * p * v₀ * pi ^ 2 * r ^ 3
hₘ_magnus = ((v₀ * sin(α))^ 2) / (2 * (g - (F / m)))
time_magnus = (2 * v₀ * sin(α)) / (g - (F / m))
range_magnus = (v₀ ^ 2 * sin(2 * α)) / (g - (F / m))

function x(v₀, α)
t -> v₀ * t * cos(α)
end

function y(v₀, α, g)
t -> v₀ * t * sin(α) - (g * t ^ 2) / 2
end
function x_magnus(v₀, α)
t -> v₀ * t * cos(α)
end

function y_magnus(v₀, α, g)
t -> v₀ * t * sin(α) - (g - (F / m))*(t ^ 2)/2
end

function z_magnus(v₀, α, g)
t -> v₀ * t * sin(α) - (g - (F / m))*(t ^ 2)/2
end

function z(v₀, α, g)
t -> v₀ * t * sin(α) - g * (t ^ 2)/2
end

a = @animate for i in LinRange(0, time_magnus, 500)
plot(x_magnus(v₀, α), y_magnus(v₀, α, g), z_magnus(v₀, α, g), 0, i,
xlabel = "distance [m]",
ylabel = "widht [m]",
zlabel = "height [m]",
xlims = (0, range_magnus),
zlims = (0, hₘ_magnus),
legend =:none,
title = "motion path")

plot!(x(v₀, α), y(v₀, α, g), z(v₀, α, g), 0, i,
label = "motion path without magnus effect",
xlims = (0, range_magnus),
ylims =(0,  hₘ_magnus),
zlims = (0, hₘ_magnus))
end

gif(a, "throw.gif", fps=30)
``````
1 Like