Imath icon indicating copy to clipboard operation
Imath copied to clipboard

Python binding for Vec questions

Open lamiller0 opened this issue 2 years ago • 3 comments
trafficstars

Here are some questions that came up while doing the pybind11 bindings and comparing it with the boost python bindings.

Vec4 doesnt have any cross product operators or functions in it. The C++ lacks it as well so I'm guessing its because its impossible?

Vec2 is missing %= operator but has the other cross product operators on the C++ side, is this an oversight that I can just add in on the C++ side?

closestVertex in C++ has it's args like: V0, V1, V2, P but in boost python its: P, V0, V1, V2 is this on purpose? https://github.com/lamiller0/Imath/blob/main/src/python/PyImath/PyImathVec3Impl.h#L237

project in C++ takes v, v0 but the boost python binding flips it (v0, v) https://github.com/lamiller0/Imath/blob/main/src/python/PyImath/PyImathVec3Impl.h#L261

lamiller0 avatar Oct 14 '23 02:10 lamiller0

Cross product only makes mathematical sense in 3 dimensions.

lgritz avatar Oct 14 '23 03:10 lgritz

As for the final two things you mention... oof. Well that kinda sucks. We would like the C++ and Python interfaces to match, of course. We would also like to not break any interfaces that have existed a long time.

I would guess that neither of those are on purpose, but both probably mistakes from the early days that were either never noticed, or whoever walked this path before us also threw up their hands and decided to leave it broken for the sake of not breaking any python code that was already using the jumbled argument order.

lgritz avatar Oct 14 '23 03:10 lgritz

Could we deprecate the existing closestVertex and project in Python (leaving them in place) and provide new ones with new names and matching argument order (closeVertexToPoint, projectVectorOnVector? Seems like the right time to do something like that.

meshula avatar Oct 14 '23 12:10 meshula

#472 completes the Vec class wrappings in pybind11, and it brings over the original python test, in src/pybind11/PyBindImathTest/pyBindImathTest, to validate that all behavior is consistent with the existing Boost.python implementation.

cary-ilm avatar Apr 20 '25 04:04 cary-ilm