Class ContactForceManager#

Inheritance Relationships#

Base Type#

Class Documentation#

class ContactForceManager : public Karana::Collision::ContactForceBase#

A ContactForceBase that delegates based on the Frame pair.

See Collision dynamics for more discussion on contact and collision dynamics.

Public Functions

ContactForceManager(std::string_view name)#

ContactForceManager constructor. The constructor is not meant to be called directly. Please use the create(…) method instead to create an instance.

Parameters:

name – - The name of the ContactForceManager.

virtual ~ContactForceManager()#

ContactForceManager destructor.

virtual Karana::Math::SpatialVector computeForce(const FrameContact &contact, const Karana::Core::ks_ptr<Karana::Dynamics::Node> &nd_1, const Karana::Core::ks_ptr<Karana::Dynamics::Node> &nd_2) override#

Compute the contact force for the associated contact.

This looks up the most specific delegate ContactForceBase for the given frame pair and returns the force computed by the delegate. If there is no default delegate or specific delegate for this pair, returns zero.

Parameters:
  • contact – The contact to compute the force for.

  • nd_1 – The contact node on the first body.

  • nd_2 – The contact node on the second body.

Returns:

The contact force.

const Karana::Core::ks_ptr<ContactForceBase> &getDelegate(const FrameContact &contact) const#

Get the most specific matching ContactForceBase.

Parameters:

contact – The contact to get the delegate for.

Returns:

The ContactForceBase (may be nullptr)

const Karana::Core::ks_ptr<ContactForceBase> &getDelegate() const#

Get the ContactForceBase used by default.

Returns:

The ContactForceBase used by default (may be nullptr)

void setDelegate(const Karana::Core::ks_ptr<ContactForceBase> &force = nullptr)#

Set the ContactForceBase used by default.

Parameters:

force – The ContactForceBase (may be nullptr)

const Karana::Core::ks_ptr<ContactForceBase> &getDelegate(const Karana::Frame::Frame &frame1, const Karana::Frame::Frame &frame2, bool strict = false) const#

Get the ContactForceBase used for a Frame pair.

Note the ordering of frame1 and frame2 does not matter.

Parameters:
  • frame1 – A frame that must be involved

  • frame2 – Another frame that must be involved

  • strict – If false and there’s no delegate for this pair, return the default delegate.

Returns:

The ContactForceBase (may be nullptr)

void setDelegate(const Karana::Frame::Frame &frame1, const Karana::Frame::Frame &frame2, const Karana::Core::ks_ptr<ContactForceBase> &force = nullptr)#

Set the ContactForceBase used for a Frame pair.

Note the ordering of frame1 and frame2 does not matter.

Parameters:
  • frame1 – A frame that must be involved

  • frame2 – Another frame that must be involved

  • force – The ContactForceBase (may be nullptr)

void clearDelegates()#

Clear out all registered ContactForceBase instances.

Public Static Functions

static Karana::Core::ks_ptr<ContactForceManager> create(std::string_view name)#

Create an instance of ContactForceManager.

Parameters:

name – The name for the ContactForceManager instance.

Returns:

A ks_ptr to the newly created ContactForceManager.