History | View | Annotate | Download (4.808 KB)
Add attribution line for fixes in utility code
It makes no sense to return 0 for the vector norm when the vector containsNaNs. Just return NaN instead, Furthermore don't refuse to normalize vectorswhen the length is small. Unless the length really is zero, it should be safeto scale with the inverse length.
Unless all vector length are very close to unity, trying to avoid taking asquare root only slows things down (at least on x86_64 and Arduino Uno).
limit scope of loop variable
Fix use of abs() function with float argument.
The abs() function in stdlib.h takes an integer argument. Passing it a floatwill silently convert the argument to int, and take the absolute value of theresult. Hence, abs(0.99) == 0, which is not what was intended. Use fabs instead.
make member functions const where appropriate, and pass vectors by reference
Remove unused include
The cross product is only defined for 3D vectors. Instead of checking the sizeat runtime, only provide an implementation for N==3. Trying to use the crossfunction with other vector sizes will then result in a link error.
Remove unnecessary double* pointer from Vector<N>
The pointer prevents the use of bitwise move/copy/initialize operationson Vector(). Less importantly, it's an unnecessary memory bloat.
Bug fix for Vector::magnitude()
Sample failure: Vector<1>(0.5).magnitude() returns 1, not 0.5.The avoid-sqrt optimization is dubious at best, and should arguablyjust be removed.
Add "const" to non-mutating Vector, Quat methods
Also adds some clarifying documentation, since the quat->euler axisconventions are a bit surprising.
Switch from dynamic memory to stack allocated memory for imumath types, add TinyWireM support, make indentation consistent.
First commit