[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Toon-members] TooN helpers.h
From: |
Gerhard Reitmayr |
Subject: |
Re: [Toon-members] TooN helpers.h |
Date: |
Thu, 16 Apr 2009 17:43:51 +0100 |
be aware that this function won't work for slices etc. because they
are non-const temporaries. i.e.
Vector<4> v;
normalize(v.slice<0,3>()); // this will fail
that's why we went with the unit function, for static vectors the
compiler generates the same code
v.slice<0,3>() = unit(v.slice<0,3>());
for Identity, the only working solution at the moment is:
Matrix<10> m = Identity;
m *= 22.0;
We could do something like the following:
Matrix<10> m = 22.0 * Identity;
one alternative would be:
Matrix<10> m = Identity(22.0);
but this is already overloaded with identity for dynamic matrices
where one has to pass in the size at construction time:
Matrix<> d = Identity(10);
what do you guys think ?
On 16 Apr 2009, at 16:23, Georg Klein wrote:
CVSROOT: /sources/toon
Module name: TooN
Changes by: Georg Klein <georgklein> 09/04/16 15:23:24
Modified files:
. : helpers.h
Log message:
Added normalize helper
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/TooN/helpers.h?cvsroot=toon&r1=1.47&r2=1.48
Patches:
Index: helpers.h
===================================================================
RCS file: /sources/toon/TooN/helpers.h,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -b -r1.47 -r1.48
--- helpers.h 14 Apr 2009 16:08:47 -0000 1.47
+++ helpers.h 16 Apr 2009 15:23:23 -0000 1.48
@@ -68,6 +68,11 @@
return v * (1/sqrt(v*v));
}
+ template<int Size, class Precision, class Base> inline void
normalize(Vector<Size, Precision, Base> & v)
+ {
+ v /= std::sqrt(v*v);
+ }
+
template<int Size, typename Precision, typename Base> inline
Vector<Size-1, Precision> project( const Vector<Size, Precision,
Base> & v){
return v.template slice<0,Size-1>() / v[Size-1];
}
_______________________________________________
Toon-members mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/toon-members
--
Gerhard Reitmayr
MIL, Engineering Department, Cambridge University
http://mi.eng.cam.ac.uk/~gr281/
- [Toon-members] TooN helpers.h, Tom Drummond, 2009/04/07
- [Toon-members] TooN helpers.h, Edward Rosten, 2009/04/08
- [Toon-members] TooN helpers.h, Tom Drummond, 2009/04/09
- [Toon-members] TooN helpers.h, Tom Drummond, 2009/04/14
- [Toon-members] TooN helpers.h, Gerhard Reitmayr, 2009/04/14
- [Toon-members] TooN helpers.h, Gerhard Reitmayr, 2009/04/14
- [Toon-members] TooN helpers.h, Georg Klein, 2009/04/16
- [Toon-members] TooN helpers.h, Tom Drummond, 2009/04/22
- [Toon-members] TooN helpers.h, Gerhard Reitmayr, 2009/04/22
- [Toon-members] TooN helpers.h, Tom Drummond, 2009/04/26
- [Toon-members] TooN helpers.h, Gerhard Reitmayr, 2009/04/28
- [Toon-members] TooN helpers.h, Gerhard Reitmayr, 2009/04/29