Skip to content

Conversation

@HueCodes
Copy link

Closes #685

Fresh implementation since #826 has merge conflicts.

Adds CoefficientCombineRule::GeometricMean which computes sqrt(coeff1 * coeff2).

This provides a more physically realistic way to combine friction/restitution coefficients:

  • For values 0.1 and 0.9: Average gives 0.5, GeometricMean gives 0.3
  • If one value is 0 (perfectly inelastic), result is 0 (not a bounce)
  • Equal values unchanged: sqrt(0.8 × 0.8) = 0.8

Uses .abs() before sqrt to handle negative coefficients defensively (consistent with Min rule).

Includes unit tests for basic usage, edge cases (zero, negative, same values), priority, and ordering.

Add CoefficientCombineRule::GeometricMean which computes sqrt(coeff1 * coeff2).

This provides a more physically realistic way to combine friction/restitution
coefficients, commonly used in physics engines like Box2D.

Uses .abs() before sqrt to handle negative coefficients defensively,
consistent with the Min rule's handling.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adding CoefficientCombineRule of GeometricMean

1 participant