Candidates

Candidates

class Candidates;

Public Functions

inline Candidates();
void build(const CollisionMeshmesh,
    
const Eigen::MatrixXdvertices,
    
const double inflation_radius = 0,
    
const BroadPhaseMethod broad_phase_method
    
= DEFAULT_BROAD_PHASE_METHOD
);

Initialize the set of discrete collision detection candidates.

Parameters:
const CollisionMesh &mesh

The surface of the contact mesh.

const Eigen::MatrixXd &vertices

Surface vertex positions (rowwise).

const double inflation_radius = 0

Amount to inflate the bounding boxes.

const BroadPhaseMethod broad_phase_method = DEFAULT_BROAD_PHASE_METHOD

Broad phase method to use.

void build(const CollisionMeshmesh,
    
const Eigen::MatrixXdvertices_t0,
    
const Eigen::MatrixXdvertices_t1,
    
const double inflation_radius = 0,
    
const BroadPhaseMethod broad_phase_method
    
= DEFAULT_BROAD_PHASE_METHOD
);

Initialize the set of continuous collision detection candidates.

Note

Assumes the trajectory is linear.

Parameters:
const CollisionMesh &mesh

The surface of the contact mesh.

const Eigen::MatrixXd &vertices_t0

Surface vertex starting positions (rowwise).

const Eigen::MatrixXd &vertices_t1

Surface vertex ending positions (rowwise).

const double inflation_radius = 0

Amount to inflate the bounding boxes.

const BroadPhaseMethod broad_phase_method = DEFAULT_BROAD_PHASE_METHOD

Broad phase method to use.

size_t size() const;
bool empty() const;
void clear();
ContinuousCollisionCandidateoperator[](size_t idx);
const ContinuousCollisionCandidateoperator[](size_t idx) const;
bool is_step_collision_free(const CollisionMeshmesh,
    
const Eigen::MatrixXdvertices_t0,
    
const Eigen::MatrixXdvertices_t1,
    
const double min_distance = 0.0,
    
const double tolerance = DEFAULT_CCD_TOLERANCE,
    
const long max_iterations = DEFAULT_CCD_MAX_ITERATIONS) const;

Determine if the step is collision free from the set of candidates.

Note

Assumes the trajectory is linear.

Parameters:
const CollisionMesh &mesh

The collision mesh.

const Eigen::MatrixXd &vertices_t0

Surface vertex starting positions (rowwise).

const Eigen::MatrixXd &vertices_t1

Surface vertex ending positions (rowwise).

const double min_distance = 0.0

The minimum distance allowable between any two elements.

const double tolerance = DEFAULT_CCD_TOLERANCE

The tolerance for the CCD algorithm.

const long max_iterations = DEFAULT_CCD_MAX_ITERATIONS

The maximum number of iterations for the CCD algorithm.

Returns:

True if any collisions occur.

double compute_collision_free_stepsize(const CollisionMeshmesh,
    
const Eigen::MatrixXdvertices_t0,
    
const Eigen::MatrixXdvertices_t1,
    
const double min_distance = 0.0,
    
const double tolerance = DEFAULT_CCD_TOLERANCE,
    
const long max_iterations = DEFAULT_CCD_MAX_ITERATIONS) const;

Computes a maximal step size that is collision free using the set of collision candidates.

Note

Assumes the trajectory is linear.

Parameters:
const CollisionMesh &mesh

The collision mesh.

const Eigen::MatrixXd &vertices_t0

Surface vertex starting positions (rowwise). Assumed to be intersection free.

const Eigen::MatrixXd &vertices_t1

Surface vertex ending positions (rowwise).

const double min_distance = 0.0

The minimum distance allowable between any two elements.

const double tolerance = DEFAULT_CCD_TOLERANCE

The tolerance for the CCD algorithm.

const long max_iterations = DEFAULT_CCD_MAX_ITERATIONS

The maximum number of iterations for the CCD algorithm.

Returns:

A step-size \(\in [0, 1]\) that is collision free. A value of 1.0 if a full step and 0.0 is no step.

double compute_noncandidate_conservative_stepsize(
    
const CollisionMeshmeshconst Eigen::MatrixXddisplacements,
    
const double dhat) const;

Computes a conservative bound on the largest-feasible step size for surface primitives not in contact.

Parameters:
const CollisionMesh &mesh

The collision mesh.

const Eigen::MatrixXd &displacements

Surface vertex displacements (rowwise).

const double dhat

Barrier activation distance.

double compute_cfl_stepsize(const CollisionMeshmesh,
    
const Eigen::MatrixXdvertices_t0,
    
const Eigen::MatrixXdvertices_t1const double dhat,
    
const BroadPhaseMethod broad_phase_method
    
= DEFAULT_BROAD_PHASE_METHOD
,
    
const double min_distance = 0.0,
    
const double tolerance = DEFAULT_CCD_TOLERANCE,
    
const long max_iterations = DEFAULT_CCD_MAX_ITERATIONS) const;

Computes a CFL-inspired CCD maximum step step size.

Parameters:
const CollisionMesh &mesh

The collision mesh.

const Eigen::MatrixXd &vertices_t0

Surface vertex starting positions (rowwise).

const Eigen::MatrixXd &vertices_t1

