Gah!

Published November 21, 2007
Advertisement
In case you wanted further proof that I am, indeed, astoundingly stupid...
        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);
Seriously, why do you guys hang out with me?
Previous Entry Is that... is that light?
Next Entry Productivity
0 likes 6 comments

Comments

sprite_hound
Because astounding stupidity is often astoundingly amusing. >.>

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.
November 21, 2007 06:43 AM
Jotaf
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
jpetrie
Quote:
Seriously, why do you guys hang out with me?

It makes me look smarter.
November 21, 2007 08:37 AM
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.

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
sprite_hound
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
Moe
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
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement