0

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.

Sana Saeed
  • 9
  • 1
  • 2
  • 2
    Possible duplicate of [Angles between two n-dimensional vectors in Python](http://stackoverflow.com/questions/2827393/angles-between-two-n-dimensional-vectors-in-python) – Natecat May 17 '16 at 02:18
  • What do your 4 points represent? – Eric May 17 '16 at 02:26
  • Have you tested it with known values? Show an example with numbers that works (or does not work). – hpaulj May 17 '16 at 02:31

1 Answers1

2

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).

Han-Kwang Nienhuys
  • 3,084
  • 2
  • 12
  • 31