Created
October 15, 2024 23:21
-
-
Save HajimeKawahara/3cf3da47ce014f4417ed56088ec699a5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def normalized_angle(theta): | |
return theta - 2 * np.pi * np.round(theta / (2 * np.pi)) | |
def normalized_angle2(theta): | |
return np.arctan2(np.sin(theta), np.cos(theta)) | |
if __name__ == "__main__": | |
theta = np.array([-1.8, -1.2, 0.5, 1.2, 1.8])*np.pi | |
print(normalized_angle(theta)) | |
print(normalized_angle2(theta)) | |
#shirochan:~/microjax_algo>python temp.py | |
#[ 0.62831853 2.51327412 1.57079633 -2.51327412 -0.62831853] | |
#[ 0.62831853 2.51327412 1.57079633 -2.51327412 -0.62831853] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment