toon-members
[Top][All Lists]
Advanced

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

Re: [Toon-members] TooN helpers.h


From: E. Rosten
Subject: Re: [Toon-members] TooN helpers.h
Date: Thu, 16 Apr 2009 18:07:11 +0100 (BST)

On Thu, 16 Apr 2009, Gerhard Reitmayr wrote:


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>());

The above code is efficient for static vectors (ie the compiler makes it work in-place), but not for dynamic ones.

If you compile the documentation and look at the section "Why don't functions work in place?", it goves a method for writing functions which work in-place.


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 ?


How about a .diag() method which returns the leading diagonal as a slice?

-Ed

--
(You can't go wrong with psycho-rats.)(http://mi.eng.cam.ac.uk/~er258)

/d{def}def/f{/Times s selectfont}d/s{11}d/r{roll}d f 2/m{moveto}d -1
r 230 350 m 0 1 179{ 1 index show 88 rotate 4 mul 0 rmoveto}for/s 12
    d f pop 235 420 translate 0 0 moveto 1 2 scale show showpage




reply via email to

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