Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- #input point of observer
- x0,y0,z0=raw_input("enter coordinate separated by commas -> ").split(",")
- x0,y0,z0=[float(x0),float(y0),float(z0)]
- #input point observed
- x1,y1,z1=raw_input("enter coordinate of first point separated by commas -> ").split(",")
- x1,y1,z1=[float(x1),float(y1),float(z1)]
- x2,y2,z2=raw_input("enter coordinate of second point separated by commas -> ").split(",")
- x2,y2,z2=[float(x2),float(y2),float(z2)]
- vec1=[x1-x0,y1-y0,z1-z0]
- vec2=[x2-x0,y2-y0,z2-z0]
- #dot product of vector
- num= sum([vec1[i]*vec2[i] for i in range(3)])
- 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)]))
- angle=round(math.degrees(math.acos(num/deno)),2)
- print angle
- Pastebin link to program
- https://pastebin.com/TpS4qErN
Advertisement
Add Comment
Please, Sign In to add comment