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
- We added a bunch of new methods:
angle, for computing the angle between 2 vectors; (#57, #68)
it uses a numerically-stable formula (based on
math.atan2) to guarantee adequate behaviour;
isclose, for checking whether 2 vectors are approximately equal; (#62, #64)
/operator, vector-scalar division:
v / λis (mostly) equivalent to
(1 / λ) * v; (#79)
+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
Vectorsare now immutable, as implemented by
Vector2was renamed to
- Making subclasses of
Vectorisn'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)
Vector2is now a dataclass, and as such support all related introspection functions,
dataclasses.update, ... (#106)
asdictis a new method for converting vectors to vector-like dictionaries (#108).
rotatenow uses higher-precision trigonometry, and better preserves vector lengths. (#89)
scale_tois now more precise, at the cost of possible overflows with vectors larger than 1e75. (#87)
- Passing a
Vector2instance to the
Vector2constructor doesn't return a new object anymore. (#142)
This is correct, as vectors are immutable, and saves up memory and time.
- Support the
update()method now has a more efficient implementation. (#167)
Bug fixes since v0.3
reflectwas previously producing incorrect results when
self * surface_normal > 0. (#63)
rotatewas previously rounding its results, causing imprecision issues. (#67)
scale_tonow deals correctly with invalid inputs (#81):
ValueErrorwhen passed a negative length;
ZeroDivisionErrorwhen scaling the null vector to a non-null length. (#95)