Created
October 10, 2018 12:10
-
-
Save JanisErdmanis/438abfec86040dd06562cb0f8cdc8eb2 to your computer and use it in GitHub Desktop.
A way to draw a mesh with julia.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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