Surface vertex ending positions (rowwise).

const double dhat

Barrier activation distance.

const double min_distance = 0.0

The minimum distance allowable between any two elements.

const double tolerance = DEFAULT_CCD_TOLERANCE

The tolerance for the CCD algorithm.

const long max_iterations = DEFAULT_CCD_MAX_ITERATIONS

The maximum number of iterations for the CCD algorithm.

bool save_obj(const std::stringfilename,
    
const Eigen::MatrixXdverticesconst Eigen::MatrixXiedges,
    
const Eigen::MatrixXifaces) const;

Public Members

std::vector<EdgeVertexCandidate> ev_candidates;
std::vector<EdgeEdgeCandidate> ee_candidates;
std::vector<FaceVertexCandidate> fv_candidates;

Collision Stencil

class CollisionStencil;

A stencil representing a collision between at most four vertices.

Subclassed by ipc::CollisionConstraint, ipc::ContinuousCollisionCandidate, ipc::FrictionConstraint, ipc::VertexVertexCandidate

Public Functions

virtual ~CollisionStencil() = default;
virtual int num_vertices() const = 0;

Get the number of vertices in the contact stencil.

virtual std::array<long, 4> vertex_ids(const Eigen::MatrixXiedges,
    
const Eigen::MatrixXifaces) const
   
 = 0;

Get the vertex IDs of the contact stencil.

Parameters:
const Eigen::MatrixXi &edges

Collision mesh edges

const Eigen::MatrixXi &faces

Collision mesh faces

Returns:

The vertex IDs of the contact stencil. Size is always 4, but elements i > num_vertices() are -1.

template <typename T>
inline std::array<VectorMax3<T>, 4> vertices(
    
const MatrixX<T>& verticesconst Eigen::MatrixXiedges,
    
const Eigen::MatrixXifaces) const;

Get the vertex attributes of the contact stencil.

Template Parameters:
typename T

Type of the attributes

Parameters:
const MatrixX<T> &vertices

Vertex attributes

const Eigen::MatrixXi &edges

Collision mesh edges

const Eigen::MatrixXi &faces

Collision mesh faces

Returns:

The vertex positions of the contact stencil. Size is always 4, but elements i > num_vertices() are NaN.

template <typename T>
inline VectorMax12<T> dof(const MatrixX<T>& X,
    
const Eigen::MatrixXiedges,
    
const Eigen::MatrixXifaces) const;

Select this stencil’s DOF from the full matrix of DOF.

Template Parameters:
typename T

Type of the DOF

Parameters:
const MatrixX<T> &X

Full matrix of DOF (rowwise).

const Eigen::MatrixXi &edges

Collision mesh edges

const Eigen::MatrixXi &faces

Collision mesh faces

Returns:

This constraint’s DOF.

double compute_distance(const Eigen::MatrixXdvertices,
    
const Eigen::MatrixXiedges,
    
const Eigen::MatrixXifaces) const;

Compute the distance of the stencil.

Parameters:
const Eigen::MatrixXd &vertices

Collision mesh vertex positions.

const Eigen::MatrixXi &edges

Collision mesh edges

const Eigen::MatrixXi &faces

Collision mesh faces

Returns:

Distance of the stencil.

VectorMax12d compute_distance_gradient(
    
const Eigen::MatrixXdverticesconst Eigen::MatrixXiedges,
    
const Eigen::MatrixXifaces) const;

Compute the distance gradient of the stencil w.r.t.

the stencil’s vertex positions.

Parameters:
const Eigen::MatrixXd &vertices

Collision mesh vertex positions.

const Eigen::MatrixXi &edges

Collision mesh edges

const Eigen::MatrixXi &faces

Collision mesh faces

Returns:

Distance gradient of the stencil w.r.t. the stencil’s vertex positions.

MatrixMax12d compute_distance_hessian(
    
const Eigen::MatrixXdverticesconst Eigen::MatrixXiedges,
    
const Eigen::MatrixXifaces) const;

Compute the distance Hessian of the stencil w.r.t.

the stencil’s vertex positions.

Parameters:
const Eigen::MatrixXd &vertices

Collision mesh vertex positions.

const Eigen::MatrixXi &edges

Collision mesh edges

const Eigen::MatrixXi &faces

Collision mesh faces

Returns:

Distance Hessian of the stencil w.r.t. the stencil’s vertex positions.

Protected Functions

virtual double compute_distance(const VectorMax12dvertices) const
   
 = 0;

Compute the distance of the stencil.

Parameters:
const VectorMax12d &vertices

Stencil’s vertex positions.

Returns:

Distance of the stencil.

virtual VectorMax12d compute_distance_gradient(
    
const VectorMax12dvertices) const
   
 = 0;

Compute the distance gradient of the stencil w.r.t.

the stencil’s vertex positions.

Parameters:
const VectorMax12d &vertices

Stencil’s vertex positions.

Returns:

Distance gradient of the stencil w.r.t. the stencil’s vertex positions.

virtual MatrixMax12d compute_distance_hessian(
    
const VectorMax12dvertices) const
   
 = 0;

Compute the distance Hessian of the stencil w.r.t.

the stencil’s vertex positions.

Parameters:
const VectorMax12d &vertices

