toon-members
[Top][All Lists]
Advanced

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

[Toon-members] TooN helpers.h


From: Edward Rosten
Subject: [Toon-members] TooN helpers.h
Date: Wed, 13 May 2009 13:58:49 +0000

CVSROOT:        /cvsroot/toon
Module name:    TooN
Changes by:     Edward Rosten <edrosten>        09/05/13 13:58:49

Modified files:
        .              : helpers.h 

Log message:
        Cross product matrix.

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

Patches:
Index: helpers.h
===================================================================
RCS file: /cvsroot/toon/TooN/helpers.h,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -b -r1.66 -r1.67
--- helpers.h   13 May 2009 13:43:44 -0000      1.66
+++ helpers.h   13 May 2009 13:58:49 -0000      1.67
@@ -235,5 +235,29 @@
                return tr;
        }
 
+       /// creates an returns a cross product matrix M from a 3 vector v, such 
that for all vectors w, the following holds: v ^ w = M * w
+       /// @param vec the 3 vector input
+       /// @return the 3x3 matrix to set to the cross product matrix
+       template<int Size, class P, class B> inline TooN::Matrix<3, 3, P> 
cross_product_matrix(const Vector<Size, P, B>& vec)
+       {
+               SizeMismatch<Size,3>::test(vec.size(), 3);
+
+               TooN::Matrix<3> result;
+
+               result(0,0) = 0; 
+               result(0,1) = -vec[2]; 
+               result(0,2) = vec[1];
+               result(1,0) = vec[2]; 
+               result(1,1) = 0; 
+               result(1,2) = -vec[0];
+               result(2,0) = -vec[1]; 
+               result(2,1) = vec[0]; 
+               result(2,2) = 0;
+
+               return result;
+       }
+
+
+
 }
 #endif




reply via email to

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