Add SPZ v3 smallest 3 quaternion encoding support (#171)

Co-authored-by: George Ash <george@nianticspatial.com>
This commit is contained in:
Greg Ash
2025-09-22 22:38:18 +01:00
committed by GitHub
parent bd4ac3665f
commit ccd2dd1243
2 changed files with 48 additions and 38 deletions
+6
View File
@@ -21,6 +21,12 @@ const f16buffer = supportsFloat16Array
: null;
const u16buffer = new Uint16Array(f16buffer?.buffer);
// Returns a normalized array of numbers
export function normalize(vec: number[]) {
const norm = Math.sqrt(vec.reduce((acc, v) => acc + v * v, 0));
return vec.map((v) => v / norm);
}
// Reinterpret the bits of a float32 as a uint32
export function floatBitsToUint(f: number): number {
f32buffer[0] = f;