Stencil’s vertex positions.

Returns:

Distance Hessian of the stencil w.r.t. the stencil’s vertex positions.

Continuous Collision Candidate

class ContinuousCollisionCandidate
   
 : public virtual ipc::CollisionStencil;

Virtual class for candidates that support CCD.

Subclassed by ipc::EdgeEdgeCandidate, ipc::EdgeVertexCandidate, ipc::FaceVertexCandidate

Public Functions

inline virtual ~ContinuousCollisionCandidate();
bool ccd(const Eigen::MatrixXdvertices_t0,
    
const Eigen::MatrixXdvertices_t1,
    
const Eigen::MatrixXiedgesconst Eigen::MatrixXifaces,
    
double& toiconst double min_distance = 0.0,
    
const double tmax = 1.0,
    
const double tolerance = DEFAULT_CCD_TOLERANCE,
    
const long max_iterations = DEFAULT_CCD_MAX_ITERATIONS,
    
const double conservative_rescaling
    
= DEFAULT_CCD_CONSERVATIVE_RESCALING
) const;

Perform narrow-phase CCD on the candidate.

Parameters:
const Eigen::MatrixXd &vertices_t0

[in] Mesh vertices at the start of the time step.

const Eigen::MatrixXd &vertices_t1

[in] Mesh vertices at the end of the time step.

const Eigen::MatrixXi &edges

[in] Collision mesh edges as rows of indicies into vertices.

const Eigen::MatrixXi &faces

[in] Collision mesh triangular faces as rows of indicies into vertices.

double &toi

[out] Computed time of impact (normalized).

const double min_distance = 0.0

[in] Minimum separation distance between primitives.

const double tmax = 1.0

[in] Maximum time (normalized) to look for collisions. Should be in [0, 1].

const double tolerance = DEFAULT_CCD_TOLERANCE

[in] CCD tolerance used by Tight-Inclusion CCD.

const long max_iterations = DEFAULT_CCD_MAX_ITERATIONS

[in] Maximum iterations used by Tight-Inclusion CCD.

const double conservative_rescaling = DEFAULT_CCD_CONSERVATIVE_RESCALING

[in] Conservative rescaling value used to avoid taking steps exactly to impact.

Returns:

If the candidate had a collision over the time interval.

virtual void print_ccd_query(const Eigen::MatrixXdvertices_t0,
    
const Eigen::MatrixXdvertices_t1,
    
const Eigen::MatrixXiedges,
    
const Eigen::MatrixXifaces) const
   
 = 0;

Protected Functions

virtual bool ccd(const VectorMax12dvertices_t0,
    
const VectorMax12dvertices_t1double& toi,
    
const double min_distance = 0.0const double tmax = 1.0,
    
const double tolerance = DEFAULT_CCD_TOLERANCE,
    
const long max_iterations = DEFAULT_CCD_MAX_ITERATIONS,
    
const double conservative_rescaling
    
= DEFAULT_CCD_CONSERVATIVE_RESCALING
) const
   
 = 0;

Vertex-Vertex Candidate

class VertexVertexCandidate : public virtual ipc::CollisionStencil;

Subclassed by ipc::VertexVertexConstraint, ipc::VertexVertexFrictionConstraint

Public Functions

VertexVertexCandidate(long vertex0_idlong vertex1_id);
inline virtual int num_vertices() const override;

Get the number of vertices in the contact stencil.

inline virtual std::array<long, 4> vertex_ids(
    
const Eigen::MatrixXiedges,
    
const Eigen::MatrixXifaces) const override;

Get the indices of the vertices.

Parameters:
const Eigen::MatrixXi &edges

edge matrix of mesh

const Eigen::MatrixXi &faces

face matrix of mesh

Returns:

List of vertex indices

bool operator==(const VertexVertexCandidateother) const;
bool operator!=(const VertexVertexCandidateother) const;
bool operator<(const VertexVertexCandidateother) const;

Compare EdgeVertexCandidates for sorting.

double compute_distance(const Eigen::MatrixXdvertices,
    
const Eigen::MatrixXiedges,
    
const Eigen::MatrixXifaces) const;

Compute the distance of the stencil.

Parameters:
const Eigen::MatrixXd &vertices

Collision mesh vertex positions.

const Eigen::MatrixXi &edges

Collision mesh edges

const Eigen::MatrixXi &faces

Collision mesh faces

Returns:

Distance of the stencil.

virtual double compute_distance(const VectorMax12dvertices) const
   
 = 0;

Compute the distance of the stencil.

Parameters:
const VectorMax12d &vertices

Stencil’s vertex positions.

Returns:

Distance of the stencil.

VectorMax12d compute_distance_gradient(
    
const Eigen::MatrixXdverticesconst Eigen::MatrixXiedges,
    
const Eigen::MatrixXifaces) const;

Compute the distance gradient of the stencil w.r.t.

the stencil’s vertex positions.

Parameters:
const Eigen::MatrixXd &vertices

Collision mesh vertex positions.

const Eigen::MatrixXi &edges

Collision mesh edges

const Eigen::MatrixXi &faces

Collision mesh faces

Returns:

Distance gradient of the stencil w.r.t. the stencil’s vertex positions.

virtual VectorMax12d compute_distance_gradient(
    
const VectorMax12dvertices) const
   
 = 0;

Compute the distance gradient of the stencil w.r.t.

the stencil’s vertex positions.

Parameters:
const VectorMax12d &vertices

Stencil’s vertex positions.

Returns:

Distance gradient of the stencil w.r.t. the stencil’s vertex positions.

MatrixMax12d compute_distance_hessian(
    
const Eigen::MatrixXdverticesconst Eigen::MatrixXiedges,
    
const Eigen::MatrixXifaces) const;

Compute the distance Hessian of the stencil w.r.t.

the stencil’s vertex positions.

Parameters:
const Eigen::MatrixXd &vertices

Collision mesh vertex positions.

const Eigen::MatrixXi &edges

Collision mesh edges

const Eigen::MatrixXi &faces

Collision mesh faces

Returns:

Distance Hessian of the stencil w.r.t. the stencil’s vertex positions.

virtual MatrixMax12d compute_distance_hessian(
    
const VectorMax12dvertices) const
   
 = 0;

Compute the distance Hessian of the stencil w.r.t.

the stencil’s vertex positions.

Parameters:
const VectorMax12d &vertices

Stencil’s vertex positions.

Returns:

Distance Hessian of the stencil w.r.t. the stencil’s vertex positions.

Public Members

long vertex0_id;

ID of the first vertex.

long vertex1_id;

ID of the second vertex.

Protected Functions

virtual double compute_distance(
    
const VectorMax12dpositions) const override;

Compute the distance of the stencil.

Parameters:
vertices

Stencil’s vertex positions.

Returns:

Distance of the stencil.

virtual VectorMax12d compute_distance_gradient(
    
const VectorMax12dpositions) const override;

Compute the distance gradient of the stencil w.r.t.

the stencil’s vertex positions.

Parameters:
vertices

Stencil’s vertex positions.

Returns:

Distance gradient of the stencil w.r.t. the stencil’s vertex positions.

virtual MatrixMax12d compute_distance_hessian(
    
const VectorMax12dpositions) const override;

Compute the distance Hessian of the stencil w.r.t.

the stencil’s vertex positions.

Parameters:
vertices

Stencil’s vertex positions.

Returns:

Distance Hessian of the stencil w.r.t. the stencil’s vertex positions.

Friends

template <typename H>
inline friend H AbslHashValue(H hconst VertexVertexCandidatevv);

Edge-Vertex Candidate

class EdgeVertexCandidate
   
 : public ipc::ContinuousCollisionCandidate;

Subclassed by ipc::EdgeVertexConstraint, ipc::EdgeVertexFrictionConstraint

Public Functions

EdgeVertexCandidate(long edge_idlong vertex_id);
inline virtual int num_vertices() const override;

Get the number of vertices in the contact stencil.

inline virtual std::array<long, 4> vertex_ids(
    
const Eigen::MatrixXiedges,
    
const Eigen::MatrixXifaces) const override;

Get the vertex IDs of the contact stencil.

Parameters:
const Eigen::MatrixXi &edges

Collision mesh edges

const Eigen::MatrixXi &faces

Collision mesh faces

Returns:

The vertex IDs of the contact stencil. Size is always 4, but elements i > num_vertices() are -1.

virtual void print_ccd_query(const Eigen::MatrixXdvertices_t0,
    
const Eigen::MatrixXdvertices_t1,
    
const Eigen::MatrixXiedges,
    
const Eigen::MatrixXifaces) const override;
bool operator==(const EdgeVertexCandidateother) const;
bool operator!=(const EdgeVertexCandidateother) const;
bool operator<(const EdgeVertexCandidateother) const;

Compare EdgeVertexCandidates for sorting.

double compute_distance(const Eigen::MatrixXdvertices,
    
const Eigen::MatrixXiedges,
    
const Eigen::MatrixXifaces) const;

Compute the distance of the stencil.

Parameters:
const Eigen::MatrixXd &vertices

Collision mesh vertex positions.

const Eigen::MatrixXi &edges

Collision mesh edges

const Eigen::MatrixXi &faces

Collision mesh faces

Returns:

Distance of the stencil.

virtual double compute_distance(const VectorMax12dvertices) const
   
 = 0;

Compute the distance of the stencil.

Parameters:
const VectorMax12d &vertices

Stencil’s vertex positions.

Returns:

Distance of the stencil.

VectorMax12d compute_distance_gradient(
    
const Eigen::MatrixXdverticesconst Eigen::MatrixXiedges,
    
const Eigen::MatrixXifaces) const;

Compute the distance gradient of the stencil w.r.t.

the stencil’s vertex positions.

Parameters:
const Eigen::MatrixXd &vertices

Collision mesh vertex positions.

const Eigen::MatrixXi &edges

Collision mesh edges

const Eigen::MatrixXi &faces

Collision mesh faces

Returns:

Distance gradient of the stencil w.r.t. the stencil’s vertex positions.

virtual VectorMax12d compute_distance_gradient(
    
const VectorMax12dvertices) const
   
 = 0;

Compute the distance gradient of the stencil w.r.t.

the stencil’s vertex positions.

Parameters:
const VectorMax12d &vertices

Stencil’s vertex positions.

Returns:

Distance gradient of the stencil w.r.t. the stencil’s vertex positions.

MatrixMax12d compute_distance_hessian(
    
const Eigen::MatrixXdverticesconst Eigen::MatrixXiedges,
    
const Eigen::MatrixXifaces) const;

Compute the distance Hessian of the stencil w.r.t.

the stencil’s vertex positions.

Parameters:
const Eigen::MatrixXd &vertices

Collision mesh vertex positions.

const Eigen::MatrixXi &edges

Collision mesh edges

const Eigen::MatrixXi &faces

Collision mesh faces

Returns:

Distance Hessian of the stencil w.r.t. the stencil’s vertex positions.

virtual MatrixMax12d compute_distance_hessian(
    
const VectorMax12dvertices) const
   
 = 0;

Compute the distance Hessian of the stencil w.r.t.

the stencil’s vertex positions.

Parameters:
const VectorMax12d &vertices

Stencil’s vertex positions.

Returns:

Distance Hessian of the stencil w.r.t. the stencil’s vertex positions.

bool ccd(const Eigen::MatrixXdvertices_t0,
    
const Eigen::MatrixXdvertices_t1,
    
const Eigen::MatrixXiedgesconst Eigen::MatrixXifaces,
    
double& toiconst double min_distance = 0.0,
    
const double tmax = 1.0,
    
const double tolerance = DEFAULT_CCD_TOLERANCE,
    
const long max_iterations = DEFAULT_CCD_MAX_ITERATIONS,
    
const double conservative_rescaling
    
= DEFAULT_CCD_CONSERVATIVE_RESCALING
) const;

Perform narrow-phase CCD on the candidate.

Parameters:
const Eigen::MatrixXd &vertices_t0

[in] Mesh vertices at the start of the time step.

const Eigen::MatrixXd &vertices_t1

[in] Mesh vertices at the end of the time step.

const Eigen::MatrixXi &edges

[in] Collision mesh edges as rows of indicies into vertices.

const Eigen::MatrixXi &faces

[in] Collision mesh triangular faces as rows of indicies into vertices.

double &toi

[out] Computed time of impact (normalized).

const double min_distance = 0.0

[in] Minimum separation distance between primitives.

const double tmax = 1.0

[in] Maximum time (normalized) to look for collisions. Should be in [0, 1].

const double tolerance = DEFAULT_CCD_TOLERANCE

[in] CCD tolerance used by Tight-Inclusion CCD.

const long max_iterations = DEFAULT_CCD_MAX_ITERATIONS

[in] Maximum iterations used by Tight-Inclusion CCD.

const double conservative_rescaling = DEFAULT_CCD_CONSERVATIVE_RESCALING

[in] Conservative rescaling value used to avoid taking steps exactly to impact.

Returns:

If the candidate had a collision over the time interval.

virtual bool ccd(const VectorMax12dvertices_t0,
    
const VectorMax12dvertices_t1double& toi,
    
const double min_distance = 0.0const double tmax = 1.0,
    
const double tolerance = DEFAULT_CCD_TOLERANCE,
    
const long max_iterations = DEFAULT_CCD_MAX_ITERATIONS,
    
const double conservative_rescaling
    
= DEFAULT_CCD_CONSERVATIVE_RESCALING
) const
   
 = 0;

Public Members

long edge_id;

ID of the edge.

long vertex_id;

ID of the vertex.

Protected Functions

virtual double compute_distance(
    
const VectorMax12dpositions) const override;

Compute the distance of the stencil.

Parameters:
vertices

Stencil’s vertex positions.

Returns:

Distance of the stencil.

virtual VectorMax12d compute_distance_gradient(
    
const VectorMax12dpositions) const override;

Compute the distance gradient of the stencil w.r.t.

the stencil’s vertex positions.

Parameters:
vertices

Stencil’s vertex positions.

Returns:

Distance gradient of the stencil w.r.t. the stencil’s vertex positions.

virtual MatrixMax12d compute_distance_hessian(
    
const VectorMax12dpositions) const override;

Compute the distance Hessian of the stencil w.r.t.

the stencil’s vertex positions.

Parameters:
vertices

Stencil’s vertex positions.

Returns:

Distance Hessian of the stencil w.r.t. the stencil’s vertex positions.

virtual bool ccd(const VectorMax12dvertices_t0,
    
const VectorMax12dvertices_t1double& toi,
    
const double min_distance = 0.0const double tmax = 1.0,
    
const double tolerance = DEFAULT_CCD_TOLERANCE,
    
const long max_iterations = DEFAULT_CCD_MAX_ITERATIONS,
    
const double conservative_rescaling
    
= DEFAULT_CCD_CONSERVATIVE_RESCALING
) const override;
inline virtual PointEdgeDistanceType known_dtype() const;

Friends

template <typename H>
inline friend H AbslHashValue(H hconst EdgeVertexCandidateev);

Edge-Edge Candidate

class EdgeEdgeCandidate : public ipc::ContinuousCollisionCandidate;

Subclassed by ipc::EdgeEdgeConstraint, ipc::EdgeEdgeFrictionConstraint

Public Functions

EdgeEdgeCandidate(long edge0_idlong edge1_id);
inline virtual int num_vertices() const override;

