Skip to content

Instantly share code, notes, and snippets.

@SimonDanisch
Created December 2, 2019 21:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SimonDanisch/40a2e27bf1757c212a590ae36bc4fbb1 to your computer and use it in GitHub Desktop.
Save SimonDanisch/40a2e27bf1757c212a590ae36bc4fbb1 to your computer and use it in GitHub Desktop.
mutating poly in place
using Makie, GeometryTypes
points = decompose(Point2f0, Circle(Point2f0(0), 1f0))
points[1] ≈ points[end] # first and last are the same, so they will get removed
# lets remove it ourselves, so that we can more easily map over it!
pop!(points)
mesh = GLNormalMesh(points)
# Visualize poly
scene = Makie.mesh(mesh, shading = false)
mplot = scene[end]
# Points get converted to 3d + get one end point
new_points = map(x->Point3f0(x[1] + rand() * 0.1, x[2] + rand() * 0.1, 0.0), points)
# update mesh inplace
mesh.vertices[:] = new_points
# Update plot with new mesh
mplot[1] = mesh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment