Main Categories: | Landscape | Fenceposts | Wildlife | Trees | Mushrooms | Art | Games || All Posts ||
for daily images, visit my ||Tumblr||

Friday, 26 June 2009

Argh! Trigonometry, Alison & Accident Book

Whenever you find yourself doing anything involved with trigonometry during the development of a 3d game, a little alarm bell should sound at the back of your mind - could you accomplish your aims more elegantly and efficiently by the application of a few vector cross and dot products? usually the answer is yes, and you should dump all those mouldy old atan2()s like a hot air balloon dropping sand bags.


Make sure your inappropriate over-reliance on trigonometry is properly recorded in the office accident book, and then move on. Don't look back - a nasty little trig fairy is lurking back there, just waiting for an opportunity to trepan your canoodle with a rusty old funnel-cap.

1 comment:

Unknown said...

How about a little bit of

float InvSqrt (float x)
{
float xhalf = 0.5f*x;
int i = *(int*)&x;
i = 0x5f3759df - (i>>1);
x = *(float*)&i;
return x*(1.5f - xhalf*x*x);
}

?