Get the number of vertices in the contact stencil.

inline virtual std::array<long, 4> vertex_ids(
    
const Eigen::MatrixXiedges,
    
const Eigen::MatrixXifaces) const override;

Get the vertex IDs of the contact stencil.

Parameters:
const Eigen::MatrixXi &edges

Collision mesh edges

const Eigen::MatrixXi &faces

Collision mesh faces

Returns:

The vertex IDs of the contact stencil. Size is always 4, but elements i > num_vertices() are -1.

virtual void print_ccd_query(const Eigen::MatrixXdvertices_t0,
    
const Eigen::MatrixXdvertices_t1,
    
const Eigen::MatrixXiedges,
    
const Eigen::MatrixXifaces) const override;
bool operator==(const EdgeEdgeCandidateother) const;
bool operator!=(const EdgeEdgeCandidateother) const;
bool operator<(const EdgeEdgeCandidateother) const;

Compare EdgeEdgeCandidates for sorting.

double compute_distance(const Eigen::MatrixXdvertices,
    
const Eigen::MatrixXiedges,
    
const Eigen::MatrixXifaces) const;

Compute the distance of the stencil.

Parameters:
const Eigen::MatrixXd &vertices

Collision mesh vertex positions.

const Eigen::MatrixXi &edges

Collision mesh edges

const Eigen::MatrixXi &faces

Collision mesh faces

Returns:

Distance of the stencil.

virtual double compute_distance(const VectorMax12dvertices) const
   
 = 0;

Compute the distance of the stencil.

Parameters:
const VectorMax12d &vertices

Stencil’s vertex positions.

Returns:

Distance of the stencil.

VectorMax12d compute_distance_gradient(
    
const Eigen::MatrixXdverticesconst Eigen::MatrixXiedges,
    
const Eigen::MatrixXifaces) const;

Compute the distance gradient of the stencil w.r.t.

the stencil’s vertex positions.

Parameters:
const Eigen::MatrixXd &vertices

Collision mesh vertex positions.

const Eigen::MatrixXi &edges

Collision mesh edges

const Eigen::MatrixXi &faces

Collision mesh faces

Returns:

Distance gradient of the stencil w.r.t. the stencil’s vertex positions.

virtual VectorMax12d compute_distance_gradient(
    
const VectorMax12dvertices) const
   
 = 0;

Compute the distance gradient of the stencil w.r.t.

the stencil’s vertex positions.

Parameters:
const VectorMax12d &vertices

Stencil’s vertex positions.

Returns:

Distance gradient of the stencil w.r.t. the stencil’s vertex positions.

MatrixMax12d compute_distance_hessian(
    
const Eigen::MatrixXdverticesconst Eigen::MatrixXiedges,
    
const Eigen::MatrixXifaces) const;

Compute the distance Hessian of the stencil w.r.t.

the stencil’s vertex positions.

Parameters:
const Eigen::MatrixXd &vertices

Collision mesh vertex positions.

const Eigen::MatrixXi &edges

Collision mesh edges

const Eigen::MatrixXi &faces

Collision mesh faces

Returns:

Distance Hessian of the stencil w.r.t. the stencil’s vertex positions.

virtual MatrixMax12d compute_distance_hessian(
    
const VectorMax12dvertices) const
   
 = 0;

Compute the distance Hessian of the stencil w.r.t.

the stencil’s vertex positions.

Parameters:
const VectorMax12d &vertices

Stencil’s vertex positions.

Returns:

Distance Hessian of the stencil w.r.t. the stencil’s vertex positions.

bool ccd(const Eigen::MatrixXdvertices_t0,
    
const Eigen::MatrixXdvertices_t1,
    
const Eigen::MatrixXiedgesconst Eigen::MatrixXifaces,
    
double& toiconst double min_distance = 0.0,
    
const double tmax = 1.0,
    
const double tolerance = DEFAULT_CCD_TOLERANCE,
    
const long max_iterations = DEFAULT_CCD_MAX_ITERATIONS,
    
const double conservative_rescaling
    
= DEFAULT_CCD_CONSERVATIVE_RESCALING
) const;

Perform narrow-phase CCD on the candidate.

Parameters:
const Eigen::MatrixXd &vertices_t0

[in] Mesh vertices at the start of the time step.

const Eigen::MatrixXd &vertices_t1

[in] Mesh vertices at the end of the time step.

const Eigen::MatrixXi &edges

[in] Collision mesh edges as rows of indicies into vertices.

const Eigen::MatrixXi &faces

[in] Collision mesh triangular faces as rows of indicies into vertices.

double &toi

[out] Computed time of impact (normalized).

const double min_distance = 0.0

[in] Minimum separation distance between primitives.

const double tmax = 1.0

[in] Maximum time (normalized) to look for collisions. Should be in [0, 1].

const double tolerance = DEFAULT_CCD_TOLERANCE

[in] CCD tolerance used by Tight-Inclusion CCD.

const long max_iterations = DEFAULT_CCD_MAX_ITERATIONS

[in] Maximum iterations used by Tight-Inclusion CCD.

const double conservative_rescaling = DEFAULT_CCD_CONSERVATIVE_RESCALING

[in] Conservative rescaling value used to avoid taking steps exactly to impact.

Returns:

