matrix_ortho.h

Go to the documentation of this file.
00001 /* -*- C++ -*- ------------------------------------------------------------
00002  
00003 Copyright (c) 2007 Jesse Anders and Demian Nave http://cmldev.net/
00004 
00005 The Configurable Math Library (CML) is distributed under the terms of the
00006 Boost Software License, v1.0 (see cml/LICENSE for details).
00007 
00008  *-----------------------------------------------------------------------*/
00013 #ifndef matrix_ortho_h
00014 #define matrix_ortho_h
00015 
00016 #include <cml/mathlib/vector_ortho.h>
00017 
00018 /* Functions for orthogonalizing a matrix.
00019  *
00020  * matrix_orthogonalize_3x3() and _2x2() operate on the upper-left-hand part
00021  * of any matrix of suitable size; this is to allow orthonormalization of the
00022  * rotation part of an affine transform matrix.
00023  *
00024  * Note: These functions pass off to the orthonormalization functions in
00025  * vector_ortho.h, so see that file for details on the optional parameters.
00026  *
00027  * @todo: General NxN matrix orthogonalization.
00028  */
00029 
00030 namespace cml {
00031 
00033 template < typename E, class A, class B, class L > void
00034 matrix_orthogonalize_3x3(matrix<E,A,B,L>& m, size_t stable_axis = 2,
00035     size_t num_iter = 0, E s = E(1))
00036 {
00037     typedef vector< E, fixed<3> > vector_type;
00038 
00039     vector_type x, y, z;
00040     matrix_get_basis_vectors(m,x,y,z);
00041     orthonormalize(x,y,z,stable_axis,num_iter,s);
00042     matrix_set_basis_vectors(m,x,y,z);
00043 }
00044 
00046 template < typename E, class A, class B, class L > void
00047 matrix_orthogonalize_2x2(matrix<E,A,B,L>& m, size_t stable_axis = 0,
00048     size_t num_iter = 0, E s = E(1))
00049 {
00050     typedef vector< E, fixed<2> > vector_type;
00051 
00052     vector_type x, y;
00053     matrix_get_basis_vectors_2D(m,x,y);
00054     orthonormalize(x,y,stable_axis,num_iter,s);
00055     matrix_set_basis_vectors_2D(m,x,y);
00056 }
00057 
00058 } // namespace cml
00059 
00060 #endif

Generated on Sat Jul 18 19:35:22 2009 for CML 1.0 by  doxygen 1.5.9