THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 29/10/2006 at 09:36, xxxxxxxx wrote:
Cinema 4D Version: 9.6
Platform: Mac OSX ;
Language(s) : C.O.F.F.E.E ;
I'm a little embarresed to ask, but I can't get my head around this..
I'm trying to read the local difference of two matrices.
Both matrices are placed along a spline using the same main position.
Matrix A (mainmatrix) is looking at a point a little ahead along the spline and thus gets its rotation.
Matrix B (submatrix) is looking at a point along the spline a little further than A. Now as they move along the spline there is a small difference in angles between the matrices. And that is what I'm after, I'm trying to get this little local vector value as a small positive resp. negative value as they "read" the curviature of the spline.
Reading the SDK and some answers here I see that using inverse matrix should be the way.
And this is where I fail:) I have no problems using MulP, MulM, MulV etc getting any value as a Global value. But any try inverting the main matrix makes my values flip.
Do I need to use a third reference matix or should these two matrices be enough?
As they are not matrices from a object I can't use "GetMl()".
Any pointers and tips?
On 30/10/2006 at 01:45, xxxxxxxx wrote:
If I understand you right you want the rotation difference? If so you could try to get the rotations with the Matrix class function GetHPB() for each matrix and set the difference back into a Matrix with SetRotHPB().
On 30/10/2006 at 05:34, xxxxxxxx wrote:
Yes, that is correct. But why I need the local value is because it is fully possible that Matrix A and Matrix B are pointing at greater value than the "small" difference.
I.e. A points slightly higher then global Z 0 (like 0.02 radiance) and B is looking slightly lower than global Z, and that is for example 4.02 radiance.
As the matrices moves along the spline, the difference "jumps" at a certain global direction. I've tried using the MinimizeAngle function but in this case it doesn't help as it seems.
And this is why I'm trying to "place" B as a virtual child of A and by using Invert() matrix get a positive small angle read as for exampl 0.02 radiance and a small negative value, like -0.04 (instead of 4.05, or what ever is the same globaly) regardles of the global direction of A.
On 30/10/2006 at 05:38, xxxxxxxx wrote:
The "closest" solution I've found to this is this post.
On 30/10/2006 at 05:40, xxxxxxxx wrote:
ops, maybe this link works better...
On 30/10/2006 at 06:52, xxxxxxxx wrote:
You could try this, locmat is the local matrix you get by inverting the parents matrix and multiplying it with the childs matrix. The below code tries to keep the rotations below Pi.
var rot = locmat->GetHPB();
rot.x = Modulo(rot.x, PI2);
rot.y = Modulo(rot.y, PI2);
rot.z = Modulo(rot.z, PI2);
if(rot.x > PI) rot.x = rot.x-PI2;
if(rot.y > PI) rot.y = rot.y-PI2;
if(rot.z > PI) rot.z = rot.z-PI2;