Hello, I’m trying to plot a 3d surface. I’ve used a marching cubes algorithm to generate a tuple of points. When I plot them in scatter() I get the following image, which is what I want and expect.
scatter([a for (a,_,_) in points],[b for (_,b,_) in points], [c for (_,_,c) in points] )
However when I try and use Mesh3d to generate the mesh surface I obtain the following.
mesh3d([a for (a,_,_) in points], [b for (_,b,_) in points], [c for (_,_,c) in points])
And only half of the points appear to be plotted. Is there a reason for this? I’m using Plots with a PlotlyJS backend. The entire setup is running in a pluto notebook, and I can append the code if someone wants to see the whole thing. The MWE is immediately below, along with a .csv version of the points tuple variable beneath it that one should be able to copy and paste!
using Plots
Pkg.add("PlotlyJS")
Pkg.add("QuadGK")
using QuadGK
plotly()
Pkg.add("Meshing")
using Meshing
function unknotintegralfunction(a,b,c,t)
1/(sqrt(((a.-cos.(t))^2).+((b.-sin.(t))^2).+c^2)) #using .math means element wise
end
function unknotpotential(a,b,c,A)
ans, err = quadgk(t->unknotintegralfunction(a,b,c,t),0,(2*pi),order=quadorder)
# we'll use the default errors to start
A[floor(Int,(10*a+21)),floor(Int,(10*b+21)),floor(Int,(10*c+21))]=ans
return [a,b,c,ans,err]
end
inflateunknot(f,N,p,A)=[f(x,y,z,A) for x in -1*N:p:N, y in -1*N:p:N, z in -1*N:p:N if z ≠ 0 || (x*x +y*y)≠ 1 ]
A = zeros(41,41,41)
ans = inflateunknot(unknotpotential,2,0.1,A)
c=A[20,20,20]+0.5
points,surfaces = isosurface(A,MarchingCubes(iso=c), origin = Vec(1,1,1), widths = Vec(4.0,4.0,4.0))
scatter([a for (a,_,_) in points],[b for (_,b,_) in points], [c for (_,_,c) in points] )
mesh3d([a for (a,_,_) in points], [b for (_,b,_) in points], [c for (_,_,c) in points])