Advertisement
jukaukor

ConvexHullEsim.jl

Dec 12th, 2023
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. # Convex Hull esimerkki Julia-kielellä
  2. # Juhani Kaukoranta 12.12.2023
  3. using QHull, Plots
  4. # arvotaan 100 pistettä ,koordinaatistoon 300x300
  5. pisteet = rand(0:300,100,2);
  6. ch = chull(pisteet);
  7. A = ch.points; # pistejoukko
  8. x=A[:,1]; # joukon pisteiden x-koordinaatit
  9. y=A[:,2]; # joukon pisteiden y-koordinaatit
  10. p = scatter(x,y,aspect_ratio=:equal,title="pistejoukko",ms=:5,legend=false);
  11. plot(p) # plotataan pistejoukko
  12. ind = ch.vertices; # convex hull-reunapisteiden järjestysindeksit
  13. preuna = scatter!(x[ind],y[ind],aspect_ratio=:equal,mc=:red,ms=:3,title="reunapisteet pun",legend=:false);
  14. plot!(preuna) # värjää reunapisteet
  15. reunaviiva=plot!(x[ind],y[ind],aspect_ratio=:equal,color=:red,legend=:false);
  16. plot!(reunaviiva)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement