JointBiomechanics#

class JointBiomechanics(
joint_type: Literal['hinge', 'ball_socket'],
joint_geometry: JointGeometry,
muscle_geometries: list[MuscleGeometry],
moment_arm_data__cm: ]] | None = None,
use_simplified_model: bool = True,
) None[source]#

Bases: object

Joint biomechanics with muscle moment arms and length calculations.

This class computes the relationship between joint angles and muscle lengths, moment arms, and resulting joint torques. It supports both simple geometric models and more complex biomechanical relationships.

Parameters:
  • joint_type ({"hinge", "ball_socket"}) – Type of joint for biomechanical calculations. “hinge” = single degree of freedom (e.g., elbow, knee) “ball_socket” = multi-degree of freedom (e.g., shoulder, hip)

  • joint_geometry (JointGeometry) – Geometric parameters of the joint.

  • muscle_geometries (list[MuscleGeometry]) – List of muscle geometry parameters for muscles crossing this joint.

  • moment_arm_data__cm (MOMENT_ARM__MATRIX, optional) – Pre-computed moment arm data as function of joint angle. If None, computed from geometry. Shape: (n_angles, n_muscles).

  • use_simplified_model (bool, default=True) – Whether to use simplified geometric model or detailed biomechanics.

n_muscles#

Number of muscles crossing this joint.

Type:

int

joint_angles__deg#

Array of joint angles for moment arm calculations.

Type:

np.ndarray

moment_arms__cm#

Moment arms for each muscle at each joint angle.

Type:

np.ndarray

Methods

__init__

compute_joint_torque

Compute net joint torque from muscle forces.

compute_muscle_length

Compute muscle length from joint angle.

get_biomechanical_summary

Get summary of biomechanical parameters.

get_moment_arm

Get moment arm for a muscle at a specific joint angle.

get_muscle_length_trajectory

Compute muscle length trajectory from joint angle trajectory.

compute_muscle_length(
joint_angle__deg: float,
muscle_index: int,
) float[source]#

Compute muscle length from joint angle.

Parameters:
  • joint_angle__deg (float) – Joint angle in degrees.

  • muscle_index (int) – Index of the muscle (0 to n_muscles-1).

Returns:

Muscle length in cm.

Return type:

float

Raises:

ValueError – If muscle_index is out of range.

get_moment_arm(joint_angle__deg: float, muscle_index: int) float[source]#

Get moment arm for a muscle at a specific joint angle.

Parameters:
  • joint_angle__deg (float) – Joint angle in degrees.

  • muscle_index (int) – Index of the muscle.

Returns:

Moment arm in cm.

Return type:

float

compute_joint_torque(
muscle_forces__N: float | ndarray,
joint_angle__deg: float,
) float[source]#

Compute net joint torque from muscle forces.

Parameters:
  • muscle_forces__N (float or np.ndarray) – Forces from each muscle in Newtons. If float, assumes single muscle. If array, must have length equal to n_muscles.

  • joint_angle__deg (float) – Current joint angle in degrees.

Returns:

Net joint torque in N⋅cm.

Return type:

float

Notes

Positive torque indicates rotation in the positive joint angle direction.

get_muscle_length_trajectory(
joint_angle_trajectory__degrees: ]],
muscle_index: int,
) ndarray[source]#

Compute muscle length trajectory from joint angle trajectory.

Parameters:
  • joint_angle_trajectory__degrees (JOINT_ANGLE__ARRAY) – Array of joint angles over time.

  • muscle_index (int) – Index of the muscle.

Returns:

Muscle length trajectory in cm.

Return type:

np.ndarray

get_biomechanical_summary() dict[source]#

Get summary of biomechanical parameters.

Returns:

Dictionary containing key biomechanical parameters.

Return type:

dict