Collision Constraints¶
Collision Constraints¶
- class CollisionConstraints;¶
Public Functions¶
- inline CollisionConstraints();¶
-
void build(const CollisionMesh& mesh,
const Eigen::MatrixXd& vertices, const double dhat,
const double dmin = 0,
const BroadPhaseMethod broad_phase_method
= DEFAULT_BROAD_PHASE_METHOD);¶ Initialize the set of constraints used to compute the barrier potential.
- Parameters:¶
- const CollisionMesh &mesh¶
The collision mesh.
- const Eigen::MatrixXd &vertices¶
Vertices of the collision mesh.
- const double dhat¶
The activation distance of the barrier.
- const double dmin = 0¶
Minimum distance.
- const BroadPhaseMethod broad_phase_method = DEFAULT_BROAD_PHASE_METHOD¶
Broad-phase method to use.
-
void build(const Candidates& candidates, const CollisionMesh& mesh,
const Eigen::MatrixXd& vertices, const double dhat,
const double dmin = 0);¶ Initialize the set of constraints used to compute the barrier potential.
- Parameters:¶
- const Candidates &candidates¶
Distance candidates from which the constraint set is built.
- const CollisionMesh &mesh¶
The collision mesh.
- const 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_potential(const CollisionMesh& mesh,
const Eigen::MatrixXd& vertices, const double dhat) const;¶ Compute the barrier potential for a given constraint set.
-
Eigen::VectorXd compute_potential_gradient(
const CollisionMesh& mesh, const Eigen::MatrixXd& vertices,
const double dhat) const;¶ Compute the gradient of the barrier potential.
- Parameters:¶
- const CollisionMesh &mesh¶
The collision mesh.
- const Eigen::MatrixXd &vertices¶
Vertices of the collision mesh.
- const double dhat¶
The activation distance of the barrier.
- Returns:¶
The gradient of all barrier potentials (not scaled by the barrier stiffness). This will have a size of |vertices|.
-
Eigen::SparseMatrix<double> compute_potential_hessian(
const CollisionMesh& mesh, const Eigen::MatrixXd& vertices,
const double dhat,
const bool project_hessian_to_psd = false) const;¶ Compute the hessian of the barrier potential.
- Parameters:¶
- const CollisionMesh &mesh¶
The collision mesh.
- const Eigen::MatrixXd &vertices¶
Vertices of the collision mesh.
- const double dhat¶
The activation distance of the barrier.
- const bool project_hessian_to_psd = false¶
Make sure the hessian is positive semi-definite.
- Returns:¶
The hessian of all barrier potentials (not scaled by the barrier stiffness). This will have a size of |vertices|x|vertices|.
-
Eigen::SparseMatrix<double> compute_shape_derivative(
const CollisionMesh& mesh, const Eigen::MatrixXd& vertices,
const double dhat) const;¶ Compute the barrier shape derivative.
- Parameters:¶
- const CollisionMesh &mesh¶
The collision mesh.
- const Eigen::MatrixXd &vertices¶
Vertices of the collision mesh.
- const double dhat¶
The activation distance of the barrier.
- Throws:¶
std::runtime_error
– If the collision constraints were not built with shape derivatives enabled.- Returns:¶
The derivative of the force with respect to X, the rest vertices.
-
double compute_minimum_distance(const CollisionMesh& mesh,
const Eigen::MatrixXd& vertices) const;¶ Computes the minimum distance between any non-adjacent elements.
- Parameters:¶
- const CollisionMesh &mesh¶
The collision mesh.
- const 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 collision constraints.
- bool empty() const;¶
Get if the collision constraints are empty.
- void clear();¶
Clear the collision constraints.
- CollisionConstraint& operator[](size_t idx);¶
Get a reference to constriant idx.
- const CollisionConstraint& operator[](size_t idx) const;¶
Get a const reference to constriant idx.
- bool is_vertex_vertex(size_t idx) const;¶
Get if the constraint at idx is a vertex-vertex constraint.
- bool is_plane_vertex(size_t idx) const;¶
Get if the constraint at idx is an plane-vertex constraint.
- inline bool use_convergent_formulation() const;¶
Get if the collision constraints should use the convergent formulation.
Note
If not empty, this is the current value not necessarily the value used to build the constraints.
- Returns:¶
If the collision constraints should use the convergent formulation.
-
void set_use_convergent_formulation(
const bool use_convergent_formulation);¶ Set if the collision constraints should use the convergent formulation.
Warning
This must be set before the constraints are built.
- inline bool are_shape_derivatives_enabled() const;¶
Get if the collision constraints are using the convergent formulation.
Note
If not empty, this is the current value not necessarily the value used to build the constraints.
- Returns:¶
If the collision constraints are using the convergent formulation.
-
void set_are_shape_derivatives_enabled(
const bool are_shape_derivatives_enabled);¶ Set if the collision constraints should enable shape derivative computation.
Warning
This must be set before the constraints are built.
-
std::string to_string(const CollisionMesh& mesh,
const Eigen::MatrixXd& vertices) const;¶
Public Members¶
- std::vector<VertexVertexConstraint> vv_constraints;¶
- std::vector<EdgeVertexConstraint> ev_constraints;¶
- std::vector<EdgeEdgeConstraint> ee_constraints;¶
- std::vector<FaceVertexConstraint> fv_constraints;¶
- std::vector<PlaneVertexConstraint> pv_constraints;¶
Collision Constraint¶
- class CollisionConstraint : public virtual ipc::CollisionStencil;¶
Inheritance diagram for ipc::CollisionConstraint:
Collaboration diagram for ipc::CollisionConstraint:
Subclassed by ipc::EdgeEdgeConstraint, ipc::EdgeVertexConstraint, ipc::FaceVertexConstraint, ipc::PlaneVertexConstraint, ipc::VertexVertexConstraint
Public Functions¶
- CollisionConstraint() = default;¶
-
CollisionConstraint(const double weight,
const Eigen::SparseVector<double>& weight_gradient);¶
- inline virtual ~CollisionConstraint();¶
-
virtual double compute_potential(const Eigen::MatrixXd& vertices,
const Eigen::MatrixXi& edges, const Eigen::MatrixXi& faces,
const double dhat) const;¶
-
virtual VectorMax12d compute_potential_gradient(
const Eigen::MatrixXd& vertices, const Eigen::MatrixXi& edges,
const Eigen::MatrixXi& faces, const double dhat) const;¶
-
virtual MatrixMax12d compute_potential_hessian(
const Eigen::MatrixXd& vertices, const Eigen::MatrixXi& edges,
const Eigen::MatrixXi& faces, const double dhat,
const bool project_hessian_to_psd) const;¶
-
virtual void compute_shape_derivative(
const Eigen::MatrixXd& rest_positions,
const Eigen::MatrixXd& vertices, const Eigen::MatrixXi& edges,
const Eigen::MatrixXi& faces, const double dhat,
std::vector<Eigen::Triplet<double>>& triplets) const;¶ Compute the derivative of the potential gradient wrt the shape.
Vertex-Vertex Collision Constraint¶
-
class VertexVertexConstraint : public ipc::VertexVertexCandidate,
public ipc::CollisionConstraint;¶ Inheritance diagram for ipc::VertexVertexConstraint:
Collaboration diagram for ipc::VertexVertexConstraint:
Public Functions¶
-
inline VertexVertexConstraint(
const VertexVertexCandidate& candidate);¶
-
inline VertexVertexConstraint(const long _vertex0_id,
const long _vertex1_id, const double _weight,
const Eigen::SparseVector<double>& _weight_gradient);¶
- VertexVertexCandidate(long vertex0_id, long vertex1_id);¶
-
inline VertexVertexConstraint(
Edge-Vertex Collision Constraint¶
-
class EdgeVertexConstraint : public ipc::EdgeVertexCandidate,
public ipc::CollisionConstraint;¶ Inheritance diagram for ipc::EdgeVertexConstraint:
Collaboration diagram for ipc::EdgeVertexConstraint:
Public Functions¶
- inline EdgeVertexConstraint(const EdgeVertexCandidate& candidate);¶
-
inline EdgeVertexConstraint(const long _edge_id,
const long _vertex_id, const double _weight,
const Eigen::SparseVector<double>& _weight_gradient);¶
Protected Functions¶
- inline virtual PointEdgeDistanceType known_dtype() const override;¶
Edge-Edge Collision Constraint¶
-
class EdgeEdgeConstraint : public ipc::EdgeEdgeCandidate,
public ipc::CollisionConstraint;¶ Inheritance diagram for ipc::EdgeEdgeConstraint:
Collaboration diagram for ipc::EdgeEdgeConstraint:
Public Functions¶
-
EdgeEdgeConstraint(const long edge0_id, const long edge1_id,
const double eps_x,
const EdgeEdgeDistanceType dtype = EdgeEdgeDistanceType::AUTO);¶
-
EdgeEdgeConstraint(const EdgeEdgeCandidate& candidate,
const double eps_x,
const EdgeEdgeDistanceType dtype = EdgeEdgeDistanceType::AUTO);¶
-
EdgeEdgeConstraint(const long edge0_id, const long edge1_id,
const double eps_x, const double weight,
const Eigen::SparseVector<double>& weight_gradient,
const EdgeEdgeDistanceType dtype = EdgeEdgeDistanceType::AUTO);¶
-
virtual double compute_potential(const Eigen::MatrixXd& vertices,
const Eigen::MatrixXi& edges, const Eigen::MatrixXi& faces,
const double dhat) const override;¶
-
virtual VectorMax12d compute_potential_gradient(
const Eigen::MatrixXd& vertices, const Eigen::MatrixXi& edges,
const Eigen::MatrixXi& faces, const double dhat) const override;¶
-
virtual MatrixMax12d compute_potential_hessian(
const Eigen::MatrixXd& vertices, const Eigen::MatrixXi& edges,
const Eigen::MatrixXi& faces, const double dhat,
const bool project_hessian_to_psd) const override;¶
- bool operator==(const EdgeEdgeConstraint& other) const;¶
- bool operator!=(const EdgeEdgeConstraint& other) const;¶
- bool operator<(const EdgeEdgeConstraint& other) const;¶
Public Members¶
- double eps_x;¶
Mollifier activation threshold.
See also
- EdgeEdgeDistanceType dtype;¶
Cached distance type.
Some EE constraints are mollified EV or VV constraints.
Protected Functions¶
- inline virtual EdgeEdgeDistanceType known_dtype() const override;¶
-
EdgeEdgeConstraint(const long edge0_id, const long edge1_id,
Face-Vertex Collision Constraint¶
-
class FaceVertexConstraint : public ipc::FaceVertexCandidate,
public ipc::CollisionConstraint;¶ Inheritance diagram for ipc::FaceVertexConstraint:
Collaboration diagram for ipc::FaceVertexConstraint:
Public Functions¶
- inline FaceVertexConstraint(const FaceVertexCandidate& candidate);¶
-
inline FaceVertexConstraint(const long _face_id,
const long _vertex_id, const double _weight,
const Eigen::SparseVector<double>& _weight_gradient);¶
Protected Functions¶
-
inline virtual PointTriangleDistanceType
known_dtype() const override;¶
Plane-Vertex Collision Constraint¶
- class PlaneVertexConstraint : public ipc::CollisionConstraint;¶
Inheritance diagram for ipc::PlaneVertexConstraint:
Collaboration diagram for ipc::PlaneVertexConstraint:
Public Functions¶
-
PlaneVertexConstraint(const VectorMax3d& plane_origin,
const VectorMax3d& plane_normal, const long vertex_id);¶
- inline virtual int num_vertices() const override;¶
Get the number of vertices in the contact stencil.
Protected Functions¶
-
virtual double compute_distance(
const VectorMax12d& point) const override;¶ Compute the distance between the point and plane.
-
PlaneVertexConstraint(const VectorMax3d& plane_origin,