toon-members
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Toon-members] TooN helpers.h


From: Ethan Eade
Subject: [Toon-members] TooN helpers.h
Date: Mon, 30 Jun 2008 13:36:10 +0000

CVSROOT:        /cvsroot/toon
Module name:    TooN
Changes by:     Ethan Eade <ethaneade>  08/06/30 13:36:10

Modified files:
        .              : helpers.h 

Log message:
        Added makeVector for dimensions 1-6.  This allows simpler use for 
common cases than using make_Vector and the vector magic stuff.
        Also added specialized normalize function for fixed-size vectors.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/TooN/helpers.h?cvsroot=toon&r1=1.23&r2=1.24

Patches:
Index: helpers.h
===================================================================
RCS file: /cvsroot/toon/TooN/helpers.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- helpers.h   31 Mar 2008 14:26:10 -0000      1.23
+++ helpers.h   30 Jun 2008 13:36:10 -0000      1.24
@@ -8,8 +8,7 @@
      version 2.1 of the License, or (at your option) any later version.
 
      This library is distributed in the hope that it will be useful,
-     but WITHOUT ANY WARRANTY; without even the implied warranty of}
-
+     but WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      Lesser General Public License for more details.
 
@@ -29,6 +28,13 @@
 
 //////////// CONTENTS OF THIS FILE ///////////
 
+inline Vector<1> makeVector(double x) { double vals[] = {x}; return 
Vector<1>(vals); }
+inline Vector<2> makeVector(double x0, double x1) { double vals[] = {x0,x1}; 
return Vector<2>(vals); }
+inline Vector<3> makeVector(double x0, double x1, double x2) { double vals[] = 
{x0,x1,x2}; return Vector<3>(vals); }
+inline Vector<4> makeVector(double x0, double x1, double x2, double x3) { 
double vals[] = {x0,x1,x2,x3}; return Vector<4>(vals); }
+inline Vector<5> makeVector(double x0, double x1, double x2, double x3, double 
x4) { double vals[] = {x0,x1,x2,x3,x4}; return Vector<5>(vals); }
+inline Vector<6> makeVector(double x0, double x1, double x2, double x3, double 
x4, double x5) { double vals[] = {x0,x1,x2,x3,x4,x5}; return Vector<6>(vals); }
+
 // normalizations (note US spelling)
 template <class Accessor> inline void  normalize(VectorBase<Accessor>& v);
 template <class Accessor> inline void  normalize_last(VectorBase<Accessor>& v);
@@ -89,13 +95,13 @@
  
  template <int M, int N> inline const Matrix<M,N>& zeros() { return 
*reinterpret_cast<const Matrix<M,N>*>(ZeroBlock<double,M*N>::data); }
  template <int N> inline const Vector<N>& zeros() { return 
*reinterpret_cast<const Vector<N>*>(ZeroBlock<double,N>::data); }
+
  inline const Matrix<> zeros(int m, int n) {
      Matrix<> z(m,n);
      Zero(z);
      return z;
  }
 
-
 template <class A> inline double determinant(const FixedMatrix<2,2,A>& M) 
 {
     return M[0][0] * M[1][1] - M[0][1] * M[1][0];
@@ -123,9 +129,13 @@
     return tr;
 }
 
- //////////////////////////////////////////////
+ ////////////////////////////-//////////////////
 
 
+template <int N, class A> void normalize(FixedVector<N,A>& v)
+{
+    v *= 1.0/sqrt(v*v);
+}
 
 // normalizations (note US spelling)
 template <class Accessor>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]