THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 09/04/2011 at 14:06, xxxxxxxx wrote:
When reading the documentation about c4d.Matrix.__rmul__ and c4d.Matrix.__mul__ (these are the LHS and RHS binary multplication operators in Python) it dawned upon me, that __rmul__ might be the equivalent for the GetMulV function in COFFEE, that is, if you muliply a matrix with a vector you get GetMulP equivalence but if you multiply a vector with a matrix (reverse order) you get the GetMulV equivalence.
A hint came from the doc text saying that one order includes position information while the other doesn't.
This seems like in COFFEE where GetMulV is for direction vectors and GetMulP is for points (position vectors).
So then I set up a very simple test scene to test the two variants and compare them to the equivalent COFFEE code in order to check if my interpretation is correct. The test object is not in the world origin and is rotated. I used a COFFEE and Python expression tag since they validate immediatly.
The result was that the COFFEE code returns two different vectors for GetMulV and GetMulP (as one might expect if the object is rotated and moved) but for Python the vectors returned are the same, while theoretically for
matrix * vector
vector * matrix
there should be different outcomes just like in COFFEE (if I understand the docs right). I mucked about and tried using inverse matrices and whatnot but couldn't figure out the equivalent code for a GetMulV operation in Python.
So then I tried to call matrix.__mul__(v) and matrix.__rmul__(v) directly and I while __mul__ is working as expected for __rmul__ I got this error message:
SystemError: /perforce_buildsystem_osx/.../c4d/PyVector/PyVector.cpp:628: bad argument to internal function
The Python and COFFEE code is really simple, just some integer component vector that gets multiplied GetMulP and GetMulV style with the objects global matrix.