Reputation: 16345
I have a matrix type that is defined as:
struct __transform_t
{
float m11, m12, m13, m14;
float m21, m22, m23, m24;
float m31, m32, m33, m34;
float m41, m42, m43, m44;
};
How would I concat one matrix to another? I want to "merge" the matrices to get a result that is a combination of both transformations. Basically, I'm trying to make a simple layering system, so if a parent layer is transformed, the child layer (that is visually inside the parent) should also inherit those transformations as well as have its own.
I'm trying to do it like in the example below, but I don't think that is the right way:
void transform_concat(transform_t* orig, transform_t* delta)
{
#define __act(x) orig->m##x += delta->m##x;
__act(11); __act(12); __act(13); __act(14);
__act(21); __act(22); __act(23); __act(24);
__act(31); __act(32); __act(33); __act(34);
__act(41); __act(42); __act(43); __act(44);
#undef __act
}
Upvotes: 1
Views: 918
Reputation: 400029
This sounds like transformation matrix compositing, so look up matrix multiplication. Since you have explicit fields for each value in the matrix, it'll be hard to write looping implementations.
Upvotes: 2