scoopr/vectorial — pull request #1 by dnschneid (2012-04-19 05:15:10+00:00)
Title: A major bugfix and minor additions.

Thanks for making vectorial! It's a refreshingly simple but effective library.

I did run into a pretty major issue when I was integrating it into my project. With vec2f's and vec3f's, operations that alter the extra one or two elements as a side-effect can cause those extra elements to NaN out. This is fine until you try to promote the vector to a higher-order vector (vec2f to vec3f or vec4f, vec3f to vec4f), at which point the multiplication to zero out W (and Z, in the case of vec2f) doesn't work, since NaN*0 == NaN.
The first commit fixes this by making the promotion explicitly create a new vector with zeros. The SSE version uses intrinsics, although I'm new to SSE and can't guarantee it's the fastest way to do it; you (or perhaps the compiler?) probably could think of a better way.

The second commit is fluff that adds scalar->vector conversions (using splat) and vector->vector promotions that let you specify the extra elements, which I've found to be very useful.

Feel free to change the commits as you please.

I'm not sure how much general math you want in vectorial; I have slerp, lerp, and outer-product implementations on the side I could integrate if you're interested.