myogen.simulator.IntramuscularElectrodeArray.rodrigues_rot#

IntramuscularElectrodeArray.rodrigues_rot(v, k, theta)[source]#

Apply Rodrigues rotation to vectors around an arbitrary axis.

This method implements 3D rotation of points or vectors around an arbitrary axis using the Rodrigues rotation formula. It is used internally for electrode array positioning and trajectory calculations.

Mathematical Foundation: Based on Rodrigues’ rotation formula for rotating a vector v around axis k by angle theta: v_rot = v*cos(θ) + (k×v)*sin(θ) + k*(k·v)*(1-cos(θ))

Parameters:
  • v (array_like) – Vector(s) to rotate. Can be single vector (3,) or array of vectors (N, 3).

  • k (array_like) – Rotation axis vector (3,). Will be normalized internally.

  • theta (float) – Rotation angle in radians. Positive angles follow right-hand rule.

Returns:

Rotated vector(s) with same shape as input v.

Return type:

numpy.ndarray

Notes

Uses scipy.spatial.transform.Rotation for numerical stability and efficiency. The rotation axis k is automatically normalized to unit length.

Examples

>>> # Rotate point 90° around z-axis
>>> point = np.array([1.0, 0.0, 0.0])
>>> rotated = array.rodrigues_rot(point, [0, 0, 1], np.pi/2)
>>> # Result: approximately [0, 1, 0]