Files
Masterprojekt/utils_angle.py
2026-02-11 12:08:46 +01:00

55 lines
1.2 KiB
Python

import numpy as np
import winkelumrechnungen as wu
def arccot(x: float) -> float:
"""
Berechnung von arccot eines Winkels
:param x: Winkel
:return: arccot(Winkel)
"""
return np.arctan2(1.0, x)
def cot(x: float) -> float:
"""
Berechnung von cot eines Winkels
:param x: Winkel
:return: cot(Winkel)
"""
return np.cos(x) / np.sin(x)
def wrap_mpi_pi(x: float) -> float:
"""
Wrap eines Winkels in den Wertebereich [-π, π)
:param x: Winkel
:return: Winkel in [-π, π)
"""
return (x + np.pi) % (2 * np.pi) - np.pi
def wrap_mhalfpi_halfpi(x: float) -> float:
"""
Wrap eines Winkels in den Wertebereich [-π/2, π/2)
:param x: Winkel
:return: Winkel in [-π/2, π/2)
"""
return (x + np.pi / 2) % np.pi - np.pi / 2
def wrap_0_2pi(x: float) -> float:
"""
Wrap eines Winkels in den Wertebereich [0, 2π)
:param x: Winkel
:return: Winkel in [0, 2π)
"""
return x % (2 * np.pi)
if __name__ == "__main__":
print(wu.rad2deg(wrap_mhalfpi_halfpi(wu.deg2rad(181))))
print(wu.rad2deg(wrap_0_2pi(wu.deg2rad(181))))
print(wu.rad2deg(wrap_mpi_pi(wu.deg2rad(181))))