Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Paraabeli y-y0 =a(x-x0)² rotaatio symmetria-akselinsa suhteen
- # Juhani Kaukoranta 25.10.2022
- using Plots # paraabeli kierto symmetria-akselin suhteen
- function paraabeli(a,x0,y0,θ)
- # a=kerroim,huippu=(x0,y0),kulma= θ
- deg=θ
- huippu ="huippu = "*"("*"$x0"*","*"$y0"*")"
- θ = pi*θ/180 ; # kiertokulma radiaaneiksi
- x = range(-1,5,length = 50);
- y = y0 .+ a .* (x .- x0).^2 ; # pystyparaabeli
- p1 = plot(x,y,xlabel="original a = $a",title=huippu);
- x1 = x .- x0 ; # rotaatiota varten
- y1 = y .- y0 ; # paraabeli origoon
- x2 = x1 .* cos(θ) .- y1 .* sin(θ) .+ x0 ; # rotatoitu x
- y2 = x1 .* sin(θ) .+ y1 .* cos(θ) .+ y0; # rotatoitu y
- p2 = plot(x2,y2,xlabel="rotatoitu $deg"*"°", title=huippu);
- plot(p1,p2,aspect_ratio=:equal,layout = (1, 2), legend = false);
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement