import math
class Vetor3D:
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
def magnitude(self):
return math.sqrt(self.x * self.x + self.y * self.y + self.z * self.z)
def produto_escalar(a, b):
return a.x * b.x + a.y * b.y + a.z * b.z
def angulo(a, b):
ta = a.magnitude()
tb = b.magnitude()
if ta == 0.0 or tb == 0.0:
return 0.0
return math.degrees(math.acos(produto_escalar(a, b) / ta / tb))
# Teste
a = Vetor3D(1, 0, 0)
b = Vetor3D(0, 1, 0)
print(angulo(a, b))
aW1wb3J0IG1hdGgKCmNsYXNzIFZldG9yM0Q6CgogICAgZGVmIF9faW5pdF9fKHNlbGYsIHgsIHksIHopOgogICAgICAgIHNlbGYueCA9IHgKICAgICAgICBzZWxmLnkgPSB5CiAgICAgICAgc2VsZi56ID0gegoKICAgIGRlZiBtYWduaXR1ZGUoc2VsZik6CiAgICAgICAgcmV0dXJuIG1hdGguc3FydChzZWxmLnggKiBzZWxmLnggKyBzZWxmLnkgKiBzZWxmLnkgKyBzZWxmLnogKiBzZWxmLnopCgpkZWYgcHJvZHV0b19lc2NhbGFyKGEsIGIpOgogICAgcmV0dXJuIGEueCAqIGIueCArIGEueSAqIGIueSArIGEueiAqIGIuegoKZGVmIGFuZ3VsbyhhLCBiKToKICAgIHRhID0gYS5tYWduaXR1ZGUoKQogICAgdGIgPSBiLm1hZ25pdHVkZSgpCiAgICBpZiB0YSA9PSAwLjAgb3IgdGIgPT0gMC4wOgogICAgICAgIHJldHVybiAwLjAKICAgIHJldHVybiBtYXRoLmRlZ3JlZXMobWF0aC5hY29zKHByb2R1dG9fZXNjYWxhcihhLCBiKSAvIHRhIC8gdGIpKQoKIyBUZXN0ZQphID0gVmV0b3IzRCgxLCAwLCAwKQpiID0gVmV0b3IzRCgwLCAxLCAwKQpwcmludChhbmd1bG8oYSwgYikpCg==