Advertisement
jukaukor

EllipsinRotaatio.jl

Oct 24th, 2022
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. # Ellipsit origokeskinen ja (4,3)-keskinen
  2. # Origon ympäri ja (4,3)-ympäri rotatoidut ellipsit
  3. # Juhani Kaukoranta 24.10.2022
  4. using Plots # original and rotated ellipse aroung origo
  5. t = range(0, 2pi, length=100); # parametrinen kulma, 100 arvoa
  6. a,b = 3,2 ; # ellipsin puoliakselit
  7. x0,y0 = 4,3 # ellipsin keskipiste
  8. x1,y1 = a * cos.(t) , b * sin.(t); # origokeskinen ellipsi
  9. p1 = plot(x1,y1,xlabel="origokeskinen",title="a=3,b=2");
  10. x2,y2 = a * cos.(t).+ x0 , b * sin.(t) .+ y0; # (x0,y0)-keskinen ellipsi
  11. p2 = plot(x2,y2,xlabel="(4,3)-keskinen",title="non-rotated");
  12. x3,y3 = (x1-y1)/sqrt(2) , (x1+y1)/sqrt(2); # origokeskinen rotated
  13. p3 = plot(x3,y3,xlabel="origokeskinen",title="rotated");
  14. x4,y4 = x2 .- x0, y2 .- y0; # keskipisteestä lasketut etäisyydet
  15. x5,y5 = (x4-y4) / sqrt(2) .+ x0 , (x4+y4)/sqrt(2) .+ y0; # rotatoitu (x0,y0)-keskinen ellipsi
  16. p4 = plot(x5,y5,xlabel="(4,3)-keskinen",title="rotated (4,3)");
  17. plot(p1,p2,p3,p4,aspect_ratio=:equal,layout = (1, 4), legend = false)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement