First, do the following:
Write a function that calculates the angle between the vector x and the vector y.
import numpy as np
default(x,y):
dot_xy=np.dot(x,y)
norm_x = np.linalg.norm(x)
norm_y = np.linalg.norm(y)
cos=dot_xy/(normal_x*normal_y)
rad=np.arccos(cos)
theta=rad*180/np.pi
return theta
Then use this function to
Calculate the angle of vector x and vector y below.
x=np.array([1,0,1])
y = np.array ([1,1,1])
print angle(x,y)
This result, of course, is 45.0.
Now calculate the angle between the vector x above and the vector z below.
z=np.array([1,-1,1])
print angle(x,z)
Of course, 45.0 will be output at the same angle as above.
But here,
When calculated by x and y, use
positive direction.
I would like to print 315.0 instead of 45.0 for the angle of x and z.
What should I do with numpy?
Can you calculate the angle by fixing the direction of the vector?
Thank you for your cooperation.
python numpy
As you commented, it was a problem that could be solved by determining the code.
Sorry for the trouble.Thank you.
© 2024 OneMinuteCode. All rights reserved.