demianmnave / CML

The Configurable Math Library
https://github.com/demianmnave/CML
Boost Software License 1.0
83 stars 15 forks source link

Order of matrix_concat switched from CML1 #38

Closed NeroProtagonist closed 9 months ago

NeroProtagonist commented 10 months ago

Hello,

The expression in CML 1 for matrix_concat is (m1 * m2):

template < class MatT_1, class MatT_2 >  #MAT_TEMP_4X4  
matrix_concat_transforms_4x4(const MatT_1& m1, const MatT_2& m2, row_basis) {  
    return m1*m2;  
}  

whereas in CML2 it is (m2 * m1):

template<class Sub1, class Sub2> inline auto
matrix_concat(
  const readable_matrix<Sub1>& m1, const readable_matrix<Sub2>& m2, row_basis
  )
-> matrix_inner_product_promote_t<Sub1, Sub2>
{
  return m2 * m1;
}

Was this intended? It means using the higher level functions from CML like unproject_point no longer work without modifying the code.

Thanks

demianmnave commented 9 months ago

@NeroProtagonist I am sorry for not seeing this. For some reason, I have not been receiving notifications for new issues.

This is definitely a bug, since row basis matrices should be concatenated as $p' = p\times m1\times m2$, whereas column basis matrices should be concatenated as $p' = m2\times m1\times p$.

Thank you for reporting this. I will get it fixed ASAP.

demianmnave commented 9 months ago

This will also require figuring out if the frustum code is incorrect (frustum1.cpp), as it depends upon concatenation to be in the right order.