skrobot.sdf.SignedDistanceFunction¶
- class skrobot.sdf.SignedDistanceFunction(origin, coords=None, use_abs=False)[source]¶
A base class for signed distance functions (SDFs).
Suffixes _obj and _sdf (e.g. in points_sdf) indicate that points are expressed in the sdf’s object coordinate (self.coords) and sdf-specfic coordinate respectively. Each SDF performs the signed-distance computation in its own sdf-specific coordinate. For example, the origin of GridSDF’s sdf-specific coordinate is the tip of the precomputed-gridded-box.
Usually, a child class implements the computation in the sdf-specific coordinates and SignedDistanceFunction wraps them so that the user can pass and get points and values expressed in an object coordinate. Thus, it is less likely that a user directly calls a method in a child class.
Methods
- __call__(points_obj)[source]¶
Compute signed distances of input points to the implicit surface.
- Parameters:
points_obj (numpy.ndarray[float](n_point, 3)) – 2 dim point array w.r.t. object coordinate.
- Returns:
signed_distances – 1 dim (n_point,) array of signed distance.
- Return type:
- on_surface(points_obj)[source]¶
Check if points are on the surface.
- Parameters:
points_obj (numpy.ndarray[float](n_point, 3)) – 2 dim point array w.r.t. an object coordinate.
- Returns:
logicals (numpy.ndarray[bool](n_point,)) – boolean vector of the on-surface predicate for points_obj.
sd_vals (numpy.ndarray[float](n_point,)) – signed distances corresponding to logicals.
- surface_points(n_sample=1000)[source]¶
Sample points from the implicit surface of the sdf.
- Parameters:
n_sample (int) – number of sample points.
- Returns:
points_obj (numpy.ndarray[float](n_point, 3)) – sampled points w.r.t object coordinate.
dists (numpy.ndarray[float](n_point,)) – signed distances corresponding to points_obj.
- __eq__(value, /)¶
Return self==value.
- __ne__(value, /)¶
Return self!=value.
- __lt__(value, /)¶
Return self<value.
- __le__(value, /)¶
Return self<=value.
- __gt__(value, /)¶
Return self>value.
- __ge__(value, /)¶
Return self>=value.