toon-members
[Top][All Lists]
Advanced

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

[Toon-members] TooN helpers.h


From: Tom Drummond
Subject: [Toon-members] TooN helpers.h
Date: Tue, 07 Apr 2009 04:57:13 +0000

CVSROOT:        /cvsroot/toon
Module name:    TooN
Changes by:     Tom Drummond <twd20>    09/04/07 04:57:13

Modified files:
        .              : helpers.h 

Log message:
        replaced unit with multiply for efficiency
        added norm(Vector)
        added c++ magic comment for emacs

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

Patches:
Index: helpers.h
===================================================================
RCS file: /cvsroot/toon/TooN/helpers.h,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -b -r1.41 -r1.42
--- helpers.h   3 Apr 2009 16:14:51 -0000       1.41
+++ helpers.h   7 Apr 2009 04:57:12 -0000       1.42
@@ -1,4 +1,4 @@
-
+// -*- c++ -*-
 /*                       
         Copyright (C) 2005,2009 Tom Drummond, E. Rosten
 
@@ -39,10 +39,16 @@
                                m[i][j] = p;
        }
 
+       template<int Size, class Precision, class Base> inline Precision 
norm(const Vector<Size, Precision, Base>& v)
+       {
+               using std::sqrt;
+               return sqrt(v*v);
+       }
+
        template<int Size, class Precision, class Base> inline Vector<Size, 
Precision> unit(const Vector<Size, Precision, Base> & v)
                {
                        using std::sqrt;
-                       return v/sqrt(v*v);
+               return v * (1/sqrt(v*v));
                }
 
        template<int Size, typename Precision, typename Base> inline 
Vector<Size-1, Precision> project( const Vector<Size, Precision, Base> & v){




reply via email to

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