Potential

template <class TCollisionsclass Potential;

Base class for potentials.

Template Parameters:
class TCollisions

The type of the collisions.

Public Functions

Potential() = default;
virtual ~Potential() = default;
double operator()(const TCollisionscollisions,
    
const CollisionMeshmesh,
    
Eigen::ConstRef<Eigen::MatrixXd> X) const;

Compute the potential for a set of collisions.

Parameters:
const TCollisions &collisions

The set of collisions.

const CollisionMesh &mesh

The collision mesh.

Eigen::ConstRef<Eigen::MatrixXd> X

Degrees of freedom of the collision mesh (e.g., vertices or velocities).

Returns:

The potential for a set of collisions.

Eigen::VectorXd gradient(const TCollisionscollisions,
    
const CollisionMeshmesh,
    
Eigen::ConstRef<Eigen::MatrixXd> X) const;

Compute the gradient of the potential.

Parameters:
const TCollisions &collisions

The set of collisions.

const CollisionMesh &mesh

The collision mesh.

Eigen::ConstRef<Eigen::MatrixXd> X

Degrees of freedom of the collision mesh (e.g., vertices or velocities).

Returns:

The gradient of the potential w.r.t. X. This will have a size of |X|.

Eigen::SparseMatrix<double> hessian(const TCollisionscollisions,
    
const CollisionMeshmeshEigen::ConstRef<Eigen::MatrixXd> X,
    
const PSDProjectionMethod project_hessian_to_psd
    
= PSDProjectionMethod::NONE
) const;

Compute the hessian of the potential.

Parameters:
const TCollisions &collisions

The set of collisions.

const CollisionMesh &mesh

The collision mesh.

Eigen::ConstRef<Eigen::MatrixXd> X

Degrees of freedom of the collision mesh (e.g., vertices or velocities).

const PSDProjectionMethod project_hessian_to_psd = PSDProjectionMethod::NONE

Make sure the hessian is positive semi-definite.

Returns:

The Hessian of the potential w.r.t. X. This will have a size of |X|×|X|.

virtual double operator()(const TCollisioncollision,
    
Eigen::ConstRef<VectorMax12d> x) const
   
 = 0;

Compute the potential for a single collision.

Parameters:
const TCollision &collision

The collision.

Eigen::ConstRef<VectorMax12d> x

The collision stencil’s degrees of freedom.

Returns:

The potential.

virtual VectorMax12d gradient(const TCollisioncollision,
    
Eigen::ConstRef<VectorMax12d> x) const
   
 = 0;

Compute the gradient of the potential for a single collision.

Parameters:
const TCollision &collision

The collision.

Eigen::ConstRef<VectorMax12d> x

The collision stencil’s degrees of freedom.

Returns:

The gradient of the potential.

virtual MatrixMax12d hessian(const TCollisioncollision,
    
Eigen::ConstRef<VectorMax12d> x,
    
const PSDProjectionMethod project_hessian_to_psd
    
= PSDProjectionMethod::NONE
) const
   
 = 0;

Compute the hessian of the potential for a single collision.

Parameters:
const TCollision &collision

The collision.

Eigen::ConstRef<VectorMax12d> x

The collision stencil’s degrees of freedom.

const PSDProjectionMethod project_hessian_to_psd = PSDProjectionMethod::NONE

Whether to project the hessian to the positive semi-definite cone.

Returns:

The hessian of the potential.

Protected Types

using TCollision = typename TCollisions::value_type;