double ratioA = 0.5; double ratioB = 0.5; if(fabs(sinHalfTheta) >= 0.001) { // Not halfway! Determine the ratios.. ratioA = sin((1.0 - t) * halfTheta) / sinHalfTheta; sin(t * halfTheta) / sinHalfTheta; } // Now that we have the ratios, figure it out. setW(getW() * ratioA + quaternion.getW() * ratioB); setX(getX() * ratioA + quaternion.getX() * ratioB); setY(getY() * ratioA + quaternion.getY() * ratioB); setZ(getZ() * ratioA + quaternion.getZ() * ratioB);
In case you wanted further proof that I am, indeed, astoundingly stupid...
Seriously, why do you guys hang out with me?
Previous Entry
Is that... is that light?
Next Entry
Productivity
Comments
November 21, 2007 06:43 AM
I think that the point is that in the line after "ratioA = ...", he calculates an expression that is never assigned to anything, and presumably should be put in ratioB (I think) :)
November 21, 2007 07:20 AM
November 21, 2007 08:37 AM
The error with the vector one is that operator- is negation, which is supposed to return the negated value and not actually modify the contents of the vector.
Instead, the code posted negates the actual vector and then returns that. So what you end up with is accidentally permanently negating the vector when all you wanted was to temporarily use the negated form.
Incidentally, if I had taken the time to make it const-correct the compiler would've caught it for me. A valuable lesson.
Jotaf is correct!
Instead, the code posted negates the actual vector and then returns that. So what you end up with is accidentally permanently negating the vector when all you wanted was to temporarily use the negated form.
Incidentally, if I had taken the time to make it const-correct the compiler would've caught it for me. A valuable lesson.
Jotaf is correct!
November 21, 2007 09:52 AM
Quote:Original post by Ravuya
The error with the vector one is that operator- is negation, which is supposed to return the negated value and not actually modify the contents of the vector.
Ah, of course.
November 21, 2007 11:41 AM
Heh, you think your code is bad... wait until I post some of MY code! (I'm about to start my 4th rewrite of my camera code, and it still isn't working properly).
November 29, 2007 07:12 PM
Advertisement
Latest Entries
A decade of GDNet
2107 views
Getting Comfortable With Some New Friends
1716 views
Finishing a Game
1752 views
Cut that out
2104 views
tuuurbos
1738 views
Holy crap
1389 views
Another entry this month - can it be?
1476 views
Hello there
1324 views
Metaphorical Journeys of 2010
1248 views
Ho ho ho, the bodies hit the floor
1524 views
Advertisement
And in any case when you post stuff like this (well, not this but the last code snippet anyway), I have no idea what's actually wrong with it, beyond just guessing.
And I'm making mistakes that are just as stupid.
In fact.... I should start posting such things. Just to be in with the stupid crowd.