SOLVED C++ The product of the Matrix and another type function does not exist?

Hello!
I develop my plugin on C++ and trying to receive the same line of Python code:

matrixA= c4d.utils.MatrixMove(c4d.Vector(0,10,0)) 
matrixB = myObject.GetMg().__mul__(matrixA)

MatrixMove func exists in a C++ help. But I can't find in C++ help the analogue of .mul function.

So does this function from a Python help: https://bit.ly/30dc2Ps
https://developers.maxon.net/docs/Cinema4DPythonSDK/html/modules/c4d/Matrix/index.html?highlight=mul#Matrix.mul

exists for a C++?

Hello @yaya,

matrixB = myObject->GetAbsPos() * matrixA;

First of all, BaseObject::GetAbsPos returns a Vector, which in turn makes your calculation at least implicitly wrong, since you call the result matrixB, implying that it is a matrix. But the product of a matrix M and a vector p is the vector p' transformed by M. There is also the fact that order matters in the C++ SDK, i.e., you are forced to write expressions in the canonical matrix-first order (in Python you are not restricted in such fashion, because Python handles operator overloading differently).

Vector p; Matrix M;

// Valid expression since Mat3 has an operator overload for M * p
Vector q = M * p;
// Invalid expression since Vec3 does not have an operator overload for p * M
Vector r = p * M;

It might also be noteworthy that Matrix and Vector are only aliases originating from our classic API. The types have been replaced by a more versatile templated model of the atomic arithmetic types. Vector is just a typedef for maxon::Vec3<maxon::Float64, 1> and Matrix for maxon::Mat3<maxon::Vector64>. You can find the relevant template descriptions in the Mat3< V > Struct Template and Vec3< T, STRIDE > Struct Template references.

Cheers,
Ferdinand

operator * does not work for you?

Hi,
Cairyn is right, the operator you are looking for is *

Cheers
Manuel

@m_magalhaes @Cairyn

Hello guys.
No, the simple operator * between two matrixes shows an error.
Right now I've write it like this:

matrixB = myObject->GetAbsPos() * matrixA;

also via operator*.

But I am not sure will GetAbsPos return the same (according I need only the position offset of matrix).

Hello @yaya,

matrixB = myObject->GetAbsPos() * matrixA;

First of all, BaseObject::GetAbsPos returns a Vector, which in turn makes your calculation at least implicitly wrong, since you call the result matrixB, implying that it is a matrix. But the product of a matrix M and a vector p is the vector p' transformed by M. There is also the fact that order matters in the C++ SDK, i.e., you are forced to write expressions in the canonical matrix-first order (in Python you are not restricted in such fashion, because Python handles operator overloading differently).

Vector p; Matrix M;

// Valid expression since Mat3 has an operator overload for M * p
Vector q = M * p;
// Invalid expression since Vec3 does not have an operator overload for p * M
Vector r = p * M;

It might also be noteworthy that Matrix and Vector are only aliases originating from our classic API. The types have been replaced by a more versatile templated model of the atomic arithmetic types. Vector is just a typedef for maxon::Vec3<maxon::Float64, 1> and Matrix for maxon::Mat3<maxon::Vector64>. You can find the relevant template descriptions in the Mat3< V > Struct Template and Vec3< T, STRIDE > Struct Template references.

Cheers,
Ferdinand

Hello @ferdinand

Thank you for a such detailed answer.
It is hard for me to understand all of it by eye, and I can't say right now is it what I search.
I need to receive in the result the point in 3d space which is attached to another point like it is a child of parent (only position is needed).

So all construction serves to achieve a Vector point of a new position shifted by 10 units in a one of its local axis. (Vector(0,10,0))

I will finish my python-C++ rewriting and will test your example above.
Thank you!

This post is deleted!

Hello @ferdinand
I've tested it a bit and now I've finished with this:

instead of this:

matrixA= c4d.utils.MatrixMove(c4d.Vector(0,10,0)) 
matrixB = myObject.GetMg().__mul__(matrixA)

to this:

Matrix matrix = MatrixMove(Vector(0, 10, 0)); 
Vector vector = myObject->GetMg() * matrix.off;

It looks it works for me.
Thank you again!