Commit Graph

13 Commits

Author SHA1 Message Date
Bill Currie cfaf158ebc [math] Add some bit-op functions
Just 32-bit rounding to next higher power of two, and base 2 logarithm.
Most importantly, they are suitable for use in initializers as they are
constant in, constant out.
2022-01-23 13:47:14 +09:00
Bill Currie 5fb28d7c38 [math] Clean up vector component operations
And add a unary op macro. Having VectorCompOp makes it easy to write
macros that work for multiple data widths, which is why it and its users
now use (dst, ...) instead of (..., dst) as in the past. I'll sort out
the other macros later now that I know the compiler handily gives
messages about the switched order (uninitialized vars etc).
2022-01-02 01:15:17 +09:00
Bill Currie 9aa8f18d73 [math] Split out Quat/Vector compare implementations
This renames existing VectorCompCompare (and quaternion equivalent) to
VectorCompCompareAll and makes VectorCompCompare produce a vector of
results with optional negation (converting 0,1 to 0,-1 for compatibility
with simd semantics).
2022-01-02 01:09:51 +09:00
Bill Currie 93167279fc Fix a bunch of issues found by gcc-11 2021-06-13 14:30:59 +09:00
Bill Currie 0da3b35ef5 [util] Add macro for using vectors with scanf 2021-03-03 18:11:59 +09:00
Bill Currie 3bbe33844a [util] Add component-wise vector mult-add/sub macros 2021-01-26 00:39:34 +09:00
Bill Currie ab04a1915e [build] Fix a pile of gcc 10 issues
gcc got stricter about array accesses, complicating progs macros, and
much better at detecting buffer overflows.
2020-12-21 14:14:29 +09:00
Bill Currie 62f3e1f428 [util] Calculate quaternion to rotate between two vectors
The calculation fails (produces NaN) if the vectors are anti-parallel,
but works for all other combinations. I came up with this implementation
when I discovered Unity's Quaternion.FromToRotation could did not work
with very small angles. This implementation will produce a usable
quaternion below 0.00255 degrees (though it will be slightly larger than
unit). Unity's failed such that I could see KSP's skybox snap while it
rotated around my test vessel.
2020-12-21 14:14:10 +09:00
Bill Currie fbd79963bb Update for doxygen 1.8.16 2020-02-11 15:20:49 +09:00
Bill Currie f58c2fef5a Switch QF's quaterions from wxyz to xyzw.
After messing with SIMD stuff for a little, I think I now understand why
the industry went with xyzw instead of the mathematical wxyz. Anyway, this
will make for less pain in the future (assuming I got everything).
2018-10-12 14:33:55 +09:00
Bill Currie 34bcf7faab Do a pure/const/noreturn/format attribute pass.
I always wanted these, but as gcc now provides warnings for functions that
could do with such attributes, finding all the functions is much easier.
2018-10-09 12:42:21 +09:00
Bill Currie f0dc995c67 Handle c99 inline vs gnu89 inline.
The meaning of "extern inline" and "inline" swaps between the two, and
gcc-5 uses c99 inline.
2015-08-18 00:11:03 +09:00
Bill Currie 54b4d589aa Split up mathlib.h into several smaller headers.
This should make maintaining them a little easier.

The copyright block in most of the new headers (execpt vector.h) reflect
when the functions in the relevant header were first created.
2012-08-19 17:39:09 +09:00