Advertisement
jukaukor

parabola_rotation.jl

Oct 25th, 2022
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. # Paraabeli y-y0 =a(x-x0)² rotaatio symmetria-akselinsa suhteen
  2. # Juhani Kaukoranta 25.10.2022
  3. using Plots # paraabeli kierto symmetria-akselin suhteen
  4. function paraabeli(a,x0,y0,θ)
  5. # a=kerroim,huippu=(x0,y0),kulma= θ
  6. deg=θ
  7. huippu ="huippu = "*"("*"$x0"*","*"$y0"*")"
  8. θ = pi*θ/180 ; # kiertokulma radiaaneiksi
  9. x = range(-1,5,length = 50);
  10. y = y0 .+ a .* (x .- x0).^2 ; # pystyparaabeli
  11. p1 = plot(x,y,xlabel="original a = $a",title=huippu);
  12. x1 = x .- x0 ; # rotaatiota varten
  13. y1 = y .- y0 ; # paraabeli origoon
  14. x2 = x1 .* cos(θ) .- y1 .* sin(θ) .+ x0 ; # rotatoitu x
  15. y2 = x1 .* sin(θ) .+ y1 .* cos(θ) .+ y0; # rotatoitu y
  16. p2 = plot(x2,y2,xlabel="rotatoitu $deg"*"°", title=huippu);
  17. plot(p1,p2,aspect_ratio=:equal,layout = (1, 2), legend = false);
  18. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement