https://hrubos.tech/blogy/content/images/20260204094631-vychylena_poloska4.gif Pozeral som si vlnenie akoby morské na x.com á rozmýšľal som ako nasimulovať vlnenie mliečnej dráhy vo vesmíre a napadla ma jednoduchá vec, a to vychýlená polo os automobilu. Tá bude základ pre naše vlny a vychýlenia na morskom povrchu v oceáne vesmíru ^^^
using Pkg
Pkg.add("Plots") # Raz
using Plots
gr()
# Parametre
wheel_radius = 0.9
axle_length = 1.2
steer_angle = π/6 # 30 stupňov
wheel_rotation = 0.0
position = [0.0, -2.0]
history = []
# Graf
p = plot(xlabel="X (m)", ylabel="Y (m)", title="Prečo mliečna cesta nie je rovina, ale vlnky",
xlims=(-1,8), ylims=(-2,2), aspect_ratio=:equal, size=(800,600), legend=false )
anim = @animate for i in 1:80
global position, wheel_rotation, history
# Pohyb
step = 0.08
position[1] += step * cos(steer_angle/2)
position[2] += step * sin(steer_angle/2)
wheel_rotation += step / wheel_radius
push!(history, copy(position))
if length(history) > 30
popfirst!(history)
end
# Vymaž predchádzajúce
empty!(p.series_list)
# Stopa
if !isempty(history)
xs = [h[1] for h in history]
ys = [h[2] for h in history]
plot!(p, xs, ys, color="gray", linewidth=3, label="Stopa", alpha=0.7, legend=false )
end
# Karoséria
car_x = position[1] + axle_length/2 * cos(steer_angle/2)
car_y = position[2] + axle_length/2 * sin(steer_angle/2)
plot!(p, [position[1], car_x], [position[2], car_y],
color="blue", linewidth=8, label="Karoséria", legend=false )
# Poloska
axle_end_x = position[1] + axle_length * cos(steer_angle)
axle_end_y = position[2] + axle_length * sin(steer_angle)
plot!(p, [position[1], axle_end_x], [position[2], axle_end_y],
color="black", linewidth=6, label="Poloska", legend=false )
# Kolo
θ = range(0, 2π, length=50)
wheel_center_x = axle_end_x
wheel_center_y = axle_end_y
wheel_x = wheel_center_x .+ wheel_radius * cos.(θ .+ steer_angle)
wheel_y = wheel_center_y .+ wheel_radius * sin.(θ .+ steer_angle)
plot!(p, wheel_x, wheel_y, color="red", linewidth=3, label="Pneumatika", legend=false )
# Rotujúce lúče
spoke_angles = [0, π/2, π, 3π/2] .+ wheel_rotation
for spoke in spoke_angles
spoke_end_x = wheel_center_x + wheel_radius * cos(spoke)
spoke_end_y = wheel_center_y + wheel_radius * sin(spoke)
plot!(p, [wheel_center_x, spoke_end_x],
[wheel_center_y, spoke_end_y],
color="darkred", linewidth=4, alpha=0.8, legend=false )
end
# **OPRAVENÁ ŠÍPKA** - namiesto quiver použijeme arrow
arrow_length = 0.25
arrow_x = [axle_end_x, axle_end_x + arrow_length * cos(steer_angle)]
arrow_y = [axle_end_y, axle_end_y + arrow_length * sin(steer_angle)]
plot!(p, arrow_x, arrow_y, color="green", linewidth=3,
arrow=true, label="Smer pohybu", legend=false )
end
gif(anim, "vychylena_poloska4.gif", fps=15)

Comments “Prečo sa mliečna cesta vlní á čo má spoločné s vychýlenou polo osou auta? Gravitácia predsa vytvára kyvadlo:”