Class NonlinearContactForce#

Nested Relationships#

Nested Types#

Inheritance Relationships#

Base Type#

Class Documentation#

class NonlinearContactForce : public Karana::Collision::ContactForceBase#

Nonlinear penalty contact force with smoothly regularized damping and friction.

With penetration \(\delta\), signed closing speed \(v_n\), stiffness \(k_p\), exponent \(n\), damping \(k_c\), and full-damping depth \(d_{\max}\), the normal force magnitude is

\[F_n=\max\left(0,k_p\delta^n+k_c\,S(\delta/d_{\max})v_n\right). \]
By default, \(S(a)=a^2(3-2a)\) with \(a\) clipped to \([0,1]\). Tangential friction follows a cubic, velocity-regularized Coulomb curve. Its magnitude rises smoothly from zero to \(\mu_s F_n\) at the stiction-transition speed \(v_s\), falls smoothly to \(\mu_d F_n\) at the friction-transition speed \(v_d\), and remains on that dynamic plateau thereafter.

The damping and friction transitions use a cubic polynomial approximation to a step function.

Public Functions

virtual km::SpatialForce computeForce(const FrameContact &contact, const kc::ks_ptr<kd::Node> &nd_1, const kc::ks_ptr<kd::Node> &nd_2) final#

Compute the force on contact object 1.

Parameters:
  • contact – Collision-native contact geometry.

  • nd_1 – Contact node on object 1.

  • nd_2 – Contact node on object 2.

Returns:

Spatial force on object 1 expressed in frame 1.

virtual bool isReady() const final#

Validate the model parameters.

Returns:

True when all parameters are usable.

virtual std::string dumpString(std::string_view prefix, const kc::Base::DumpOptions *options = nullptr) const override#

Return model parameters and latest scratch values.

Parameters:
  • prefix – Prefix applied to each output line.

  • options – Dump options.

Returns:

Formatted diagnostic text.

Public Members

NonlinearContactForceParams params#

Contact-law parameters.

NonlinearContactForceScratch scratch#

Latest computed contact values.

Public Static Functions

static kc::ks_ptr<NonlinearContactForce> create(std::string_view name)#

Create a nonlinear contact-force model.

Parameters:

name – Object name.

Returns:

Newly allocated model.

struct NonlinearContactForceParams#

Parameters used by the nonlinear contact-force model.

Public Members

double kp = km::notReadyNaN#

Penalty stiffness in N/m^n.

double kc = km::notReadyNaN#

Maximum normal damping coefficient in N s/m.

double n = km::notReadyNaN#

Positive penetration exponent.

std::optional<double> mu_static = std::nullopt#

Static coefficient, or nullopt to use mu_dynamic.

double mu_dynamic = km::notReadyNaN#

Dynamic friction coefficient.

double damping_ramp_depth = km::notReadyNaN#

Penetration at full damping in meters.

double stiction_transition_speed = km::notReadyNaN#

Slip speed of the static-friction peak in m/s.

double friction_transition_speed = km::notReadyNaN#

Slip speed at the end of the friction transition in m/s.

struct NonlinearContactForceScratch#

Scratch data populated by the latest force computation.

Public Members

double penetration = km::notReadyNaN#

Positive penetration depth in meters.

km::Vec3 linvel#

Relative contact-point velocity expressed in frame 1.

km::Vec3 f#

Total force on object 1 expressed in frame 1.