When the method sample_sdf_near_surface(..) is called, the mesh is first scaled to fit into a unit sphere. The scaling ratio is not fixed, as it depends on the object geometry - which means that different objects are scaled differently. While in the virtual domain this is not a problem, as we can extract geometry information from the simulator, a geometry-dependent scaling ratio is a problem in the real world, where we cannot extract geometry information from the object easily. Therefore, it is essential to have a way to keep the scaling ratio fixed for all the objects in our dataset. Moreover, having control over the scaling ratio could be beneficial in the virtual domain as well.
Changes
This PR adds two parameters to the methods sample_sdf_near_surface(..) and scale_to_unit_sphere(..) :
auto_scaling: when True, the mesh is automatically scaled to fit into a unit sphere. Thus, nothing changes from the current repository. When False, the mesh is scaled according to the parameter scale_ratio.
scale_ratio: this parameter is used to scale the original mesh when the method scale_to_unit_sphere(..) is called. This parameter allows to have control over the scaling procedure.
Example
# sample from mesh_1 and mesh_2, keeping the ratio between the original and resulting mesh fixed at 1.3
samples_1 = mesh_to_sdf.sample_sdf_near_surface(mesh_1, auto_scaling=False, scale_ratio = 1.3)[0]
samples_2 = mesh_to_sdf.sample_sdf_near_surface(mesh_2, auto_scaling=False, scale_ratio = 1.3)[0]
# plot the samples
fig = plotly.graph_objects.Figure(
[ go.Scatter3d(
x=samples_1[:, 0], y=samples_1[:, 1], z=samples_1[:, 2],
mode='markers', marker=dict(size=1, color='darkblue') ),
go.Scatter3d(
x=samples_2[:, 0], y=samples_2[:, 1], z=samples_2[:, 2],
mode='markers', marker=dict(size=1, color='orange') )
]
)
fig.show()
Both objects have been scaled by the same ratio, therefore we can use the DeepSDF method in downstream tasks in the real world.
I hope this makes sense, I am happy answer any questions you may have about this PR.
Problem statement
When the method
sample_sdf_near_surface(..)
is called, the mesh is first scaled to fit into a unit sphere. The scaling ratio is not fixed, as it depends on the object geometry - which means that different objects are scaled differently. While in the virtual domain this is not a problem, as we can extract geometry information from the simulator, a geometry-dependent scaling ratio is a problem in the real world, where we cannot extract geometry information from the object easily. Therefore, it is essential to have a way to keep the scaling ratio fixed for all the objects in our dataset. Moreover, having control over the scaling ratio could be beneficial in the virtual domain as well.Changes
This PR adds two parameters to the methods
sample_sdf_near_surface(..)
andscale_to_unit_sphere(..)
:auto_scaling
: whenTrue
, the mesh is automatically scaled to fit into a unit sphere. Thus, nothing changes from the current repository. WhenFalse
, the mesh is scaled according to the parameterscale_ratio
.scale_ratio
: this parameter is used to scale the original mesh when the methodscale_to_unit_sphere(..)
is called. This parameter allows to have control over the scaling procedure.Example
Both objects have been scaled by the same ratio, therefore we can use the DeepSDF method in downstream tasks in the real world.
I hope this makes sense, I am happy answer any questions you may have about this PR.