# ssapy_toolkit/Accelerations/accel_plane.py
import numpy as np
[docs]
def accel_plane(r, v, magnitude):
"""
Tangential acceleration in the orbital plane, perpendicular to rĖ.
Parameters
----------
r : array_like, shape (3,)
Position vector in meters.
v : array_like, shape (3,)
Velocity vector in meters per second.
magnitude : float
Desired acceleration magnitude in m/s^2.
Positive â along the direction of motion;
negative â opposite direction.
Returns
-------
a : ndarray, shape (3,)
Tangential acceleration vector in m/s^2.
"""
r = np.asarray(r, dtype=float).reshape(3)
v = np.asarray(v, dtype=float).reshape(3)
if magnitude == 0:
return np.zeros(3, dtype=float)
norm_r = np.linalg.norm(r)
if norm_r == 0:
return np.zeros(3, dtype=float)
r_hat = r / norm_r
# Remove radial component of v to get purely tangential direction
tangential = v - np.dot(v, r_hat) * r_hat
norm_tan = np.linalg.norm(tangential)
if norm_tan == 0:
return np.zeros(3, dtype=float)
return float(magnitude) * tangential / norm_tan