PDA

View Full Version : Vector/matrix math in SDK?



kjl
05-31-2005, 04:32 PM
Is there a matrix builtin or any basic vector math functions available to us in the SDK? I see that lscript has cross products, dot products, normalize, and other vector math functions built in, but I can't find any such thing in the SDK. I wrote all the ones I could think of from scratch this weekend so the question is kind of moot now, but I guess I'm just wondering if all that time I spent trying to remember what exactly a cross product was was wasted or not :)

Thanks.

tischbein3
05-31-2005, 06:01 PM
The helper libaries provides you with the basic lwvector math.

Lynx3d
06-01-2005, 08:33 AM
As soon as you include lwmath.h you can use a bunch of macros like VDOT, VCROSS, VADD etc. but macros are not foolproof :D
The vecmath SDK sample contains a global class plugin that provides functions like normalize, matrix multiplications etc. but it also states that the implementation goes for simplicity over speed.
Most of those functions are so small you should actually inline them.

And if you're using C++ you may want to write a vector-class that fits your needs and overload operators anyway, which makes handling vectors much nicer IMHO.

kjl
06-01-2005, 08:44 PM
Ah, yeah - vecmath.{c,h}, I guess that's what I was looking for. Yeah, those are #defines, so that's as inline as you can get, I guess ;)

But, yeah, overloading all the operators would be nice.

v3=normalize(v1-v2*(v1*v2));
would be way easier to type than
VSUB3(v3,v1,VSCL(v2,VDOT(v1,v2)));
VNORM(v3);
Ugh, that's gross.


Thanks for the reply.