This is the first release of ppb-vector
where we commit to API stability. 🎉
This is also the first stable release since v0.3, about a year and a half ago, and a lot changed since then.
There were no changes since v1.0b1.
What's new since v0.3!
- Vectors are now 3× smaller and most methods saw a speedup between 30% and 50%. (#115)
This is thanks to using__slots__
to reserve space for the coordinates. - There's a reference documentation for the API, available in your favorite IDE, and on Read The Docs. (#130)
- There are annotations for type-checkers such as
mypy
. - We added a bunch of new methods:
angle
, for computing the angle between 2 vectors; (#57, #68)
it uses a numerically-stable formula (based onmath.atan2
) to guarantee adequate behaviour;isclose
, for checking whether 2 vectors are approximately equal; (#62, #64)- the
/
operator, vector-scalar division:v / λ
is (mostly) equivalent to(1 / λ) * v
; (#79) - the
+
operator now supports adding vectors to vector-likes:(0, 1) + Vector(1, 0)
; (#151) - we made non-null vectors truth-y, and
(0, 0)
false-y. (#166)
Breaking changes since v0.3
Vectors
are now immutable, as implemented by@dataclass(frozen=True)
(#106)Vector2
was renamed toVector
(#149)- Making subclasses of
Vector
isn't supported anymore (#149)
Improvements since v0.3
- All methods support vector-likes. (#56)
- Do not memoize the vector length, reducing memory usage at no computational cost. (#71)
Vector2
is now a dataclass, and as such support all related introspection functions,dataclasses.update
, ... (#106)asdict
is a new method for converting vectors to vector-like dictionaries (#108).rotate
now uses higher-precision trigonometry, and better preserves vector lengths. (#89)scale_to
is now more precise, at the cost of possible overflows with vectors larger than 1e75. (#87)- Passing a
Vector2
instance to theVector2
constructor doesn't return a new object anymore. (#142)
This is correct, as vectors are immutable, and saves up memory and time. - Support the
pickle
protocol (#147) - The
update()
method now has a more efficient implementation. (#167)
Bug fixes since v0.3
reflect
was previously producing incorrect results whenself * surface_normal > 0
. (#63)rotate
was previously rounding its results, causing imprecision issues. (#67)scale_to
now deals correctly with invalid inputs (#81):- raise
ValueError
when passed a negative length; - raise
ZeroDivisionError
when scaling the null vector to a non-null length. (#95)
- raise