updade from Atlas repo

This commit is contained in:
Luciano Ramalho
2021-05-21 18:56:12 -03:00
parent c518bf851e
commit 8a330d822b
120 changed files with 2190 additions and 1184 deletions

View File

@@ -264,7 +264,7 @@ class Vector:
def __repr__(self):
components = reprlib.repr(self._components)
components = components[components.find('['):-1]
return 'Vector({})'.format(components)
return f'Vector({components})'
def __str__(self):
return str(tuple(self))
@@ -283,7 +283,7 @@ class Vector:
# tag::VECTOR_V6_UNARY[]
def __abs__(self):
return math.sqrt(sum(x * x for x in self))
return math.hypot(*self)
def __neg__(self):
return Vector(-x for x in self) # <1>
@@ -313,11 +313,11 @@ class Vector:
pos = cls.shortcut_names.find(name)
if 0 <= pos < len(self._components):
return self._components[pos]
msg = '{.__name__!r} object has no attribute {!r}'
raise AttributeError(msg.format(cls, name))
msg = f'{cls.__name__!r} object has no attribute {name!r}'
raise AttributeError(msg)
def angle(self, n):
r = math.sqrt(sum(x * x for x in self[n:]))
r = math.hypot(*self[n:])
a = math.atan2(r, self[n-1])
if (n == len(self) - 1) and (self[-1] < 0):
return math.pi * 2 - a