If the candidate had a collision over the time interval.

virtual bool ccd(const VectorMax12dvertices_t0,
    
const VectorMax12dvertices_t1double& toi,
    
const double min_distance = 0.0const double tmax = 1.0,
    
const double tolerance = DEFAULT_CCD_TOLERANCE,
    
const long max_iterations = DEFAULT_CCD_MAX_ITERATIONS,
    
const double conservative_rescaling
    
= DEFAULT_CCD_CONSERVATIVE_RESCALING
) const
   
 = 0;

Public Members

long edge0_id;

ID of the first edge.

long edge1_id;

ID of the second edge.

Protected Functions

virtual double compute_distance(
    
const VectorMax12dpositions) const override;

Compute the distance of the stencil.

Parameters:
vertices

Stencil’s vertex positions.

Returns:

Distance of the stencil.

virtual VectorMax12d compute_distance_gradient(
    
const VectorMax12dpositions) const override;

Compute the distance gradient of the stencil w.r.t.

the stencil’s vertex positions.

Parameters:
vertices

Stencil’s vertex positions.

Returns:

Distance gradient of the stencil w.r.t. the stencil’s vertex positions.

virtual MatrixMax12d compute_distance_hessian(
    
const VectorMax12dpositions) const override;

Compute the distance Hessian of the stencil w.r.t.

the stencil’s vertex positions.

Parameters:
vertices

Stencil’s vertex positions.

Returns:

Distance Hessian of the stencil w.r.t. the stencil’s vertex positions.

virtual bool ccd(const VectorMax12dvertices_t0,
    
const VectorMax12dvertices_t1double& toi,
    
const double min_distance = 0.0const double tmax = 1.0,
    
const double tolerance = DEFAULT_CCD_TOLERANCE,
    
const long max_iterations = DEFAULT_CCD_MAX_ITERATIONS,
    
const double conservative_rescaling
    
= DEFAULT_CCD_CONSERVATIVE_RESCALING
) const override;
inline virtual EdgeEdgeDistanceType known_dtype() const;

Friends

template <typename H>
inline friend H AbslHashValue(H hconst EdgeEdgeCandidateee);

Edge-Face Candidate

class EdgeFaceCandidate;

Candidate for intersection between edge and face.

Not included in Candidates because it is not a collision candidate.

Public Functions

EdgeFaceCandidate(long edge_idlong face_id);
bool operator==(const EdgeFaceCandidateother) const;
bool operator!=(const EdgeFaceCandidateother) const;
bool operator<(const EdgeFaceCandidateother) const;

Compare EdgeFaceCandidate for sorting.

Public Members

long edge_id;

ID of the edge.

long face_id;

ID of the face.

Friends

template <typename H>
inline friend H AbslHashValue(H hconst EdgeFaceCandidatefv);

Face-Vertex Candidate

class FaceVertexCandidate
   
 : public ipc::ContinuousCollisionCandidate;

Subclassed by ipc::FaceVertexConstraint, ipc::FaceVertexFrictionConstraint

Public Functions

FaceVertexCandidate(long face_idlong vertex_id);
inline virtual int num_vertices() const override;

Get the number of vertices in the contact stencil.

inline virtual std::array<long, 4> vertex_ids(
    
const Eigen::MatrixXiedges,
    
const Eigen::MatrixXifaces) const override;

Get the vertex IDs of the contact stencil.

Parameters:
const Eigen::MatrixXi &edges

Collision mesh edges

const Eigen::MatrixXi &faces

Collision mesh faces

Returns:

The vertex IDs of the contact stencil. Size is always 4, but elements i > num_vertices() are -1.

virtual void print_ccd_query(const Eigen::MatrixXdvertices_t0,
    
const Eigen::MatrixXdvertices_t1,
    
const Eigen::MatrixXiedges,
    
const Eigen::MatrixXifaces) const override;
bool operator==(const FaceVertexCandidateother) const;
bool operator!=(const FaceVertexCandidateother) const;
bool operator<(const FaceVertexCandidateother) const;

Compare FaceVertexCandidate for sorting.

double compute_distance(const Eigen::MatrixXdvertices,
    
const Eigen::MatrixXiedges,
    
const Eigen::MatrixXifaces) const;

Compute the distance of the stencil.

Parameters:
const Eigen::MatrixXd &vertices

Collision mesh vertex positions.

const Eigen::MatrixXi &edges

Collision mesh edges

const Eigen::MatrixXi &faces

Collision mesh faces

Returns:

Distance of the stencil.

virtual double compute_distance(const VectorMax12dvertices) const
   
 = 0;

Compute the distance of the stencil.

Parameters:
const VectorMax12d &vertices

Stencil’s vertex positions.

Returns:

Distance of the stencil.

VectorMax12d compute_distance_gradient(
    
const Eigen::MatrixXdverticesconst Eigen::MatrixXiedges,
    
const Eigen::MatrixXifaces) const;

Compute the distance gradient of the stencil w.r.t.

the stencil’s vertex positions.

Parameters:
const Eigen::MatrixXd &vertices

Collision mesh vertex positions.

const Eigen::MatrixXi &edges

Collision mesh edges

const Eigen::MatrixXi &faces

Collision mesh faces

Returns:

