Skip to content

Instantly share code, notes, and snippets.

@JanisErdmanis
Created October 10, 2018 12:10
Show Gist options
  • Save JanisErdmanis/438abfec86040dd06562cb0f8cdc8eb2 to your computer and use it in GitHub Desktop.
Save JanisErdmanis/438abfec86040dd06562cb0f8cdc8eb2 to your computer and use it in GitHub Desktop.
A way to draw a mesh with julia.
using Meshing
using LinearAlgebra
using GeometryTypes
import Makie: wireframe
wireframe(v,f) = wireframe(HomogenousMesh(v,f))
wireframe(v,t::Array{Int64,2}) = wireframe(v,[Face(t[i,:]...) for i in 1:size(t,1)])
sdf = SignedDistanceField(HyperRectangle(Vec(-1,-1,-1.),Vec(2,2,2.))) do v
sqrt(sum(dot(v,v))) - 1 # sphere
end
m = marching_cubes(sdf)
f,v = faces(m), vertices(m)
wireframe(v,f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment