bool pxUtil_MassPropertiesComputer::ComputeSphereVolumeMassProperties( pxReal radius, pxReal mass, pxMassProperties &result ) { if( !CHK( radius > 0.0f ) ) { return false; } if( !CHK( mass > 0.0f ) ) { return false; } result.centerOfMass.SetZero(); // volume = (4/3) * MX_PI * (radius^3) result.volume = pxReal(4.0/3.0) * MX_PI * cubef( radius ); result.mass = mass; const pxReal radiusSq = squaref( radius ); /*------------------------------------------------------ | (2/5) * M * (R^2) 0 0 | 0 (2/5) * M * (R^2) 0 | 0 0 (2/5) * M * (R^2) */ result.inertiaTensor.SetValue( pxReal(0.4)*radiusSq, 0.0f, 0.0f, 0.0f, pxReal(0.4)*radiusSq, 0.0f, 0.0f, 0.0f, pxReal(0.4)*radiusSq ); return true; }
void RunFloatTests(void) { float f1 = 2.5; float f2 = 2.6; if(enabled) { printf("calling addTwoNums(%f, %f) with result %f.\n", f1, f2, addTwoNums(f1, f2)); printf("calling mulTwoNums(%f, %f) with result %f.\n", f1, f2, mulTwoNums(f1, f2)); printf("calling subTwoNums(%f, %f) with result %f.\n", f1, f2, subTwoNums(f1, f2)); printf("calling divTwoNums(%f, %f) with result %f.\n\n", f1, f2, divTwoNums(f1, f2)); } f1 = 4.0; f2 = 10.0; if(enabled) { printf("calling squaref(%f) with result %f.\n", f1, squaref(f1)); printf("calling cubef(%f) with result %f.\n", f1, cubef(f1)); printf("calling squaref(%f) with result %f.\n", f2, squaref(f2)); printf("calling cubef(%f) with result %f.\n\n", f2, cubef(f2)); } }
static long Labaf_to_rgbaf (float *src, float *dst, long samples) { long n = samples; while (n--) { float L = src[0]; float A = src[1]; float B = src[2]; float a = src[3]; float fy = (L + 16.0f) / 116.0f; float fx = fy + A / 500.0f; float fz = fy - B / 200.0f; float yr = L > LAB_KAPPA * LAB_EPSILON ? cubef (fy) : L / LAB_KAPPA; float xr = cubef (fx) > LAB_EPSILON ? cubef (fx) : (fx * 116.0f - 16.0f) / LAB_KAPPA; float zr = cubef (fz) > LAB_EPSILON ? cubef (fz) : (fz * 116.0f - 16.0f) / LAB_KAPPA; float r = 3.134274799724f * D50_WHITE_REF_X * xr -1.617275708956f * D50_WHITE_REF_Y * yr -0.490724283042f * D50_WHITE_REF_Z * zr; float g = -0.978795575994f * D50_WHITE_REF_X * xr +1.916161689117f * D50_WHITE_REF_Y * yr +0.033453331711f * D50_WHITE_REF_Z * zr; float b = 0.071976988401f * D50_WHITE_REF_X * xr -0.228984974402f * D50_WHITE_REF_Y * yr +1.405718224383f * D50_WHITE_REF_Z * zr; dst[0] = r; dst[1] = g; dst[2] = b; dst[3] = a; src += 4; dst += 4; } return samples; }