Skip to content

Trigonometrics¤

Trigonometric functions.

acos_with_shift(x, shift=None) ¤

Arccos with shift.

Source code in hamilflow/maths/trigonometrics.py
13
14
15
16
17
18
19
20
21
22
23
24
25
def acos_with_shift(
    x: "Collection[float] | npt.ArrayLike",
    shift: "Collection[float] | npt.ArrayLike | None" = None,
) -> "npt.ArrayLike":
    """Arccos with shift."""
    x = np.asarray(x)
    value = np.arccos(x)
    shift = np.asarray(shift)
    period_shift = (div := np.floor(shift)) * 2 * np.pi
    remainder = shift - div
    value = np.where(remainder <= 0.5, value, 2 * np.pi - value)  # noqa: PLR2004

    return period_shift + value