X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2Fcml%2Fmathlib%2Fmatrix_concat.h;fp=src%2Fcml%2Fmathlib%2Fmatrix_concat.h;h=8e789aa01171bd8e7641a8ea93e8051379d24fbe;hp=0000000000000000000000000000000000000000;hb=6b0a0d0efafe34d48ab344fca3b479553bd4e62c;hpb=85783316365181491a3e3c0c63659972477cebba diff --git a/src/cml/mathlib/matrix_concat.h b/src/cml/mathlib/matrix_concat.h new file mode 100644 index 0000000..8e789aa --- /dev/null +++ b/src/cml/mathlib/matrix_concat.h @@ -0,0 +1,62 @@ +/* -*- C++ -*- ------------------------------------------------------------ + +Copyright (c) 2007 Jesse Anders and Demian Nave http://cmldev.net/ + +The Configurable Math Library (CML) is distributed under the terms of the +Boost Software License, v1.0 (see cml/LICENSE for details). + + *-----------------------------------------------------------------------*/ +/** @file + * @brief + */ + +#ifndef matrix_concat_h +#define matrix_concat_h + +#include + +/* This will all most likely be abstracted away in a future version of the + * CML. For now, this file provides support for functions that need to + * concatenate transformation matrices in a basis-independent manner. + * + * @todo: The 2x2 and 3x3 versions of these functions are currently in + * matrix_rotation.h. They should be moved here. + */ + +namespace cml { +namespace detail { + +/** A fixed-size temporary 4x4 matrix */ +#define MAT_TEMP_4X4 matrix< \ + typename et::ScalarPromote< \ + typename MatT_1::value_type, \ + typename MatT_2::value_type \ + >::type, \ + fixed<4,4>, \ + typename MatT_1::basis_orient, \ + typename MatT_1::layout \ +> + +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; +} + +/** Concatenate two 3D col-basis rotation matrices in the order m1->m2 */ +template < class MatT_1, class MatT_2 > MAT_TEMP_4X4 +matrix_concat_transforms_4x4(const MatT_1& m1, const MatT_2& m2, col_basis) { + return m2*m1; +} + +/** Concatenate two 3D rotation matrices in the order m1->m2 */ +template < class MatT_1, class MatT_2 > MAT_TEMP_4X4 +matrix_concat_transforms_4x4(const MatT_1& m1, const MatT_2& m2) { + return matrix_concat_transforms_4x4(m1,m2,typename MatT_1::basis_orient()); +} + +#undef MAT_TEMP_4x4 + +} // namespace detail +} // namespace cml + +#endif