Collision Mesh¶
- class ipctk.CollisionMesh¶
Bases:
pybind11_object
Public Data Attributes:
Get the number of vertices in the collision mesh.
Get the number of codimensional vertices in the collision mesh.
Get the number of codimensional edges in the collision mesh.
Get the number of edges in the collision mesh.
Get the number of faces in the collision mesh.
Get the dimension of the mesh.
Get the number of degrees of freedom in the collision mesh.
Get the number of vertices in the full mesh.
Get the number of degrees of freedom in the full mesh.
Get the vertices of the collision mesh at rest (#V × dim).
Get the indices of codimensional vertices of the collision mesh (#CV x 1).
Get the indices of codimensional edges of the collision mesh (#CE x 1).
Get the edges of the collision mesh (#E × 2).
Get the faces of the collision mesh (#F × 3).
Get the mapping from faces to edges of the collision mesh (#F × 3).
Get the vertex-vertex adjacency matrix.
Get the vertex-edge adjacency matrix.
Get the edge-vertex adjacency matrix.
Get the barycentric area of the vertices.
A function that takes two vertex IDs and returns true if the vertices (and faces or edges containing the vertices) can collide.
Public Methods:
__init__
(*args, **kwargs)Overloaded function.
build_from_full_mesh
(full_rest_positions, edges)Helper function that automatically builds include_vertex using construct_is_on_surface.
init_adjacencies
(self)Initialize vertex-vertex and edge-vertex adjacencies.
init_area_jacobians
(self)Initialize vertex and edge areas.
vertices
(self, full_positions)Compute the vertex positions from the positions of the full mesh.
displace_vertices
(self, full_displacements)Compute the vertex positions from vertex displacements on the full mesh.
map_displacements
(self, full_displacements)Map vertex displacements on the full mesh to vertex displacements on the collision mesh.
to_full_vertex_id
(self, id)Map a vertex ID to the corresponding vertex ID in the full mesh.
to_full_dof
(*args, **kwargs)Overloaded function.
Determine if the adjacencies have been initialized by calling init_adjacencies().
is_vertex_on_boundary
(self, vi)Is a vertex on the boundary of the collision mesh?
vertex_area
(self, vi)Get the barycentric area of a vertex.
vertex_area_gradient
(self, vi)Get the gradient of the barycentric area of a vertex wrt the rest positions of all points.
edge_area
(self, ei)Get the barycentric area of an edge.
edge_areas
(self)Get the barycentric area of the edges.
edge_area_gradient
(self, ei)Get the gradient of the barycentric area of an edge wrt the rest positions of all points.
Determine if the area Jacobians have been initialized by calling init_area_jacobians().
construct_is_on_surface
(num_vertices, edges)Construct a vector of bools indicating whether each vertex is on the surface.
construct_faces_to_edges
(faces, edges)Construct a matrix that maps from the faces' edges to rows in the edges matrix.
Inherited from
pybind11_object
-
__annotations__ =
{}
¶
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: ipctk.CollisionMesh, rest_positions: numpy.ndarray[numpy.float64[m, n]], edges: numpy.ndarray[numpy.int32[m, n]] = array([], shape=(0, 0), dtype=int32), faces: numpy.ndarray[numpy.int32[m, n]] = array([], shape=(0, 0), dtype=int32), displacement_map: scipy.sparse.csc_matrix[numpy.float64] = <Compressed Sparse Column sparse matrix of dtype ‘float64’ with 0 stored elements and shape (0, 0)>) -> None
Construct a new Collision Mesh object directly from the collision mesh vertices.
- Parameters:
rest_positions: The vertices of the collision mesh at rest (#V × dim). edges: The edges of the collision mesh (#E × 2). faces: The faces of the collision mesh (#F × 3). displacement_map: The displacement mapping from displacements on the full mesh to the collision mesh.
__init__(self: ipctk.CollisionMesh, include_vertex: list[bool], full_rest_positions: numpy.ndarray[numpy.float64[m, n]], edges: numpy.ndarray[numpy.int32[m, n]] = array([], shape=(0, 0), dtype=int32), faces: numpy.ndarray[numpy.int32[m, n]] = array([], shape=(0, 0), dtype=int32), displacement_map: scipy.sparse.csc_matrix[numpy.float64] = <Compressed Sparse Column sparse matrix of dtype ‘float64’ with 0 stored elements and shape (0, 0)>) -> None
Construct a new Collision Mesh object from a full mesh vertices.
- Parameters:
include_vertex: Vector of bools indicating whether each vertex should be included in the collision mesh. full_rest_positions: The vertices of the full mesh at rest (#V × dim). edges: The edges of the collision mesh indexed into the full mesh vertices (#E × 2). faces: The faces of the collision mesh indexed into the full mesh vertices (#F × 3). displacement_map: The displacement mapping from displacements on the full mesh to the collision mesh.
-
__module__ =
'ipctk'
¶
- are_adjacencies_initialized(self) bool ¶
Determine if the adjacencies have been initialized by calling init_adjacencies().
- are_area_jacobians_initialized(self) bool ¶
Determine if the area Jacobians have been initialized by calling init_area_jacobians().
-
static build_from_full_mesh(full_rest_positions: numpy.ndarray[numpy.float64[m, n]], edges: numpy.ndarray[numpy.int32[m, n]], faces: numpy.ndarray[numpy.int32[m, n]] =
array([], shape=(0, 0), dtype=int32)
) ipctk.CollisionMesh ¶ Helper function that automatically builds include_vertex using construct_is_on_surface.
- property can_collide : collections.abc.Callable[[int, int], bool]¶
A function that takes two vertex IDs and returns true if the vertices (and faces or edges containing the vertices) can collide.
By default all primitives can collide with all other primitives.
- property codim_edges : numpy.ndarray[numpy.int32[m, 1]]¶
Get the indices of codimensional edges of the collision mesh (#CE x 1).
- property codim_vertices : numpy.ndarray[numpy.int32[m, 1]]¶
Get the indices of codimensional vertices of the collision mesh (#CV x 1).
- static construct_faces_to_edges(faces: numpy.ndarray[numpy.int32[m, n]], edges: numpy.ndarray[numpy.int32[m, n]]) numpy.ndarray[numpy.int32[m, n]] ¶
Construct a matrix that maps from the faces’ edges to rows in the edges matrix.
-
static construct_is_on_surface(num_vertices: int, edges: numpy.ndarray[numpy.int32[m, n]], codim_vertices: numpy.ndarray[numpy.int32[m, 1]] =
array([], dtype=int32)
) list[bool] ¶ Construct a vector of bools indicating whether each vertex is on the surface.
- property dim : int¶
Get the dimension of the mesh.
- displace_vertices(self, full_displacements: numpy.ndarray[numpy.float64[m, n]]) numpy.ndarray[numpy.float64[m, n]] ¶
Compute the vertex positions from vertex displacements on the full mesh.
- edge_area_gradient(self, ei: int) scipy.sparse.csc_matrix[numpy.float64] ¶
Get the gradient of the barycentric area of an edge wrt the rest positions of all points.
- edge_areas(self) numpy.ndarray[numpy.float64[m, 1]] ¶
Get the barycentric area of the edges.
- property edge_vertex_adjacencies : list[tsl::robin_set<int, absl::lts_20230125::hash_internal::Hash<int>, std::equal_to<int>, std::allocator<int>, false, tsl::rh::power_of_two_growth_policy<2ul> >]¶
Get the edge-vertex adjacency matrix.
- property edges : numpy.ndarray[numpy.int32[m, n]]¶
Get the edges of the collision mesh (#E × 2).
- property faces : numpy.ndarray[numpy.int32[m, n]]¶
Get the faces of the collision mesh (#F × 3).
- property faces_to_edges : numpy.ndarray[numpy.int32[m, n]]¶
Get the mapping from faces to edges of the collision mesh (#F × 3).
- property full_ndof : int¶
Get the number of degrees of freedom in the full mesh.
- property full_num_vertices : int¶
Get the number of vertices in the full mesh.
- init_adjacencies(self) None ¶
Initialize vertex-vertex and edge-vertex adjacencies.
- init_area_jacobians(self) None ¶
Initialize vertex and edge areas.
- map_displacements(self, full_displacements: numpy.ndarray[numpy.float64[m, n]]) numpy.ndarray[numpy.float64[m, n]] ¶
Map vertex displacements on the full mesh to vertex displacements on the collision mesh.
- property ndof : int¶
Get the number of degrees of freedom in the collision mesh.
- property num_codim_edges : int¶
Get the number of codimensional edges in the collision mesh.
- property num_codim_vertices : int¶
Get the number of codimensional vertices in the collision mesh.
- property num_edges : int¶
Get the number of edges in the collision mesh.
- property num_faces : int¶
Get the number of faces in the collision mesh.
- property num_vertices : int¶
Get the number of vertices in the collision mesh.
- property rest_positions : numpy.ndarray[numpy.float64[m, n]]¶
Get the vertices of the collision mesh at rest (#V × dim).
- to_full_dof(*args, **kwargs)¶
Overloaded function.
to_full_dof(self: ipctk.CollisionMesh, x: numpy.ndarray[numpy.float64[m, 1]]) -> numpy.ndarray[numpy.float64[m, 1]]
Map a vector quantity on the collision mesh to the full mesh.
This is useful for mapping gradients from the collision mesh to the full mesh (i.e., applies the chain-rule).
- Parameters:
x: Vector quantity on the collision mesh with size equal to ndof().
- Returns:
Vector quantity on the full mesh with size equal to full_ndof().
to_full_dof(self: ipctk.CollisionMesh, X: scipy.sparse.csc_matrix[numpy.float64]) -> scipy.sparse.csc_matrix[numpy.float64]
Map a matrix quantity on the collision mesh to the full mesh.
This is useful for mapping Hessians from the collision mesh to the full mesh (i.e., applies the chain-rule).
- Parameters:
X: Matrix quantity on the collision mesh with size equal to ndof() × ndof().
- Returns:
Matrix quantity on the full mesh with size equal to full_ndof() × full_ndof().
- to_full_vertex_id(self, id: int) int ¶
Map a vertex ID to the corresponding vertex ID in the full mesh.
- vertex_area_gradient(self, vi: int) scipy.sparse.csc_matrix[numpy.float64] ¶
Get the gradient of the barycentric area of a vertex wrt the rest positions of all points.
- property vertex_areas : numpy.ndarray[numpy.float64[m, 1]]¶
Get the barycentric area of the vertices.
- property vertex_edge_adjacencies : list[tsl::robin_set<int, absl::lts_20230125::hash_internal::Hash<int>, std::equal_to<int>, std::allocator<int>, false, tsl::rh::power_of_two_growth_policy<2ul> >]¶
Get the vertex-edge adjacency matrix.
- property vertex_vertex_adjacencies : list[tsl::robin_set<int, absl::lts_20230125::hash_internal::Hash<int>, std::equal_to<int>, std::allocator<int>, false, tsl::rh::power_of_two_growth_policy<2ul> >]¶
Get the vertex-vertex adjacency matrix.
- vertices(self, full_positions: numpy.ndarray[numpy.float64[m, n]]) numpy.ndarray[numpy.float64[m, n]] ¶
Compute the vertex positions from the positions of the full mesh.
-
__annotations__ =