def hit_object_angles(hit_objects, *, double_time=False, half_time=False):
"""Compute the angle from one hit object to the next in 3d space with time
along the Z axis.
Parameters
----------
hit_objects : iterable[HitObject]
The hit objects to compute the angles about.
double_time : bool, optional
Apply double time compression to the Z axis.
half_time : bool, optional
Apply half time expansion to the Z axis.
Returns
-------
angles : ndarray[float]
An array shape (3, len(hit_objects) - 1) of pitch, roll, and yaw
between each hit object. All angles are measured in radians.
"""
coords = hit_object_coordinates(
hit_objects,
double_time=double_time,
half_time=half_time,
)
diff = np.diff(coords, axis=1)
# (pitch, roll, yaw) x transitions
out = np.empty((3, len(hit_objects) - 1), dtype=np.float64)
np.arctan2(diff[Axis.y], diff[Axis.z], out=out[Angle.pitch])
np.arctan2(diff[Axis.y], diff[Axis.x], out=out[Angle.roll])
np.arctan2(diff[Axis.z], diff[Axis.x], out=out[Angle.yaw])
return out
评论列表
文章目录