1
0
mirror of https://gitlab.com/lander-team/plots.git synced 2025-06-16 06:56:39 +00:00
Plots/ThrustDef.jl
2021-09-19 20:20:39 -07:00

44 lines
840 B
Julia

using Plots
using Unitful
using UnitfulRecipes
using NumericalIntegration
theme(:juno)
rate = 180u"°/s"
max_deflection = 15u"°"
dt = 0.001u"s"
time = 0u"s":dt:2u"s"
angle = [(t * rate) % max_deflection for t in time]
v = cos.(angle) .* u"N"
h = sin.(angle) .* u"N"
horizontal_impulse = let
vimp = integrate(time, v)
himp = integrate(time, h)
round(himp / (vimp + himp) * 100) |> Int
end
let
plot(time, v, label = "Vertical")
plot!(time, h, label = "Horizontal")
yticks!(0:0.25:1, string.(0:25:100) .* "%")
ylabel!("Percent of Thrust")
xticks!(0:0.5:2, string.(0:0.5:2) .* "s")
xlabel!("Time")
title!(
"Max Deflection: $(max_deflection)\n" *
"Vertical Impulse: $(100-horizontal_impulse)% | Horizontal Impulse: $(horizontal_impulse)%",
)
end
savefig("ThrustDef.png")