Normal Collisions¶
Normal Collisions¶
- class NormalCollisions;¶
Public Types¶
- enum class CollisionSetType : uint8_t;¶
How to construct the collision set.
This choice is described in the “Offset Geometric Contact” [Chen et al. 2025] using the notation: \(\mathcal{F}\) and \(\mathcal{E}\) for the face and edge sets, respectively.
Values:
- enumerator IPC;¶
IPC set type, which uses the original formulation described in [Li et al. 2020].
- enumerator IMPROVED_MAX_APPROX;¶
Improved max approximation set type, which uses the improved max approximation formulation described in [Li et al. 2023].
- enumerator OGC;¶
Offset Geometric Contact set type, which uses the formulation described in [Chen et al. 2025].
- using value_type = NormalCollision;¶
The type of the collisions.
Public Functions¶
- NormalCollisions() = default;¶
-
void build(const CollisionMesh& mesh,
Eigen::ConstRef<Eigen::MatrixXd> vertices, const double dhat,
const double dmin = 0, BroadPhase* broad_phase = nullptr);¶ Initialize the set of collisions used to compute the barrier potential.
- Parameters:¶
- const CollisionMesh &mesh¶
The collision mesh.
- Eigen::ConstRef<Eigen::MatrixXd> vertices¶
Vertices of the collision mesh.
- const double dhat¶
The activation distance of the barrier.
- const double dmin = 0¶
Minimum distance.
- BroadPhase *broad_phase = nullptr¶
Broad-phase method to use.
-
void build(const Candidates& candidates, const CollisionMesh& mesh,
Eigen::ConstRef<Eigen::MatrixXd> vertices, const double dhat,
const double dmin = 0);¶ Initialize the set of collisions used to compute the barrier potential.
- Parameters:¶
- const Candidates &candidates¶
Distance candidates from which the collision set is built.
- const CollisionMesh &mesh¶
The collision mesh.
- Eigen::ConstRef<Eigen::MatrixXd> vertices¶
Vertices of the collision mesh.
- const double dhat¶
The activation distance of the barrier.
- const double dmin = 0¶
Minimum distance.
-
double compute_minimum_distance(const CollisionMesh& mesh,
Eigen::ConstRef<Eigen::MatrixXd> vertices) const;¶ Computes the minimum distance between any non-adjacent elements.
- Parameters:¶
- const CollisionMesh &mesh¶
The collision mesh.
- Eigen::ConstRef<Eigen::MatrixXd> vertices¶
Vertices of the collision mesh.
- Returns:¶
The minimum distance between any non-adjacent elements.
- size_t size() const;¶
Get the number of collisions.
- bool empty() const;¶
Get if the collision set are empty.
- void clear();¶
Clear the collision set.
- NormalCollision& operator[](size_t i);¶
Get a reference to collision at index i.
- const NormalCollision& operator[](size_t i) const;¶
Get a const reference to collision at index i.
- inline bool use_area_weighting() const;¶
Get if the collision set should use area weighting.
Note
If not empty, this is the current value not necessarily the value used to build the collisions.
- Returns:¶
If the collision set should use area weighting.
- void set_use_area_weighting(const bool use_area_weighting);¶
Set if the collision set should use area weighting.
Warning
This must be set before the collisions are built.
- inline bool use_improved_max_approximator() const;¶
Get if the collision set should use the improved max approximator.
Note
If not empty, this is the current value not necessarily the value used to build the collisions.
- Returns:¶
If the collision set should use the improved max approximator.
-
inline void set_use_improved_max_approximator(
const bool use_improved_max_approximator);¶ Set if the collision set should use the improved max approximator.
Warning
This must be set before the collisions are built.
- inline CollisionSetType collision_set_type() const;¶
Get the set type of the collision set.
Note
If not empty, this is the current value not necessarily the value used to build the collisions.
- Returns:¶
The set type of the collision set.
- void set_collision_set_type(const CollisionSetType type);¶
Set the set type of the collision set.
- Parameters:¶
- const CollisionSetType type¶
The set type of the collision set.
- inline bool enable_shape_derivatives() const;¶
Get if the collision set are using the convergent formulation.
Note
If not empty, this is the current value not necessarily the value used to build the collisions.
- Returns:¶
If the collision set are using the convergent formulation.
-
void set_enable_shape_derivatives(
const bool enable_shape_derivatives);¶ Set if the collision set should enable shape derivative computation.
Warning
This must be set before the collisions are built.
-
std::string to_string(const CollisionMesh& mesh,
Eigen::ConstRef<Eigen::MatrixXd> vertices) const;¶
Public Members¶
- std::vector<VertexVertexNormalCollision> vv_collisions;¶
Vertex-vertex normal collisions.
- std::vector<EdgeVertexNormalCollision> ev_collisions;¶
Edge-vertex normal collisions.
- std::vector<EdgeEdgeNormalCollision> ee_collisions;¶
Edge-edge normal collisions.
- std::vector<FaceVertexNormalCollision> fv_collisions;¶
Face-vertex normal collisions.
- std::vector<PlaneVertexNormalCollision> pv_collisions;¶
Plane-vertex normal collisions.
Protected Attributes¶
- CollisionSetType m_collision_set_type = CollisionSetType::IPC;¶
- bool m_use_area_weighting = false;¶
- bool m_enable_shape_derivatives = false;¶
Normal Collision¶
- class NormalCollision : public virtual ipc::CollisionStencil;¶
Inheritance diagram for ipc::NormalCollision:
Collaboration diagram for ipc::NormalCollision:
Subclassed by ipc::EdgeEdgeNormalCollision, ipc::EdgeVertexNormalCollision, ipc::FaceVertexNormalCollision, ipc::PlaneVertexNormalCollision, ipc::VertexVertexNormalCollision
Public Functions¶
- NormalCollision() = default;¶
-
NormalCollision(const double weight,
const Eigen::SparseVector<double>& weight_gradient);¶
- virtual ~NormalCollision() = default;¶
- inline virtual bool is_mollified() const;¶
Does the distance potentially have to be mollified?
-
inline virtual double mollifier_threshold(
Eigen::ConstRef<VectorMax12d> rest_positions) const;¶ Compute the mollifier threshold for the distance.
- Parameters:¶
- Eigen::ConstRef<VectorMax12d> rest_positions¶
The stencil’s rest vertex positions.
- Returns:¶
The mollifier threshold.
-
virtual double mollifier(
Eigen::ConstRef<VectorMax12d> positions) const;¶ Compute the mollifier for the distance.
- Parameters:¶
- Eigen::ConstRef<VectorMax12d> positions¶
The stencil’s vertex positions.
- Returns:¶
The mollifier value.
-
virtual double mollifier(
Eigen::ConstRef<VectorMax12d> positions, double eps_x) const;¶ Compute the mollifier for the distance.
- Parameters:¶
- Eigen::ConstRef<VectorMax12d> positions¶
The stencil’s vertex positions.
- double eps_x¶
The mollifier’s threshold.
- Returns:¶
The mollifier value.
-
virtual VectorMax12d mollifier_gradient(
Eigen::ConstRef<VectorMax12d> positions) const;¶ Compute the gradient of the mollifier for the distance wrt the positions.
- Parameters:¶
- Eigen::ConstRef<VectorMax12d> positions¶
The stencil’s vertex positions.
- Returns:¶
The mollifier gradient.
-
virtual VectorMax12d mollifier_gradient(
Eigen::ConstRef<VectorMax12d> positions, double eps_x) const;¶ Compute the gradient of the mollifier for the distance wrt the positions.
- Parameters:¶
- Eigen::ConstRef<VectorMax12d> positions¶
The stencil’s vertex positions.
- double eps_x¶
The mollifier’s threshold.
- Returns:¶
The mollifier gradient.
-
virtual MatrixMax12d mollifier_hessian(
Eigen::ConstRef<VectorMax12d> positions) const;¶ Compute the Hessian of the mollifier for the distance wrt the positions.
- Parameters:¶
- Eigen::ConstRef<VectorMax12d> positions¶
The stencil’s vertex positions.
- Returns:¶
The mollifier Hessian.
-
virtual MatrixMax12d mollifier_hessian(
Eigen::ConstRef<VectorMax12d> positions, double eps_x) const;¶ Compute the Hessian of the mollifier for the distance wrt the positions.
- Parameters:¶
- Eigen::ConstRef<VectorMax12d> positions¶
The stencil’s vertex positions.
- double eps_x¶
The mollifier’s threshold.
- Returns:¶
The mollifier Hessian.
-
virtual Vector12d mollifier_gradient_wrt_x(
Eigen::ConstRef<VectorMax12d> rest_positions,
Eigen::ConstRef<VectorMax12d> positions) const;¶ Compute the gradient of the mollifier for the distance w.r.t.
rest positions.
- Parameters:¶
- Eigen::ConstRef<VectorMax12d> rest_positions¶
The stencil’s rest vertex positions.
- Eigen::ConstRef<VectorMax12d> positions¶
The stencil’s vertex positions.
- Returns:¶
The mollifier gradient w.r.t. rest positions.
-
virtual Matrix12d mollifier_gradient_jacobian_wrt_x(
Eigen::ConstRef<VectorMax12d> rest_positions,
Eigen::ConstRef<VectorMax12d> positions) const;¶ Compute the jacobian of the distance mollifier’s gradient w.r.t.
rest positions.
- Parameters:¶
- Eigen::ConstRef<VectorMax12d> rest_positions¶
The stencil’s rest vertex positions.
- Eigen::ConstRef<VectorMax12d> positions¶
The stencil’s vertex positions.
- Returns:¶
The jacobian of the mollifier’s gradient w.r.t. rest positions.
Vertex-Vertex Normal Collision¶
-
class VertexVertexNormalCollision
: public ipc::VertexVertexCandidate,
public ipc::NormalCollision;¶ Inheritance diagram for ipc::VertexVertexNormalCollision:
Collaboration diagram for ipc::VertexVertexNormalCollision:
Public Functions¶
-
inline VertexVertexNormalCollision(
const VertexVertexCandidate& candidate);¶
-
inline VertexVertexNormalCollision(const index_t _vertex0_id,
const index_t _vertex1_id, const double _weight,
const Eigen::SparseVector<double>& _weight_gradient);¶
- VertexVertexCandidate(index_t vertex0_id, index_t vertex1_id);¶
-
inline VertexVertexNormalCollision(
Edge-Vertex Normal Collision¶
-
class EdgeVertexNormalCollision : public ipc::EdgeVertexCandidate,
public ipc::NormalCollision;¶ Inheritance diagram for ipc::EdgeVertexNormalCollision:
Collaboration diagram for ipc::EdgeVertexNormalCollision:
Public Functions¶
-
inline EdgeVertexNormalCollision(
const EdgeVertexCandidate& candidate);¶
-
inline EdgeVertexNormalCollision(const index_t _edge_id,
const index_t _vertex_id, const double _weight,
const Eigen::SparseVector<double>& _weight_gradient);¶
- inline virtual PointEdgeDistanceType known_dtype() const override;¶
-
inline EdgeVertexNormalCollision(
Edge-Edge Normal Collision¶
-
class EdgeEdgeNormalCollision : public ipc::EdgeEdgeCandidate,
public ipc::NormalCollision;¶ Inheritance diagram for ipc::EdgeEdgeNormalCollision:
Collaboration diagram for ipc::EdgeEdgeNormalCollision:
Public Functions¶
-
EdgeEdgeNormalCollision(const index_t edge0_id,
const index_t edge1_id, const double eps_x,
const EdgeEdgeDistanceType dtype = EdgeEdgeDistanceType::AUTO);¶
-
EdgeEdgeNormalCollision(const EdgeEdgeCandidate& candidate,
const double eps_x,
const EdgeEdgeDistanceType dtype = EdgeEdgeDistanceType::AUTO);¶
-
EdgeEdgeNormalCollision(const index_t edge0_id,
const index_t edge1_id, const double eps_x, const double weight,
const Eigen::SparseVector<double>& weight_gradient,
const EdgeEdgeDistanceType dtype = EdgeEdgeDistanceType::AUTO);¶
- inline virtual bool is_mollified() const override;¶
Does the distance potentially have to be mollified?
-
virtual double mollifier_threshold(
Eigen::ConstRef<VectorMax12d> rest_positions) const override;¶ Compute the mollifier threshold for the distance.
- Parameters:¶
- Eigen::ConstRef<VectorMax12d> rest_positions¶
The stencil’s rest vertex positions.
- Returns:¶
The mollifier threshold.
-
virtual double mollifier(
Eigen::ConstRef<VectorMax12d> positions) const override;¶ Compute the mollifier for the distance.
- Parameters:¶
- Eigen::ConstRef<VectorMax12d> positions¶
The stencil’s vertex positions.
- Returns:¶
The mollifier value.
-
virtual double mollifier(Eigen::ConstRef<VectorMax12d> positions,
double eps_x) const override;¶ Compute the mollifier for the distance.
- Parameters:¶
- Eigen::ConstRef<VectorMax12d> positions¶
The stencil’s vertex positions.
- double eps_x¶
The mollifier’s tolerance.
- Returns:¶
The mollifier value.
-
virtual VectorMax12d mollifier_gradient(
Eigen::ConstRef<VectorMax12d> positions) const override;¶ Compute the gradient of the mollifier for the distance w.r.t.
positions.
- Parameters:¶
- Eigen::ConstRef<VectorMax12d> positions¶
The stencil’s vertex positions.
- Returns:¶
The mollifier gradient.
-
virtual VectorMax12d mollifier_gradient(
Eigen::ConstRef<VectorMax12d> positions,
double eps_x) const override;¶ Compute the gradient of the mollifier for the distance wrt the positions.
- Parameters:¶
- Eigen::ConstRef<VectorMax12d> positions¶
The stencil’s vertex positions.
- double eps_x¶
The mollifier’s tolerance.
- Returns:¶
The mollifier gradient.
-
virtual MatrixMax12d mollifier_hessian(
Eigen::ConstRef<VectorMax12d> positions) const override;¶ Compute the Hessian of the mollifier for the distance w.r.t.
positions.
- Parameters:¶
- Eigen::ConstRef<VectorMax12d> positions¶
The stencil’s vertex positions.
- Returns:¶
The mollifier Hessian.
-
virtual MatrixMax12d mollifier_hessian(
Eigen::ConstRef<VectorMax12d> positions,
double eps_x) const override;¶ Compute the Hessian of the mollifier for the distance wrt the positions.
- Parameters:¶
- Eigen::ConstRef<VectorMax12d> positions¶
The stencil’s vertex positions.
- double eps_x¶
The mollifier’s tolerance.
- Returns:¶
The mollifier Hessian.
-
virtual Vector12d mollifier_gradient_wrt_x(
Eigen::ConstRef<VectorMax12d> rest_positions,
Eigen::ConstRef<VectorMax12d> positions) const override;¶ Compute the gradient of the mollifier for the distance w.r.t.
rest positions.
- Parameters:¶
- Eigen::ConstRef<VectorMax12d> rest_positions¶
The stencil’s rest vertex positions.
- Eigen::ConstRef<VectorMax12d> positions¶
The stencil’s vertex positions.
- Returns:¶
The mollifier gradient w.r.t. rest positions.
-
virtual Matrix12d mollifier_gradient_jacobian_wrt_x(
Eigen::ConstRef<VectorMax12d> rest_positions,
Eigen::ConstRef<VectorMax12d> positions) const override;¶ Compute the jacobian of the distance mollifier’s gradient w.r.t.
rest positions.
- Parameters:¶
- Eigen::ConstRef<VectorMax12d> rest_positions¶
The stencil’s rest vertex positions.
- Eigen::ConstRef<VectorMax12d> positions¶
The stencil’s vertex positions.
- Returns:¶
The jacobian of the mollifier’s gradient w.r.t. rest positions.
- inline virtual EdgeEdgeDistanceType known_dtype() const override;¶
- bool operator==(const EdgeEdgeNormalCollision& other) const;¶
- bool operator!=(const EdgeEdgeNormalCollision& other) const;¶
- bool operator<(const EdgeEdgeNormalCollision& other) const;¶
Public Members¶
- double eps_x;¶
Mollifier activation threshold.
See also
- EdgeEdgeDistanceType dtype;¶
Cached distance type.
Some EE collisions are mollified EV or VV collisions.
-
EdgeEdgeNormalCollision(const index_t edge0_id,
Face-Vertex Normal Collision¶
-
class FaceVertexNormalCollision : public ipc::FaceVertexCandidate,
public ipc::NormalCollision;¶ Inheritance diagram for ipc::FaceVertexNormalCollision:
Collaboration diagram for ipc::FaceVertexNormalCollision:
Public Functions¶
-
inline FaceVertexNormalCollision(
const FaceVertexCandidate& candidate);¶
-
inline FaceVertexNormalCollision(const index_t _face_id,
const index_t _vertex_id, const double _weight,
const Eigen::SparseVector<double>& _weight_gradient);¶
-
inline virtual PointTriangleDistanceType
known_dtype() const override;¶
-
inline FaceVertexNormalCollision(
Plane-Vertex Normal Collision¶
-
class PlaneVertexNormalCollision : public ipc::PlaneVertexCandidate,
public ipc::NormalCollision;¶ Inheritance diagram for ipc::PlaneVertexNormalCollision:
Collaboration diagram for ipc::PlaneVertexNormalCollision:
Public Functions¶
-
inline PlaneVertexNormalCollision(
const PlaneVertexCandidate& candidate);¶
-
inline PlaneVertexNormalCollision(
const Eigen::Hyperplane<double, 3>& _plane,
const index_t _vertex_id, const double _weight,
const Eigen::SparseVector<double>& _weight_gradient);¶
-
inline PlaneVertexNormalCollision(