jaredec18

Untitled

Sep 15th, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. import math
  2. #input point of observer
  3. x0,y0,z0=raw_input("enter coordinate separated by commas -> ").split(",")
  4. x0,y0,z0=[float(x0),float(y0),float(z0)]
  5.  
  6. #input point observed
  7.  
  8. x1,y1,z1=raw_input("enter coordinate of first point separated by commas -> ").split(",")
  9. x1,y1,z1=[float(x1),float(y1),float(z1)]
  10.  
  11. x2,y2,z2=raw_input("enter coordinate of second point separated by commas -> ").split(",")
  12. x2,y2,z2=[float(x2),float(y2),float(z2)]
  13.  
  14. vec1=[x1-x0,y1-y0,z1-z0]
  15. vec2=[x2-x0,y2-y0,z2-z0]
  16.  
  17. #dot product of vector
  18. num= sum([vec1[i]*vec2[i] for i in range(3)])
  19.  
  20. deno=math.sqrt(sum([vec1[i]*vec1[i] for i in range(3)])) * math.sqrt(sum([vec2[i]*vec2[i] for i in range(3)]))
  21.  
  22. angle=round(math.degrees(math.acos(num/deno)),2)
  23.  
  24. print angle
  25. Pastebin link to program
  26.  
  27. https://pastebin.com/TpS4qErN
Advertisement
Add Comment
Please, Sign In to add comment