Distance gradient of the stencil w.r.t. the stencil’s vertex positions.

virtual VectorMax12d compute_distance_gradient(
    
const VectorMax12dvertices) const
   
 = 0;

Compute the distance gradient of the stencil w.r.t.

the stencil’s vertex positions.

Parameters:
const VectorMax12d &vertices

Stencil’s vertex positions.

Returns:

Distance gradient of the stencil w.r.t. the stencil’s vertex positions.

MatrixMax12d compute_distance_hessian(
    
const Eigen::MatrixXdverticesconst Eigen::MatrixXiedges,
    
const Eigen::MatrixXifaces) const;

Compute the distance Hessian of the stencil w.r.t.

the stencil’s vertex positions.

Parameters:
const Eigen::MatrixXd &vertices

Collision mesh vertex positions.

const Eigen::MatrixXi &edges

Collision mesh edges

const Eigen::MatrixXi &faces

Collision mesh faces

Returns:

Distance Hessian of the stencil w.r.t. the stencil’s vertex positions.

virtual MatrixMax12d compute_distance_hessian(
    
const VectorMax12dvertices) const
   
 = 0;

Compute the distance Hessian of the stencil w.r.t.

the stencil’s vertex positions.

Parameters:
const VectorMax12d &vertices

Stencil’s vertex positions.

Returns:

Distance Hessian of the stencil w.r.t. the stencil’s vertex positions.

bool ccd(const Eigen::MatrixXdvertices_t0,
    
const Eigen::MatrixXdvertices_t1,
    
const Eigen::MatrixXiedgesconst Eigen::MatrixXifaces,
    
double& toiconst double min_distance = 0.0,
    
const double tmax = 1.0,
    
const double tolerance = DEFAULT_CCD_TOLERANCE,
    
const long max_iterations = DEFAULT_CCD_MAX_ITERATIONS,
    
const double conservative_rescaling
    
= DEFAULT_CCD_CONSERVATIVE_RESCALING
) const;

Perform narrow-phase CCD on the candidate.

Parameters:
const Eigen::MatrixXd &vertices_t0

[in] Mesh vertices at the start of the time step.

const Eigen::MatrixXd &vertices_t1

[in] Mesh vertices at the end of the time step.

const Eigen::MatrixXi &edges

[in] Collision mesh edges as rows of indicies into vertices.

const Eigen::MatrixXi &faces

[in] Collision mesh triangular faces as rows of indicies into vertices.

double &toi

[out] Computed time of impact (normalized).

const double min_distance = 0.0

[in] Minimum separation distance between primitives.

const double tmax = 1.0

[in] Maximum time (normalized) to look for collisions. Should be in [0, 1].

const double tolerance = DEFAULT_CCD_TOLERANCE

[in] CCD tolerance used by Tight-Inclusion CCD.

const long max_iterations = DEFAULT_CCD_MAX_ITERATIONS

[in] Maximum iterations used by Tight-Inclusion CCD.

const double conservative_rescaling = DEFAULT_CCD_CONSERVATIVE_RESCALING

[in] Conservative rescaling value used to avoid taking steps exactly to impact.

Returns:

If the candidate had a collision over the time interval.

virtual bool ccd(const VectorMax12dvertices_t0,
    
const VectorMax12dvertices_t1double& toi,
    
const double min_distance = 0.0const double tmax = 1.0,
    
const double tolerance = DEFAULT_CCD_TOLERANCE,
    
const long max_iterations = DEFAULT_CCD_MAX_ITERATIONS,
    
const double conservative_rescaling
    
= DEFAULT_CCD_CONSERVATIVE_RESCALING
) const
   
 = 0;

Public Members

long face_id;

ID of the face.

long vertex_id;

ID of the vertex.

Protected Functions

virtual double compute_distance(
    
const VectorMax12dpositions) const override;

Compute the distance of the stencil.

Parameters:
vertices

Stencil’s vertex positions.

Returns:

Distance of the stencil.

virtual VectorMax12d compute_distance_gradient(
    
const VectorMax12dpositions) const override;

Compute the distance gradient of the stencil w.r.t.

the stencil’s vertex positions.

Parameters:
vertices

Stencil’s vertex positions.

Returns:

Distance gradient of the stencil w.r.t. the stencil’s vertex positions.

virtual MatrixMax12d compute_distance_hessian(
    
const VectorMax12dpositions) const override;

Compute the distance Hessian of the stencil w.r.t.

the stencil’s vertex positions.

Parameters:
vertices

Stencil’s vertex positions.

Returns:

Distance Hessian of the stencil w.r.t. the stencil’s vertex positions.

virtual bool ccd(const VectorMax12dvertices_t0,
    
const VectorMax12dvertices_t1double& toi,
    
const double min_distance = 0.0const double tmax = 1.0,
    
const double tolerance = DEFAULT_CCD_TOLERANCE,
    
const long max_iterations = DEFAULT_CCD_MAX_ITERATIONS,
    
const double conservative_rescaling
    
= DEFAULT_CCD_CONSERVATIVE_RESCALING
) const override;
inline virtual PointTriangleDistanceType known_dtype() const;

Friends

template <typename H>
inline friend H AbslHashValue(H hconst FaceVertexCandidatefv);