// Quatizations void LLVector3::quantize16(F32 lowerxy, F32 upperxy, F32 lowerz, F32 upperz) { F32 x = mV[VX]; F32 y = mV[VY]; F32 z = mV[VZ]; x = U16_to_F32(F32_to_U16(x, lowerxy, upperxy), lowerxy, upperxy); y = U16_to_F32(F32_to_U16(y, lowerxy, upperxy), lowerxy, upperxy); z = U16_to_F32(F32_to_U16(z, lowerz, upperz), lowerz, upperz); mV[VX] = x; mV[VY] = y; mV[VZ] = z; }
void v3math_object::test<34>() { F32 x = 10.f, y = 20.f, z = -15.f; F32 x1, y1, z1; F32 lowerxy = 0.f, upperxy = 1.0f, lowerz = -1.0f, upperz = 1.f; LLVector3 vec3(x,y,z); vec3.quantize16(lowerxy,upperxy,lowerz,upperz); x1 = U16_to_F32(F32_to_U16(x, lowerxy, upperxy), lowerxy, upperxy); y1 = U16_to_F32(F32_to_U16(y, lowerxy, upperxy), lowerxy, upperxy); z1 = U16_to_F32(F32_to_U16(z, lowerz, upperz), lowerz, upperz); ensure("1:quantize16: Fail ", is_approx_equal(x1, vec3.mV[VX]) && is_approx_equal(y1, vec3.mV[VY]) && is_approx_equal(z1, vec3.mV[VZ])); LLVector3 vec3a(x,y,z); vec3a.quantize8(lowerxy,upperxy,lowerz,upperz); x1 = U8_to_F32(F32_to_U8(x, lowerxy, upperxy), lowerxy, upperxy); y1 = U8_to_F32(F32_to_U8(y, lowerxy, upperxy), lowerxy, upperxy); z1 = U8_to_F32(F32_to_U8(z, lowerz, upperz), lowerz, upperz); ensure("2:quantize8: Fail ", is_approx_equal(x1, vec3a.mV[VX]) && is_approx_equal(y1, vec3a.mV[VY]) && is_approx_equal(z1, vec3a.mV[VZ])); }
// Quatizations void LLQuaternion::quantize16(F32 lower, F32 upper) { F32 x = mQ[VX]; F32 y = mQ[VY]; F32 z = mQ[VZ]; F32 s = mQ[VS]; x = U16_to_F32(F32_to_U16_ROUND(x, lower, upper), lower, upper); y = U16_to_F32(F32_to_U16_ROUND(y, lower, upper), lower, upper); z = U16_to_F32(F32_to_U16_ROUND(z, lower, upper), lower, upper); s = U16_to_F32(F32_to_U16_ROUND(s, lower, upper), lower, upper); mQ[VX] = x; mQ[VY] = y; mQ[VZ] = z; mQ[VS] = s; normQuat(); }