I found the following example in the README for the Meshing package
using Meshing
using GeometryTypes
using LinearAlgebra: dot, norm
using FileIO
# generate an SDF of a sphere
sdf_sphere = SignedDistanceField(HyperRectangle(Vec(-1,-1,-1.),Vec(2,2,2.))) do v
sqrt(sum(dot(v,v))) - 1 # sphere
end
m = GLNormalMesh(sdf_sphere, MarchingCubes())
save("sphere.ply",m)
I am trying to work out what that SignedDistanceField(...) do ... end
syntax means. It seems that this code samples the function sqrt(sum(dot(v,v))) - 1
at intervals of 0.1, but what Julia syntax is being used to accomplish this?
More specifically, for SignedDistanceField
, how does one change the resolution to something other than 0.1? I looked at the documentation for SignedDistanceField (in the GeometryTypes package), but unfortunately itβs not much help:
A SignedDistanceField is a uniform sampling of an implicit function. The bounds field corresponds to the sampling
space intervals on each axis. The data field represents the value at each point whose exact location can be
rationalized from bounds. The type is parameterized by:
β’ N - The dimensionality of the sampling space.
β’ SpaceT - the type of the space where we will uniformly sample.
β’ FieldT - the type resulting from evaluation of the implicit function.
Note that decoupling the space and field types is useful since geometry can be formulated with integers and distances
can be measured with floating points.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Construct a SignedDistanceField by sampling a function over the bounds at the specified resolution (default = 0.1).
Note that the sampling grid must be regular, so a new HyperRectangle will be generated for the SignedDistanceField
that may have larger maximum bounds than the input HyperRectangle. The default Field type is Float64, but this can be
changed with the fieldT argument.
It mentions that the default resolution but doesnβt mention how to change it.