Reputation: 9
i am trying to find out dihedral between two planes i have all the coordinates and i calculated vectors but the last step is giving problem, my last step is to find the angle between the vectors. here is my code
V1= (x2-x1,y2-y1,z2-z1)
V2= (x3-x2,y3-y2,z3-z2)
V3= (x4-x3,y4-y3,z4-z3)
V4= numpy.cross(V1,V2)
V5= numpy.cross(V2,V3)
dihedral=math.acos(V4.V5)
print dihedral
please tell me if this is right? i know coordinates for 4 points from which i made 3 vectors V1, V2, V3 and then i did cross product to get 2 vectors , now i want to find angle between these vectors.
Upvotes: 0
Views: 6176
Reputation: 3254
Using cross products of vectors to calculate angles will only work if the vectors have unit length. You should normalize them first, e.g.
V4 = V4/np.sqrt(np.dot(V4,V4))
Furthermore, I think you meant to write math.acos(np.dot(V4,V5))
for math.acos(V4.V5)
.
Upvotes: 2