toon-members
[Top][All Lists]
Advanced

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

[Toon-members] TooN/internal operators.hh


From: Tom Drummond
Subject: [Toon-members] TooN/internal operators.hh
Date: Tue, 10 Mar 2009 16:50:17 +0000

CVSROOT:        /cvsroot/toon
Module name:    TooN
Changes by:     Tom Drummond <twd20>    09/03/10 16:50:17

Modified files:
        internal       : operators.hh 

Log message:
        added cross product for 3-vectors (operator ^)

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/TooN/internal/operators.hh?cvsroot=toon&r1=1.18&r2=1.19

Patches:
Index: operators.hh
===================================================================
RCS file: /cvsroot/toon/TooN/internal/operators.hh,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- operators.hh        10 Mar 2009 15:30:23 -0000      1.18
+++ operators.hh        10 Mar 2009 16:50:11 -0000      1.19
@@ -164,6 +164,23 @@
   return result;
 }
 
+template <typename P1, typename P2>
+Vector<3, typename Internal::MultiplyType<P1,P2>::type> operator^(const 
Vector<3,P1>& v1, const Vector<3,P2>& v2){
+       // assume the result of adding two restypes is also a restype
+       typedef typename Internal::MultiplyType<P1,P2>::type restype;
+
+       Vector<3, restype> result;
+
+       result[0] = v1[1]*v2[2] - v1[2]*v2[1];
+    result[1] = v1[2]*v2[0] - v1[0]*v2[2];
+    result[2] = v1[0]*v2[1] - v1[1]*v2[0];
+
+       return result;
+}
+
+
+
+
 
////////////////////////////////////////////////////////////////////////////////
 //
 // matrix <op> matrix




reply via email to

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