Created
August 5, 2025 17:36
-
-
Save louismeunier/67ad6e589ae31198ebcdffc66d65fbcf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| begin | |
| using Plots | |
| r = 10 | |
| x(t) = r*(1+cos(t)) | |
| y(t) = r*sin(t) | |
| z(t) = 2*r*sin(0.5*t) | |
| R(t) = [x(t), y(t), z(t)] | |
| t_range = range(-2π, 2π, length=100) | |
| tnb_anim = @animate for t_at in t_range | |
| plot3d(x.(t_range), y.(t_range), z.(t_range), legend=false, aspect_ratio=:equal, | |
| xlims=(-5,25), | |
| ylims=(-11,11), | |
| zlims=(-21,21), | |
| camera=(30, 15), | |
| color=RGBA(241/255,90/255,34/255,0.5), | |
| linewidth=5, | |
| ) | |
| plot3d!([R(t_at)[1]], [R(t_at)[2]], [R(t_at)[3]], color=:black, marker=:circle, markersize=3, label="t = $t_at") | |
| # T | |
| T_hat = R'(t_at)/norm(R'(t_at)) | |
| arrow!(R(t_at), 2.5*T_hat, color=:red, label="T", linewidth=3, aspect_ratio=:equal) | |
| # N | |
| N_hat = cross(R'(t_at), cross(R''(t_at), R'(t_at)))/(norm(R'(t_at))*norm(cross(R''(t_at), R'(t_at)))) | |
| arrow!(R(t_at), 2.5*N_hat, color=:green, label="N", linewidth=3, aspect_ratio=:equal) | |
| # B | |
| B_hat = cross(T_hat,N_hat) | |
| arrow!(R(t_at), 2.5*B_hat, color=:blue, label="B", linewidth=3, aspect_ratio=:equal) | |
| end | |
| gif(tnb_anim, "tnb.gif", fps=20) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment