Open QuLogic opened 2 years ago
I also noted that there exist several packages that do affine transforms already. I have not attempted any conversions, and they may not be any better, but might be useful as inspiration.
There are some pure Python packages:
Some compiled options:
affine-transform
- Parallel affine transforms using C++17 and OpenMPPyrr
- 3D mathematical functions using NumPy (might be similar to ours though)cython-blis
- Fast matrix-multiplication as a self-contained Python library (not affine specific)eigency
- Cython interface to Eigen libraryAnd some non-Python things that would need wrappers:
cglm
- OpenGL Mathematics (glm) for C (not affine specific, but does 2D and 3D math)math
- Vector and matrix math in C++17trans_affine
structSince pybind11 has native support for Eigen, I've put together a branch https://github.com/QuLogic/matplotlib/tree/eigen-transform that attempts to use it. There are a few minor issues that need to be fixed, but it passes most tests now.
However, I've noticed that there is a cast to a NumPy array in the path extension here: https://github.com/matplotlib/matplotlib/blob/8f296dbde92cdcca7de69b1ceaa0f044c6529c5f/src/py_converters.cpp#L320-L323 which means we miss out on avoiding NumPy right now. This will be made easier once #27087 is complete.
I've not run any benchmarks yet, but at least this points out the pain points with doing this change (and we got #27511 out of it.)
Also, taking a quick look at Agg's trans_affine
, it looks to be fairly similar to Eigen. It may be just as easy to implement that way, and not require the addition of Eigen.
Originally posted by @anntzer in https://github.com/matplotlib/matplotlib/pull/22119