diff --git a/src/Imath/ImathMatrix.h b/src/Imath/ImathMatrix.h index a9a98472..a596030d 100644 --- a/src/Imath/ImathMatrix.h +++ b/src/Imath/ImathMatrix.h @@ -3574,22 +3574,22 @@ template IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline Matrix44& Matrix44::setValue (const Matrix44& v) IMATH_NOEXCEPT { - x[0][0] = v.x[0][0]; - x[0][1] = v.x[0][1]; - x[0][2] = v.x[0][2]; - x[0][3] = v.x[0][3]; - x[1][0] = v.x[1][0]; - x[1][1] = v.x[1][1]; - x[1][2] = v.x[1][2]; - x[1][3] = v.x[1][3]; - x[2][0] = v.x[2][0]; - x[2][1] = v.x[2][1]; - x[2][2] = v.x[2][2]; - x[2][3] = v.x[2][3]; - x[3][0] = v.x[3][0]; - x[3][1] = v.x[3][1]; - x[3][2] = v.x[3][2]; - x[3][3] = v.x[3][3]; + x[0][0] = T(v.x[0][0]); + x[0][1] = T(v.x[0][1]); + x[0][2] = T(v.x[0][2]); + x[0][3] = T(v.x[0][3]); + x[1][0] = T(v.x[1][0]); + x[1][1] = T(v.x[1][1]); + x[1][2] = T(v.x[1][2]); + x[1][3] = T(v.x[1][3]); + x[2][0] = T(v.x[2][0]); + x[2][1] = T(v.x[2][1]); + x[2][2] = T(v.x[2][2]); + x[2][3] = T(v.x[2][3]); + x[3][0] = T(v.x[3][0]); + x[3][1] = T(v.x[3][1]); + x[3][2] = T(v.x[3][2]); + x[3][3] = T(v.x[3][3]); return *this; } diff --git a/src/Imath/ImathMatrixAlgo.h b/src/Imath/ImathMatrixAlgo.h index cea305be..5db5e20b 100644 --- a/src/Imath/ImathMatrixAlgo.h +++ b/src/Imath/ImathMatrixAlgo.h @@ -1094,7 +1094,7 @@ addOffset ( Matrix44 O; Vec3 _rOffset (rOffset); - _rOffset *= M_PI / 180.0; + _rOffset *= T(M_PI / 180.0); O.rotate (_rOffset); O[3][0] = tOffset[0]; diff --git a/src/ImathTest/half_perf_test.cpp b/src/ImathTest/half_perf_test.cpp index 796cb4b9..ca75ec38 100644 --- a/src/ImathTest/half_perf_test.cpp +++ b/src/ImathTest/half_perf_test.cpp @@ -8,6 +8,7 @@ #endif #include +#include #include #include @@ -378,28 +379,17 @@ main (int argc, char* argv[]) if (halfs && floats) { - srand (numentries); + Rand48 r(numentries); for (int i = 0; i < numentries; ++i) { - halfs[i] = (uint16_t) (rand ()); + halfs[i] = (uint16_t) r.nexti(); floats[i] = imath_half_to_float (halfs[i]); } perf_test_half_to_float (floats, halfs, numentries); // test float -> half with real-world values -#ifdef _WIN32 - unsigned int rv; - for (int i = 0; i < numentries; ++i) - { - rand_s (&rv); - floats[i] = - 65504.0 * - (((double) rand () / (double) UINT_MAX) * 2.0 - 1.0); - } -#else for (int i = 0; i < numentries; ++i) - floats[i] = 65504.0 * (drand48 () * 2.0 - 1.0); -#endif + floats[i] = float(r.nextf(-65504, 65504)); perf_test_float_to_half (halfs, floats, numentries); } diff --git a/src/ImathTest/testBox.cpp b/src/ImathTest/testBox.cpp index 982e0727..57f9ec1a 100644 --- a/src/ImathTest/testBox.cpp +++ b/src/ImathTest/testBox.cpp @@ -39,7 +39,7 @@ addItem (const std::vector& value, std::vector& perms) T p; for (unsigned int i = 0; i < value.size (); i++) { - p[i] = value[i]; + p[i] = static_cast(value[i]); } perms.push_back (p); } @@ -94,7 +94,7 @@ testConstructors (const char* type) { T p; for (unsigned int i = 0; i < T::dimensions (); i++) - p[i] = i; + p[i] = static_cast(i); IMATH_INTERNAL_NAMESPACE::Box b (p); assert (b.min == p && b.max == p); @@ -108,8 +108,8 @@ testConstructors (const char* type) T p1; for (unsigned int i = 0; i < T::dimensions (); i++) { - p0[i] = i; - p1[i] = 10 * T::dimensions () - i - 1; + p0[i] = static_cast(i); + p1[i] = static_cast(10 * T::dimensions () - i - 1); } IMATH_INTERNAL_NAMESPACE::Box b (p0, p1); @@ -625,7 +625,7 @@ testSize (const char* type) T p; for (unsigned int i = 0; i < T::dimensions (); i++) { - p[i] = i; + p[i] = static_cast(i); } IMATH_INTERNAL_NAMESPACE::Box b1 (-p, p); assert (b1.size () == p * T (2)); @@ -684,8 +684,10 @@ testCenter (const char* type) T p1; for (unsigned int i = 0; i < T::dimensions (); i++) { - p0[i] = -typename T::BaseType (1 << (i + 1)); - p1[i] = typename T::BaseType (1 << (T::dimensions () - i)); + int lo = 1 << (i + 1); + int hi = 1 << (T::dimensions () - i); + p0[i] = -static_cast(lo); + p1[i] = static_cast(hi); } IMATH_INTERNAL_NAMESPACE::Box b1 (p0, p1); assert (b1.center () == (p1 + p0) / 2); @@ -737,8 +739,10 @@ testIsEmpty (const char* type) T p1; for (unsigned int i = 0; i < T::dimensions (); i++) { - p0[i] = -typename T::BaseType (1 << (i + 1)); - p1[i] = typename T::BaseType (1 << (T::dimensions () - i)); + int lo = 1 << (i + 1); + int hi = 1 << (T::dimensions () - i); + p0[i] = -static_cast(lo); + p1[i] = static_cast(hi); } IMATH_INTERNAL_NAMESPACE::Box b1 (p0, p1); assert (!b1.isEmpty ()); @@ -791,8 +795,10 @@ testIsInfinite (const char* type) T p1; for (unsigned int i = 0; i < T::dimensions (); i++) { - p0[i] = -typename T::BaseType (1 << (i + 1)); - p1[i] = typename T::BaseType (1 << (T::dimensions () - i)); + int lo = 1 << (i + 1); + int hi = 1 << (T::dimensions () - i); + p0[i] = -static_cast(lo); + p1[i] = static_cast(hi); } IMATH_INTERNAL_NAMESPACE::Box b1 (p0, p1); assert (!b1.isInfinite ()); @@ -853,8 +859,10 @@ testHasVolume (const char* type) T p1; for (unsigned int i = 0; i < T::dimensions (); i++) { - p0[i] = -typename T::BaseType (1 << (i + 1)); - p1[i] = typename T::BaseType (1 << (T::dimensions () - i)); + int lo = 1 << (i + 1); + int hi = 1 << (T::dimensions () - i); + p0[i] = -static_cast(lo); + p1[i] = static_cast(hi); } IMATH_INTERNAL_NAMESPACE::Box b1 (p0, p1); assert (b1.hasVolume ()); diff --git a/src/ImathTest/testBoxAlgo.cpp b/src/ImathTest/testBoxAlgo.cpp index fcb22de1..f7e80870 100644 --- a/src/ImathTest/testBoxAlgo.cpp +++ b/src/ImathTest/testBoxAlgo.cpp @@ -51,9 +51,9 @@ testEntryAndExitPoints (const Box3f& box) for (int i = 0; i < 100000; ++i) { V3f p1 ( - random.nextf (box.max.x, box.min.x), - random.nextf (box.max.y, box.min.y), - random.nextf (box.max.z, box.min.z)); + float(random.nextf (box.max.x, box.min.x)), + float(random.nextf (box.max.y, box.min.y)), + float(random.nextf (box.max.z, box.min.z))); V3f p2 (p1 + hollowSphereRand (random)); @@ -99,8 +99,8 @@ testEntryAndExitPoints (const Box3f& box) // box, and it passes the box at a minimum distance of r1. // - const float r1 = 0.00001; - const float r2 = 1.0; + const float r1 = 0.00001f; + const float r2 = 1.0f; V3f p1 = box.min + r2 * hollowSphereRand (random); V3f p2; @@ -142,9 +142,9 @@ testEntryAndExitPoints (const Box3f& box) do { p1 = V3f ( - random.nextf (bigBox.min.x, bigBox.max.x), - random.nextf (bigBox.min.y, bigBox.max.y), - random.nextf (bigBox.min.z, bigBox.max.z)); + float(random.nextf (bigBox.min.x, bigBox.max.x)), + float(random.nextf (bigBox.min.y, bigBox.max.y)), + float(random.nextf (bigBox.min.z, bigBox.max.z))); } while (box.intersects (p1)); V3f p2; @@ -152,9 +152,9 @@ testEntryAndExitPoints (const Box3f& box) do { p2 = V3f ( - random.nextf (box.min.x, box.max.x), - random.nextf (box.min.y, box.max.y), - random.nextf (box.min.z, box.max.z)); + float(random.nextf (box.min.x, box.max.x)), + float(random.nextf (box.min.y, box.max.y)), + float(random.nextf (box.min.z, box.max.z))); } while (approximatelyEqual (p1, p2, e)); Line3f ray (p1, p2); @@ -423,9 +423,9 @@ testRayBoxIntersection (const Box3f& box) for (int i = 0; i < 100000; ++i) { V3f p1 ( - random.nextf (box.max.x, box.min.x), - random.nextf (box.max.y, box.min.y), - random.nextf (box.max.z, box.min.z)); + float(random.nextf (box.max.x, box.min.x)), + float(random.nextf (box.max.y, box.min.y)), + float(random.nextf (box.max.z, box.min.z))); V3f p2 (p1 + hollowSphereRand (random)); @@ -471,8 +471,8 @@ testRayBoxIntersection (const Box3f& box) // box, and it passes the box at a minimum distance of r1. // - const float r1 = 0.00001; - const float r2 = 1.0; + const float r1 = 0.00001f; + const float r2 = 1.0f; V3f p1 = box.min + r2 * hollowSphereRand (random); V3f p2; @@ -504,9 +504,9 @@ testRayBoxIntersection (const Box3f& box) for (int i = 0; i < 1000; ++i) { V3f p1 ( - random.nextf (box.min.x, box.max.x), - random.nextf (box.min.y, box.max.y), - random.nextf (box.min.z, box.max.z)); + float(random.nextf (box.min.x, box.max.x)), + float(random.nextf (box.min.y, box.max.y)), + float(random.nextf (box.min.z, box.max.z))); V3f p2 (p1 + hollowSphereRand (random)); @@ -531,9 +531,9 @@ testRayBoxIntersection (const Box3f& box) do { p1 = V3f ( - random.nextf (bigBox.min.x, bigBox.max.x), - random.nextf (bigBox.min.y, bigBox.max.y), - random.nextf (bigBox.min.z, bigBox.max.z)); + float(random.nextf (bigBox.min.x, bigBox.max.x)), + float(random.nextf (bigBox.min.y, bigBox.max.y)), + float(random.nextf (bigBox.min.z, bigBox.max.z))); } while (box.intersects (p1)); V3f p2; @@ -541,9 +541,9 @@ testRayBoxIntersection (const Box3f& box) do { p2 = V3f ( - random.nextf (box.min.x, box.max.x), - random.nextf (box.min.y, box.max.y), - random.nextf (box.min.z, box.max.z)); + float(random.nextf (box.min.x, box.max.x)), + float(random.nextf (box.min.y, box.max.y)), + float(random.nextf (box.min.z, box.max.z))); } while (approximatelyEqual (p1, p2, e)); Line3f ray (p1, p2); diff --git a/src/ImathTest/testColor.cpp b/src/ImathTest/testColor.cpp index bf2c072b..8a74bafe 100644 --- a/src/ImathTest/testColor.cpp +++ b/src/ImathTest/testColor.cpp @@ -38,7 +38,7 @@ testColor () assert (in3 == out3); IMATH_INTERNAL_NAMESPACE::C4c testConstructor1; - IMATH_INTERNAL_NAMESPACE::C4c testConstructor1i (0.f); + IMATH_INTERNAL_NAMESPACE::C4c testConstructor1i (0); IMATH_INTERNAL_NAMESPACE::C4c testConstructor2 (testConstructor1i); testConstructor1 = diff --git a/src/ImathTest/testExtractEuler.cpp b/src/ImathTest/testExtractEuler.cpp index a3826a34..b77e9b54 100644 --- a/src/ImathTest/testExtractEuler.cpp +++ b/src/ImathTest/testExtractEuler.cpp @@ -24,7 +24,7 @@ namespace float rad (float deg) { - return deg * (M_PI / 180); + return deg * float(M_PI / 180); } M44f @@ -103,9 +103,9 @@ testRandomAngles ( // Eulerf e ( - rad (r.nextf (-180, 180)), - rad (r.nextf (-180, 180)), - rad (r.nextf (-180, 180)), + rad (float(r.nextf (-180, 180))), + rad (float(r.nextf (-180, 180))), + rad (float(r.nextf (-180, 180))), Eulerf::XYZ); M44f M (e.toMatrix44 ()); @@ -116,7 +116,7 @@ testRandomAngles ( for (int j = 0; j < 3; ++j) for (int k = 0; k < 3; ++k) - M[j][k] += r.nextf (-1e-7, 1e-7); + M[j][k] += float(r.nextf (-1e-7, 1e-7)); // // Extract Euler angles from M, convert the Euler angles @@ -176,7 +176,7 @@ test ( for (int i = 0; i < 360; i += 90) for (int j = 0; j < 360; j += 90) for (int k = 0; k < 360; k += 90) - testAngles (V3f (i, j, k), matrixEulerMatrix, order); + testAngles (V3f (float(i), float(j), float(k)), matrixEulerMatrix, order); } void @@ -184,11 +184,11 @@ testRandomAngles33 () { Rand48 r (0); - float eps = 8.0 * std::numeric_limits::epsilon (); + float eps = 8.0f * std::numeric_limits::epsilon (); for (int i = 0; i < 100000; ++i) { - float angle = rad (r.nextf (-180, 180)); + float angle = rad (float(r.nextf (-180, 180))); M33f M; M.setRotation (angle); diff --git a/src/ImathTest/testExtractSHRT.cpp b/src/ImathTest/testExtractSHRT.cpp index 0b0a9852..50e97069 100644 --- a/src/ImathTest/testExtractSHRT.cpp +++ b/src/ImathTest/testExtractSHRT.cpp @@ -32,7 +32,7 @@ namespace float rad (float deg) { - return deg * (M_PI / 180); + return deg * float(M_PI / 180); } void @@ -108,7 +108,8 @@ testRandomAngles33 () // Scale M. // - V2f s (random.nextf (0.000001, 2.0), random.nextf (0.000001, 2.0)); + V2f s (float(random.nextf (0.000001, 2.0)), + float(random.nextf (0.000001, 2.0))); for (int j = 0; j < 2; j++) if (random.nextf (0.0, 1.0) >= 0.5) s[j] *= -1; @@ -119,7 +120,7 @@ testRandomAngles33 () // Shear M. // - float h = random.nextf (0.000001, 2.); + float h = float(random.nextf (0.000001, 2.)); if (random.nextf (0.0, 1.0) >= 0.5) h *= -1; M *= M33f ().setShear (h); @@ -128,7 +129,7 @@ testRandomAngles33 () // Rotate M. // - float r = rad (random.nextf (-180, 180)); + float r = rad (float(random.nextf (-180, 180))); M *= M33f ().setRotation (r); @@ -136,7 +137,8 @@ testRandomAngles33 () // Translate M. // - V2f t (random.nextf (-10, 10), random.nextf (-10, 10)); + V2f t (float(random.nextf (-10, 10)), + float(random.nextf (-10, 10))); M *= M33f ().setTranslation (t); @@ -146,7 +148,7 @@ testRandomAngles33 () for (int j = 0; j < 3; ++j) for (int k = 0; k < 2; ++k) - M[j][k] += random.nextf (-1e-7, 1e-7); + M[j][k] += float(random.nextf (-1e-7, 1e-7)); debug (("Scale : %f %f\n", s[0], s[1])); debug (("Shear : %f\n", h)); @@ -263,9 +265,9 @@ testRandomAngles44 () // V3f t ( - random.nextf (-10, 10), - random.nextf (-10, 10), - random.nextf (-10, 10)); + float(random.nextf (-10, 10)), + float(random.nextf (-10, 10)), + float(random.nextf (-10, 10))); M.translate (t); @@ -274,9 +276,9 @@ testRandomAngles44 () // V3f r ( - rad (random.nextf (-180, 180)), - rad (random.nextf (-180, 180)), - rad (random.nextf (-180, 180))); + rad (float(random.nextf (-180, 180))), + rad (float(random.nextf (-180, 180))), + rad (float(random.nextf (-180, 180)))); M.rotate (r); @@ -285,9 +287,9 @@ testRandomAngles44 () // V3f h ( - random.nextf (0.000001, 2.0), - random.nextf (0.000001, 2.0), - random.nextf (0.000001, 2.0)); + float(random.nextf (0.000001, 2.0)), + float(random.nextf (0.000001, 2.0)), + float(random.nextf (0.000001, 2.0))); for (int j = 0; j < 3; j++) if (random.nextf (0.0, 1.0) >= 0.5) h[j] *= -1; @@ -299,9 +301,9 @@ testRandomAngles44 () // V3f s ( - random.nextf (0.000001, 2.0), - random.nextf (0.000001, 2.0), - random.nextf (0.000001, 2.0)); + float(random.nextf (0.000001, 2.0)), + float(random.nextf (0.000001, 2.0)), + float(random.nextf (0.000001, 2.0))); for (int j = 0; j < 3; j++) if (random.nextf (0.0, 1.0) >= 0.5) s[j] *= -1; @@ -314,7 +316,7 @@ testRandomAngles44 () for (int j = 0; j < 4; ++j) for (int k = 0; k < 3; ++k) - M[j][k] += random.nextf (-1e-7, 1e-7); + M[j][k] += float(random.nextf (-1e-7, 1e-7)); debug (("Scale : %f %f %f\n", s[0], s[1], s[2])); debug (("Shear : %f %f %f\n", h[0], h[1], h[2])); @@ -384,7 +386,7 @@ test () for (int i = 0; i < 360; i += 90) for (int j = 0; j < 360; j += 90) for (int k = 0; k < 360; k += 90) - testAngles44 (V3f (i, j, k)); + testAngles44 (V3f (float(i), float(j), float(k))); } } // namespace diff --git a/src/ImathTest/testFrustum.cpp b/src/ImathTest/testFrustum.cpp index 70d8826b..c3416b0e 100644 --- a/src/ImathTest/testFrustum.cpp +++ b/src/ImathTest/testFrustum.cpp @@ -28,7 +28,7 @@ testFrustumPlanes (IMATH_INTERNAL_NAMESPACE::Frustumf& frustum) { bool ortho = frustum.orthographic (); IMATH_INTERNAL_NAMESPACE::V3f o (0.0f, 0.0f, 0.0f); - float eps = 5.0e-4; + float eps = 5.0e-4f; for (auto xRo: {0.0f, 100.0f, 200.0f}) { @@ -174,12 +174,12 @@ testFrustum () cout << "\nperspective "; - float n = 1.7; - float f = 567.0; - float l = -3.5; - float r = 2.0; - float b = -1.3; - float t = 0.9; + float n = 1.7f; + float f = 567.0f; + float l = -3.5f; + float r = 2.0f; + float b = -1.3f; + float t = 0.9f; IMATH_INTERNAL_NAMESPACE::Frustum frustum (n, f, l, r, t, b, false); @@ -201,51 +201,51 @@ testFrustum () IMATH_INTERNAL_NAMESPACE::M44f m = frustum.projectionMatrixExc (); assert ( IMATH_INTERNAL_NAMESPACE::abs (m[0][0] - ((2 * n) / (r - l))) < - 1e-6 && - IMATH_INTERNAL_NAMESPACE::abs (m[0][1]) < 1e-6 && - IMATH_INTERNAL_NAMESPACE::abs (m[0][2]) < 1e-6 && - IMATH_INTERNAL_NAMESPACE::abs (m[0][3]) < 1e-6 && - IMATH_INTERNAL_NAMESPACE::abs (m[1][0]) < 1e-6 && + 1e-6f && + IMATH_INTERNAL_NAMESPACE::abs (m[0][1]) < 1e-6f && + IMATH_INTERNAL_NAMESPACE::abs (m[0][2]) < 1e-6f && + IMATH_INTERNAL_NAMESPACE::abs (m[0][3]) < 1e-6f && + IMATH_INTERNAL_NAMESPACE::abs (m[1][0]) < 1e-6f && IMATH_INTERNAL_NAMESPACE::abs (m[1][1] - ((2 * n) / (t - b))) < - 1e-6 && - IMATH_INTERNAL_NAMESPACE::abs (m[1][2]) < 1e-6 && - IMATH_INTERNAL_NAMESPACE::abs (m[1][3]) < 1e-6 && + 1e-6f && + IMATH_INTERNAL_NAMESPACE::abs (m[1][2]) < 1e-6f && + IMATH_INTERNAL_NAMESPACE::abs (m[1][3]) < 1e-6f && IMATH_INTERNAL_NAMESPACE::abs (m[2][0] - ((r + l) / (r - l))) < - 1e-6 && + 1e-6f && IMATH_INTERNAL_NAMESPACE::abs (m[2][1] - ((t + b) / (t - b))) < - 1e-6 && + 1e-6f && IMATH_INTERNAL_NAMESPACE::abs (m[2][2] - (-(f + n) / (f - n))) < - 1e-6 && - IMATH_INTERNAL_NAMESPACE::abs (m[2][3] - -1.0) < 1e-6 && - IMATH_INTERNAL_NAMESPACE::abs (m[3][0]) < 1e-6 && - IMATH_INTERNAL_NAMESPACE::abs (m[3][1]) < 1e-6 && + 1e-6f && + IMATH_INTERNAL_NAMESPACE::abs (m[2][3] - -1.0f) < 1e-6f && + IMATH_INTERNAL_NAMESPACE::abs (m[3][0]) < 1e-6f && + IMATH_INTERNAL_NAMESPACE::abs (m[3][1]) < 1e-6f && IMATH_INTERNAL_NAMESPACE::abs ( - m[3][2] - ((-2 * f * n) / (f - n))) < 1e-6 && - IMATH_INTERNAL_NAMESPACE::abs (m[3][3]) < 1e-6); + m[3][2] - ((-2 * f * n) / (f - n))) < 1e-6f && + IMATH_INTERNAL_NAMESPACE::abs (m[3][3]) < 1e-6f); m = frustum.projectionMatrix (); assert ( IMATH_INTERNAL_NAMESPACE::abs (m[0][0] - ((2 * n) / (r - l))) < - 1e-6 && - IMATH_INTERNAL_NAMESPACE::abs (m[0][1]) < 1e-6 && - IMATH_INTERNAL_NAMESPACE::abs (m[0][2]) < 1e-6 && - IMATH_INTERNAL_NAMESPACE::abs (m[0][3]) < 1e-6 && - IMATH_INTERNAL_NAMESPACE::abs (m[1][0]) < 1e-6 && + 1e-6f && + IMATH_INTERNAL_NAMESPACE::abs (m[0][1]) < 1e-6f && + IMATH_INTERNAL_NAMESPACE::abs (m[0][2]) < 1e-6f && + IMATH_INTERNAL_NAMESPACE::abs (m[0][3]) < 1e-6f && + IMATH_INTERNAL_NAMESPACE::abs (m[1][0]) < 1e-6f && IMATH_INTERNAL_NAMESPACE::abs (m[1][1] - ((2 * n) / (t - b))) < - 1e-6 && + 1e-6f && IMATH_INTERNAL_NAMESPACE::abs (m[1][2]) < 1e-6 && IMATH_INTERNAL_NAMESPACE::abs (m[1][3]) < 1e-6 && IMATH_INTERNAL_NAMESPACE::abs (m[2][0] - ((r + l) / (r - l))) < - 1e-6 && + 1e-6f && IMATH_INTERNAL_NAMESPACE::abs (m[2][1] - ((t + b) / (t - b))) < - 1e-6 && + 1e-6f && IMATH_INTERNAL_NAMESPACE::abs (m[2][2] - (-(f + n) / (f - n))) < - 1e-6 && - IMATH_INTERNAL_NAMESPACE::abs (m[2][3] - -1.0) < 1e-6 && - IMATH_INTERNAL_NAMESPACE::abs (m[3][0]) < 1e-6 && - IMATH_INTERNAL_NAMESPACE::abs (m[3][1]) < 1e-6 && + 1e-6f && + IMATH_INTERNAL_NAMESPACE::abs (m[2][3] - -1.0f) < 1e-6f && + IMATH_INTERNAL_NAMESPACE::abs (m[3][0]) < 1e-6f && + IMATH_INTERNAL_NAMESPACE::abs (m[3][1]) < 1e-6f && IMATH_INTERNAL_NAMESPACE::abs ( - m[3][2] - ((-2 * f * n) / (f - n))) < 1e-6 && - IMATH_INTERNAL_NAMESPACE::abs (m[3][3]) < 1e-6); + m[3][2] - ((-2 * f * n) / (f - n))) < 1e-6f && + IMATH_INTERNAL_NAMESPACE::abs (m[3][3]) < 1e-6f); cout << "3"; cout << "\nplanes "; @@ -304,26 +304,26 @@ testFrustum () m = frustum.projectionMatrix (); assert ( - IMATH_INTERNAL_NAMESPACE::abs (m[0][0] - (2 / (r - l))) < 1e-6 && - IMATH_INTERNAL_NAMESPACE::abs (m[0][1]) < 1e-6 && - IMATH_INTERNAL_NAMESPACE::abs (m[0][2]) < 1e-6 && - IMATH_INTERNAL_NAMESPACE::abs (m[0][3]) < 1e-6 && - IMATH_INTERNAL_NAMESPACE::abs (m[1][0]) < 1e-6 && - IMATH_INTERNAL_NAMESPACE::abs (m[1][1] - (2 / (t - b))) < 1e-6 && - IMATH_INTERNAL_NAMESPACE::abs (m[1][2]) < 1e-6 && - IMATH_INTERNAL_NAMESPACE::abs (m[1][3]) < 1e-6 && - IMATH_INTERNAL_NAMESPACE::abs (m[2][0]) < 1e-6 && - IMATH_INTERNAL_NAMESPACE::abs (m[2][1]) < 1e-6 && + IMATH_INTERNAL_NAMESPACE::abs (m[0][0] - (2 / (r - l))) < 1e-6f && + IMATH_INTERNAL_NAMESPACE::abs (m[0][1]) < 1e-6f && + IMATH_INTERNAL_NAMESPACE::abs (m[0][2]) < 1e-6f && + IMATH_INTERNAL_NAMESPACE::abs (m[0][3]) < 1e-6f && + IMATH_INTERNAL_NAMESPACE::abs (m[1][0]) < 1e-6f && + IMATH_INTERNAL_NAMESPACE::abs (m[1][1] - (2 / (t - b))) < 1e-6f && + IMATH_INTERNAL_NAMESPACE::abs (m[1][2]) < 1e-6f && + IMATH_INTERNAL_NAMESPACE::abs (m[1][3]) < 1e-6f && + IMATH_INTERNAL_NAMESPACE::abs (m[2][0]) < 1e-6f && + IMATH_INTERNAL_NAMESPACE::abs (m[2][1]) < 1e-6f && IMATH_INTERNAL_NAMESPACE::abs (m[2][2] - (-2 / (f - n))) < - 1e-6 && - IMATH_INTERNAL_NAMESPACE::abs (m[2][3]) < 1e-6 && + 1e-6f && + IMATH_INTERNAL_NAMESPACE::abs (m[2][3]) < 1e-6f && IMATH_INTERNAL_NAMESPACE::abs (m[3][0] - (-(r + l) / (r - l))) < - 1e-6 && + 1e-6f && IMATH_INTERNAL_NAMESPACE::abs (m[3][1] - (-(t + b) / (t - b))) < - 1e-6 && + 1e-6f && IMATH_INTERNAL_NAMESPACE::abs (m[3][2] - (-(f + n) / (f - n))) < - 1e-6 && - IMATH_INTERNAL_NAMESPACE::abs (m[3][3] - 1.0) < 1e-6); + 1e-6f && + IMATH_INTERNAL_NAMESPACE::abs (m[3][3] - 1.0f) < 1e-6f); cout << "1"; cout << "\nplanes "; @@ -336,17 +336,17 @@ testFrustum () IMATH_INTERNAL_NAMESPACE::Frustum f1 (n, f, l, r, t, b, false); IMATH_INTERNAL_NAMESPACE::Frustum f2 (n, f, l, r, t, b, true); assert (f1 != f2); - f2.set (n + 0.1, f, l, r, t, b, false); + f2.set (n + 0.1f, f, l, r, t, b, false); assert (f1 != f2); - f2.set (n, f + 0.1, l, r, t, b, false); + f2.set (n, f + 0.1f, l, r, t, b, false); assert (f1 != f2); - f2.set (n, f, l + 0.1, r, t, b, false); + f2.set (n, f, l + 0.1f, r, t, b, false); assert (f1 != f2); - f2.set (n, f, l, r + 0.1, t, b, false); + f2.set (n, f, l, r + 0.1f, t, b, false); assert (f1 != f2); - f2.set (n, f, l, r, t + 0.1, b, false); + f2.set (n, f, l, r, t + 0.1f, b, false); assert (f1 != f2); - f2.set (n, f, l, r, t, b + 0.1, false); + f2.set (n, f, l, r, t, b + 0.1f, false); assert (f1 != f2); cout << "\npassed inequality test"; @@ -367,7 +367,7 @@ testFrustum () assert ( f1.ZToDepth (zMin, zMin, zMax) == f1.ZToDepthExc (zMin, zMin, zMax)); - assert (f1.normalizedZToDepth (zMin) == f1.normalizedZToDepthExc (zMin)); + assert (f1.normalizedZToDepth (float(zMin)) == f1.normalizedZToDepthExc (float(zMin))); assert (f1.DepthToZ (n, zMin, zMax) == f1.DepthToZExc (n, zMin, zMax)); assert (f1.worldRadius (v3, one) == f1.worldRadiusExc (v3, one)); assert (f1.screenRadius (v3, one) == f1.screenRadiusExc (v3, one)); diff --git a/src/ImathTest/testFrustumTest.cpp b/src/ImathTest/testFrustumTest.cpp index 1a23e0f2..431c86cd 100644 --- a/src/ImathTest/testFrustumTest.cpp +++ b/src/ImathTest/testFrustumTest.cpp @@ -27,12 +27,12 @@ testFrustumTest () cout << "\nisVisible(Vec3) "; - float n = 1.7; - float f = 567.0; - float l = -3.5; - float r = 2.0; - float b = -1.3; - float t = 0.9; + float n = 1.7f; + float f = 567.0f; + float l = -3.5f; + float r = 2.0f; + float b = -1.3f; + float t = 0.9f; IMATH_INTERNAL_NAMESPACE::Frustum frustum (n, f, l, r, t, b, false); diff --git a/src/ImathTest/testFun.cpp b/src/ImathTest/testFun.cpp index c69ecd44..99cbe8d3 100644 --- a/src/ImathTest/testFun.cpp +++ b/src/ImathTest/testFun.cpp @@ -90,11 +90,11 @@ testd (double d, bool changeExpected = true) double psd = IMATH_INTERNAL_NAMESPACE::predd (IMATH_INTERNAL_NAMESPACE::succd (d)); - printf ("d %0.18lg %lx\n", d, bit_cast (d)); - printf ("sd %0.18lg %lx\n", sd, bit_cast (sd)); - printf ("pd %0.18lg %lx\n", pd, bit_cast (pd)); - printf ("spd %0.18lg %lx\n", spd, bit_cast (spd)); - printf ("psd %0.18lg %lx\n", psd, bit_cast (psd)); + printf ("d %0.18lg %llx\n", d, bit_cast (d)); + printf ("sd %0.18lg %llx\n", sd, bit_cast (sd)); + printf ("pd %0.18lg %llx\n", pd, bit_cast (pd)); + printf ("spd %0.18lg %llx\n", spd, bit_cast (spd)); + printf ("psd %0.18lg %llx\n", psd, bit_cast (psd)); fflush (stdout); @@ -299,12 +299,12 @@ testFun () cout << "successor, predecessor" << endl; testf (0); - testf (0.0 * -1.0); + testf (0.0f * -1.0f); testf (1); testf (-1); testf (16); testf (7); - testf (0.7); + testf (0.7f); union { diff --git a/src/ImathTest/testInterop.cpp b/src/ImathTest/testInterop.cpp index 35b54354..617e2f37 100644 --- a/src/ImathTest/testInterop.cpp +++ b/src/ImathTest/testInterop.cpp @@ -582,8 +582,8 @@ testInteropMx2 () for (int j = 0; j < 2; ++j) for (int i = 0; i < 2; ++i) { - s[j][i] = i + j * 2; - ref[j][i] = i + j * 2; + s[j][i] = float(i + j * 2); + ref[j][i] = float(i + j * 2); } Matrix22 v (s); assert (v[0][0] == 0 && v[0][1] == 1 && v[1][0] == 2 && v[1][1] == 3); @@ -626,8 +626,8 @@ testInteropMx3 () for (int j = 0; j < 3; ++j) for (int i = 0; i < 3; ++i) { - s[j][i] = i + j * 3; - ref[j][i] = i + j * 3; + s[j][i] = float(i + j * 3); + ref[j][i] = float(i + j * 3); } Matrix33 v (s); assert ( @@ -676,8 +676,8 @@ testInteropMx4 () for (int j = 0; j < 4; ++j) for (int i = 0; i < 4; ++i) { - s[j][i] = i + j * 4; - ref[j][i] = i + j * 4; + s[j][i] = float(i + j * 4); + ref[j][i] = float(i + j * 4); } Matrix44 v (s); assert ( diff --git a/src/ImathTest/testInterval.cpp b/src/ImathTest/testInterval.cpp index 9c31a869..66d9b4f8 100644 --- a/src/ImathTest/testInterval.cpp +++ b/src/ImathTest/testInterval.cpp @@ -168,7 +168,7 @@ testExtendByPoint (const char* type) // for (unsigned int i = 0; i < iters; i++) { - T p (rand.nextf (-12345, 12345)); + T p (static_cast(rand.nextf (-12345, 12345))); IMATH_INTERNAL_NAMESPACE::Interval b; b.extendBy (p); assert (b.min == p && b.max == p); @@ -187,7 +187,7 @@ testExtendByPoint (const char* type) for (unsigned int j = 0; j < i; j++) { - T p (rand.nextf (-12345, 12345)); + T p (static_cast(rand.nextf (-12345, 12345))); if (j == 0) { @@ -250,8 +250,8 @@ testExtendByInterval (const char* type) for (unsigned int i = 1; i < iters; i++) { - T p0 (rand.nextf (0, 999)); - T p1 (rand.nextf (1000, 1999)); + T p0 (static_cast(rand.nextf (0, 999))); + T p1 (static_cast(rand.nextf (1000, 1999))); min = b.min; max = b.max; diff --git a/src/ImathTest/testInvert.cpp b/src/ImathTest/testInvert.cpp index 1f8c5ef6..32a30a69 100644 --- a/src/ImathTest/testInvert.cpp +++ b/src/ImathTest/testInvert.cpp @@ -78,23 +78,23 @@ testInvert () 0, 0, 0, -1, 0, 0, 1, 0); - M44f m4 ( 4.683281e-01, -8.749647e-01, 1.229049e-01, 0.000000e+00, - 1.251189e-02, 1.456563e-01, 9.892561e-01, 0.000000e+00, - -8.834660e-01, -4.617587e-01, 7.916244e-02, 0.000000e+00, - -4.726541e+00, 3.044795e+00, -6.737138e+00, 1.000000e+00); + M44f m4 ( 4.683281e-01f, -8.749647e-01f, 1.229049e-01f, 0.000000e+00f, + 1.251189e-02f, 1.456563e-01f, 9.892561e-01f, 0.000000e+00f, + -8.834660e-01f, -4.617587e-01f, 7.916244e-02f, 0.000000e+00f, + -4.726541e+00f, 3.044795e+00f, -6.737138e+00f, 1.000000e+00f); - M44f m5 ( 4.683281e-01, -8.749647e-01, 1.229049e-01, 1.000000e+00, - 1.251189e-02, 1.456563e-01, 9.892561e-01, 2.000000e+00, - -8.834660e-01, -4.617587e-01, 7.916244e-02, 3.000000e+00, - -4.726541e+00, 3.044795e+00, -6.737138e+00, 4.000000e+00); + M44f m5 ( 4.683281e-01f, -8.749647e-01f, 1.229049e-01f, 1.000000e+00f, + 1.251189e-02f, 1.456563e-01f, 9.892561e-01f, 2.000000e+00f, + -8.834660e-01f, -4.617587e-01f, 7.916244e-02f, 3.000000e+00f, + -4.726541e+00f, 3.044795e+00f, -6.737138e+00f, 4.000000e+00f); // clang-format on invertM44f (m1, 0); invertM44f (m2, 0); invertM44f (m3, 0); - invertM44f (m4, 1e-6); - invertM44f (m5, 1e-6); + invertM44f (m4, 1e-6f); + invertM44f (m5, 1e-6f); } { @@ -114,21 +114,21 @@ testInvert () 0, 0, -1, 0, 1, 0); - M33f m4 ( 4.683281e-01, -8.749647e-01, 0.000000e+00, - 1.251189e-02, 1.456563e-01, 0.000000e+00, - 0.000000e+00, 0.000000e+00, 1.000000e+00); + M33f m4 ( 4.683281e-01f, -8.749647e-01f, 0.000000e+00f, + 1.251189e-02f, 1.456563e-01f, 0.000000e+00f, + 0.000000e+00f, 0.000000e+00f, 1.000000e+00f); - M33f m5 ( 4.683281e-01, -8.749647e-01, 1.229049e-01, - 1.251189e-02, 1.456563e-01, 9.892561e-01, - -8.834660e-01, -4.617587e-01, 7.916244e-02); + M33f m5 ( 4.683281e-01f, -8.749647e-01f, 1.229049e-01f, + 1.251189e-02f, 1.456563e-01f, 9.892561e-01f, + -8.834660e-01f, -4.617587e-01f, 7.916244e-02f); // clang-format on invertM33f (m1, 0); invertM33f (m2, 0); invertM33f (m3, 0); - invertM33f (m4, 1e-6); - invertM33f (m5, 1e-6); + invertM33f (m4, 1e-6f); + invertM33f (m5, 1e-6f); } cout << "ok\n" << endl; diff --git a/src/ImathTest/testJacobiEigenSolver.cpp b/src/ImathTest/testJacobiEigenSolver.cpp index 8c202e06..cc9ab654 100644 --- a/src/ImathTest/testJacobiEigenSolver.cpp +++ b/src/ImathTest/testJacobiEigenSolver.cpp @@ -63,8 +63,8 @@ void verifyOrthonormal (const TM& A, const typename TM::BaseType threshold) { const TM prod = A * A.transposed (); - for (size_t i = 0; i < TM::dimensions (); ++i) - for (size_t j = 0; j < TM::dimensions (); ++j) + for (unsigned int i = 0; i < TM::dimensions (); ++i) + for (unsigned int j = 0; j < TM::dimensions (); ++j) if (i == j) assert (std::abs (prod[i][j] - 1) < threshold); else @@ -78,8 +78,8 @@ computeThreshold (const TM& A) typedef typename TM::BaseType T; T maxAbsEntry (0); - for (size_t i = 0; i < TM::dimensions (); ++i) - for (size_t j = 0; j < TM::dimensions (); ++j) + for (unsigned int i = 0; i < TM::dimensions (); ++i) + for (unsigned int j = 0; j < TM::dimensions (); ++j) maxAbsEntry = std::max (maxAbsEntry, std::abs (A[i][j])); const T eps = std::numeric_limits::epsilon (); @@ -113,8 +113,8 @@ testJacobiEigenSolver (const TM& A) // Determinant of A and S TM MS; - for (size_t i = 0; i < TM::dimensions (); ++i) - for (size_t j = 0; j < TM::dimensions (); ++j) + for (unsigned int i = 0; i < TM::dimensions (); ++i) + for (unsigned int j = 0; j < TM::dimensions (); ++j) if (i == j) MS[i][j] = S[i]; else @@ -125,8 +125,8 @@ testJacobiEigenSolver (const TM& A) // A = V * S * V^T TM MA = V * MS * V.transposed (); - for (size_t i = 0; i < TM::dimensions (); ++i) - for (size_t j = 0; j < TM::dimensions (); ++j) + for (unsigned int i = 0; i < TM::dimensions (); ++i) + for (unsigned int j = 0; j < TM::dimensions (); ++j) assert (abs (A[i][j] - MA[i][j]) < threshold); } diff --git a/src/ImathTest/testLineAlgo.cpp b/src/ImathTest/testLineAlgo.cpp index 503f4a68..ea873840 100644 --- a/src/ImathTest/testLineAlgo.cpp +++ b/src/ImathTest/testLineAlgo.cpp @@ -372,8 +372,8 @@ testIntersect () do { - b.x = rand.nextf (0.001, 0.999); - b.y = rand.nextf (0.001, 0.999); + b.x = float(rand.nextf (0.001, 0.999)); + b.y = float(rand.nextf (0.001, 0.999)); b.z = 1 - b.x - b.y; } while (b.x + b.y > 0.999); @@ -416,8 +416,8 @@ testIntersect () do { - b.x = rand.nextf (-3, 3); - b.y = rand.nextf (-3, 3); + b.x = float(rand.nextf (-3, 3)); + b.y = float(rand.nextf (-3, 3)); b.z = 1 - b.x - b.y; } while (b.x > -0.001 && b.y > -0.001 && b.z > -0.001); diff --git a/src/ImathTest/testMiscMatrixAlgo.cpp b/src/ImathTest/testMiscMatrixAlgo.cpp index 9b1aced1..62dd5629 100644 --- a/src/ImathTest/testMiscMatrixAlgo.cpp +++ b/src/ImathTest/testMiscMatrixAlgo.cpp @@ -30,13 +30,13 @@ namespace float rad (float deg) { - return deg * (M_PI / 180); + return deg * float(M_PI / 180); } void testComputeLocalFrame () { - float eps = 0.00005; + float eps = 0.00005f; Rand48 random (0); for (int i = 0; i < 100000; ++i) { @@ -44,21 +44,21 @@ testComputeLocalFrame () // Random pos V3f p ( - random.nextf (-10, 10), - random.nextf (-10, 10), - random.nextf (-10, 10)); + float(random.nextf (-10, 10)), + float(random.nextf (-10, 10)), + float(random.nextf (-10, 10))); // Random xDir V3f xDir ( - random.nextf (-10, 10), - random.nextf (-10, 10), - random.nextf (-10, 10)); + float(random.nextf (-10, 10)), + float(random.nextf (-10, 10)), + float(random.nextf (-10, 10))); // Random normalDir V3f normalDir ( - random.nextf (-10, 10), - random.nextf (-10, 10), - random.nextf (-10, 10)); + float(random.nextf (-10, 10)), + float(random.nextf (-10, 10)), + float(random.nextf (-10, 10))); // Run computeLocalFrame we want to test M44f L = computeLocalFrame (p, xDir, normalDir); @@ -101,18 +101,20 @@ getRandTRS (Rand48& random, V3f& trans, V3f& rot, V3f& scale) { // Translate trans = V3f ( - random.nextf (-10, 10), random.nextf (-10, 10), random.nextf (-10, 10)); + float(random.nextf (-10, 10)), + float(random.nextf (-10, 10)), + float(random.nextf (-10, 10))); // Rotate rot = V3f ( - rad (random.nextf (-180, 180)), - rad (random.nextf (-180, 180)), - rad (random.nextf (-180, 180))); + rad (float(random.nextf (-180, 180))), + rad (float(random.nextf (-180, 180))), + rad (float(random.nextf (-180, 180)))); // Scale V3f s ( - random.nextf (0.000001, 2.0), - random.nextf (0.000001, 2.0), - random.nextf (0.000001, 2.0)); + float(random.nextf (0.000001, 2.0)), + float(random.nextf (0.000001, 2.0)), + float(random.nextf (0.000001, 2.0))); for (int j = 0; j < 3; j++) if (random.nextf (0.0, 1.0) >= 0.5) s[j] *= -1; scale = s; @@ -131,9 +133,9 @@ createRandomMat (Rand48& random, V3f& trans, V3f& rot, V3f& scale) // Shear M. V3f h ( - random.nextf (0.000001, 2.0), - random.nextf (0.000001, 2.0), - random.nextf (0.000001, 2.0)); + float(random.nextf (0.000001, 2.0)), + float(random.nextf (0.000001, 2.0)), + float(random.nextf (0.000001, 2.0))); for (int j = 0; j < 3; j++) if (random.nextf (0.0, 1.0) >= 0.5) h[j] *= -1; @@ -146,7 +148,7 @@ createRandomMat (Rand48& random, V3f& trans, V3f& rot, V3f& scale) // for (int j = 0; j < 4; ++j) for (int k = 0; k < 3; ++k) - M[j][k] += random.nextf (-1e-7, 1e-7); + M[j][k] += float(random.nextf (-1e-7, 1e-7)); V3f sh; extractSHRT (M, scale, sh, rot, trans); @@ -162,7 +164,7 @@ createRandomMat (Rand48& random, V3f& trans, V3f& rot, V3f& scale) void compareMat (M44f& M, M44f& N) { - float eps = 0.0001; + float eps = 0.0001f; /// Verify that the entries in M and N do not // differ too much. diff --git a/src/ImathTest/testProcrustes.cpp b/src/ImathTest/testProcrustes.cpp index a141d908..90daf28d 100644 --- a/src/ImathTest/testProcrustes.cpp +++ b/src/ImathTest/testProcrustes.cpp @@ -48,7 +48,7 @@ testTranslationRotationMatrix (const IMATH_INTERNAL_NAMESPACE::M44d& mat) const IMATH_INTERNAL_NAMESPACE::M44d m2 = procrustesRotationAndTranslation (&from[0], &to[0], numPoints); - const T eps = sizeof (T) == 8 ? 1e-8 : 1e-4; + const T eps = sizeof (T) == 8 ? T(1e-8) : T(1e-4); for (size_t i = 0; i < numPoints; ++i) { const IMATH_INTERNAL_NAMESPACE::V3d a = from[i]; @@ -75,12 +75,15 @@ testWithTranslateRotateAndScale (const IMATH_INTERNAL_NAMESPACE::M44d& m) std::vector from; std::vector weights; - const float eps = 1e-4; + const float eps = 1e-4f; std::cout << "numPoints: " << std::flush; for (size_t numPoints = 1; numPoints < 10; ++numPoints) { - from.push_back (V3 (rand.nextf (), rand.nextf (), rand.nextf ())); - weights.push_back (rand.nextf ()); + from.push_back (V3( + static_cast(rand.nextf()), + static_cast(rand.nextf()), + static_cast(rand.nextf()))); + weights.push_back(static_cast(rand.nextf())); std::cout << from.size () << " "; std::vector to; @@ -157,7 +160,7 @@ verifyProcrustes ( // Now try the weighted version: for (size_t i = 0; i < weights.size (); ++i) - weights[i] = i + 1; + weights[i] = static_cast(i + 1); IMATH_INTERNAL_NAMESPACE::M44d m = procrustesRotationAndTranslation (&from[0], &to[0], &weights[0], n); @@ -167,7 +170,7 @@ verifyProcrustes ( &from[0], &to[0], &weights[0], n, true); // Verify that it's orthonormal w/ positive determinant. - const T det = m.determinant (); + const T det = static_cast(m.determinant ()); assert (std::abs (det - T (1)) < eps); // Verify orthonormal: @@ -219,15 +222,15 @@ verifyProcrustes ( // Try a small scale: IMATH_INTERNAL_NAMESPACE::M44d newMat = ms; const double scaleDiff = delta; - for (size_t i = 0; i < 3; ++i) - for (size_t j = 0; j < 3; ++j) + for (int i = 0; i < 3; ++i) + for (int j = 0; j < 3; ++j) newMat[i][j] = ms[i][j] * (1.0 + scaleDiff); assert ( procrustesError (&from[0], &to[0], &weights[0], n, newMat) > procrustesError (&from[0], &to[0], &weights[0], n, ms)); - for (size_t i = 0; i < 3; ++i) - for (size_t j = 0; j < 3; ++j) + for (int i = 0; i < 3; ++i) + for (int j = 0; j < 3; ++j) newMat[i][j] = ms[i][j] * (1.0 - scaleDiff); assert ( procrustesError (&from[0], &to[0], &weights[0], n, newMat) > @@ -352,10 +355,11 @@ testProcrustesImp () for (size_t i = 0; i < 4; ++i) { const T theta = T (2 * i) / T (M_PI); + const T offset = T(M_PI / 3.0); fromPoints.push_back ( IMATH_INTERNAL_NAMESPACE::Vec3 (cos (theta), sin (theta), 0)); toPoints.push_back (IMATH_INTERNAL_NAMESPACE::Vec3 ( - cos (theta + M_PI / 3.0), sin (theta + M_PI / 3.0), 0)); + cos (theta + offset), sin (theta + offset), 0)); } verifyProcrustes (fromPoints, toPoints); @@ -367,9 +371,13 @@ testProcrustesImp () for (size_t i = 0; i < numPoints; ++i) { fromPoints.push_back (IMATH_INTERNAL_NAMESPACE::Vec3 ( - random.nextf (), random.nextf (), random.nextf ())); + static_cast(random.nextf ()), + static_cast(random.nextf ()), + static_cast(random.nextf ()))); toPoints.push_back (IMATH_INTERNAL_NAMESPACE::Vec3 ( - random.nextf (), random.nextf (), random.nextf ())); + static_cast(random.nextf ()), + static_cast(random.nextf ()), + static_cast(random.nextf ()))); } } verifyProcrustes (fromPoints, toPoints); @@ -387,7 +395,7 @@ testProcrustesImp () m = m * rot.toMatrix44 (); testProcrustesWithMatrix (m); - m.scale (IMATH_INTERNAL_NAMESPACE::Vec3 (1.5, 6.4, 2.0)); + m.scale (IMATH_INTERNAL_NAMESPACE::Vec3 (T(1.5), T(6.4), T(2.0))); testProcrustesWithMatrix (m); IMATH_INTERNAL_NAMESPACE::Eulerd rot2 (1.0, M_PI, M_PI / 3.0); @@ -396,7 +404,7 @@ testProcrustesImp () m.scale (IMATH_INTERNAL_NAMESPACE::Vec3 (-1, 1, 1)); testProcrustesWithMatrix (m); - m.scale (IMATH_INTERNAL_NAMESPACE::Vec3 (1, 0.001, 1)); + m.scale (IMATH_INTERNAL_NAMESPACE::Vec3 (1, T(0.001), 1)); testProcrustesWithMatrix (m); m.scale (IMATH_INTERNAL_NAMESPACE::Vec3 (1, 1, 0)); diff --git a/src/ImathTest/testQuat.cpp b/src/ImathTest/testQuat.cpp index 8af1cdac..274820bc 100644 --- a/src/ImathTest/testQuat.cpp +++ b/src/ImathTest/testQuat.cpp @@ -95,7 +95,7 @@ testQuatT () { Quat q; - q.setAxisAngle (Vec3 (0, 0, 1), M_PI_2); + q.setAxisAngle (Vec3 (0, 0, 1), T(M_PI_2)); Vec3 v = q.axis (); T a = q.angle (); assert (v.equalWithAbsError (Vec3 (0, 0, 1), e)); @@ -117,8 +117,8 @@ testQuatT () assert (v.equalWithAbsError (Vec3 (0, 0, 1), e)); assert (IMATH_INTERNAL_NAMESPACE::equal (a, t, t * e)); - q.r *= 1.1; - q.v *= 1.1; + q.r *= T(1.1); + q.v *= T(1.1); v = q.axis (); a = q.angle (); assert (v.equalWithAbsError (Vec3 (0, 0, 1), e)); @@ -126,7 +126,7 @@ testQuatT () } { - T t = 0.001 * std::sqrt (s); + T t = T(0.001) * std::sqrt (s); Quat q; q.setAxisAngle (Vec3 (0, 0, 1), t); @@ -135,8 +135,8 @@ testQuatT () assert (v.equalWithAbsError (Vec3 (0, 0, 1), e)); assert (IMATH_INTERNAL_NAMESPACE::equal (a, t, t * e)); - q.r *= 1.1; - q.v *= 1.1; + q.r *= T(1.1); + q.v *= T(1.1); v = q.axis (); a = q.angle (); assert (v.equalWithAbsError (Vec3 (0, 0, 1), e)); diff --git a/src/ImathTest/testQuatSetRotation.cpp b/src/ImathTest/testQuatSetRotation.cpp index 270b65db..ae6da358 100644 --- a/src/ImathTest/testQuatSetRotation.cpp +++ b/src/ImathTest/testQuatSetRotation.cpp @@ -116,8 +116,8 @@ randomVectors () for (int i = 0; i < 500000; ++i) { - V3f from = hollowSphereRand (rand) * rand.nextf (0.1, 10.0); - V3f to = hollowSphereRand (rand) * rand.nextf (0.1, 10.0); + V3f from = hollowSphereRand (rand) * float(rand.nextf (0.1, 10.0)); + V3f to = hollowSphereRand (rand) * float(rand.nextf (0.1, 10.0)); testRotation (from, to); } } diff --git a/src/ImathTest/testQuatSlerp.cpp b/src/ImathTest/testQuatSlerp.cpp index 4c437fa4..d79129b1 100644 --- a/src/ImathTest/testQuatSlerp.cpp +++ b/src/ImathTest/testQuatSlerp.cpp @@ -93,7 +93,7 @@ specificRotations () for (int n1 = 0; n1 < 4; ++n1) { - float angle1 = n1 * M_PI / 2; + float angle1 = n1 * float(M_PI / 2); Quatf q1; q1.setAxisAngle (axis1, angle1); @@ -105,7 +105,7 @@ specificRotations () for (int n2 = 0; n2 < 4; ++n2) { - float angle2 = n2 * M_PI / 2; + float angle2 = n2 * float(M_PI / 2); Quatf q2; q2.setAxisAngle (axis2, angle2); @@ -135,8 +135,8 @@ randomRotations () { V3f axis1 = hollowSphereRand (rand); V3f axis2 = hollowSphereRand (rand); - float angle1 = rand.nextf (0, M_PI); - float angle2 = rand.nextf (0, M_PI); + float angle1 = float(rand.nextf (0, M_PI)); + float angle2 = float(rand.nextf (0, M_PI)); Quatf q1, q2; q1.setAxisAngle (axis1, angle1); diff --git a/src/ImathTest/testRandom.cpp b/src/ImathTest/testRandom.cpp index af664856..44846d85 100644 --- a/src/ImathTest/testRandom.cpp +++ b/src/ImathTest/testRandom.cpp @@ -95,7 +95,7 @@ testGenerator () for (int i = 0; i < M * N; ++i) { - float r = rand.nextf (0.0, 1.0); + float r = float(rand.nextf (0.0, 1.0)); float diff = r - previous; previous = r; diff --git a/src/ImathTest/testTinySVD.cpp b/src/ImathTest/testTinySVD.cpp index d2ca3d39..3a3ea31d 100644 --- a/src/ImathTest/testTinySVD.cpp +++ b/src/ImathTest/testTinySVD.cpp @@ -267,13 +267,13 @@ testTinySVDImp () testTinySVD_3x3 (0, 0, 0, 0, 0, 0, 0, 0, 1); testTinySVD_3x3 (1, 0, 0, 0, 1, 0, 0, 0, 0); testTinySVD_3x3 (1, 0, 0, 0, 0, 0, 0, 0, 0); - testTinySVD_3x3 (1, 0, 0, 1e-10, 0, 0, 0, 0, 0); - testTinySVD_3x3 (1, 0, 0, 1e-10, 0, 0, 0, 0, 100000); + testTinySVD_3x3 (1, 0, 0, T(1e-10), 0, 0, 0, 0, 0); + testTinySVD_3x3 (1, 0, 0, T(1e-10), 0, 0, 0, 0, 100000); testTinySVD_3x3 (1, 2, 3, 4, 5, 6, 7, 8, 9); testTinySVD_3x3 (1, 2, 3, 4, 5, 6, 7, 8, 9); testTinySVD_3x3 (outerProduct ( - IMATH_INTERNAL_NAMESPACE::Vec3 (100, 1e-5, 0), - IMATH_INTERNAL_NAMESPACE::Vec3 (100, 1e-5, 0))); + IMATH_INTERNAL_NAMESPACE::Vec3 (100, T(1e-5), 0), + IMATH_INTERNAL_NAMESPACE::Vec3 (100, T(1e-5), 0))); testTinySVD_3x3 (outerProduct ( IMATH_INTERNAL_NAMESPACE::Vec3 (245, 20, 1), IMATH_INTERNAL_NAMESPACE::Vec3 (256, 300, 20))); @@ -287,65 +287,65 @@ testTinySVDImp () // Some problematic matrices from SVDTest: testTinySVD_3x3 ( - 0.0023588321752040036, - -0.0096558131480729038, - 0.0010959850449366493, - 0.0088671829608044754, - 0.0016771794267033666, - -0.0043081475729438235, - 0.003976050440932701, - 0.0019880497026345716, - 0.0089576046614601966); + T(0.0023588321752040036), + T(-0.0096558131480729038), + T(0.0010959850449366493), + T(0.0088671829608044754), + T(0.0016771794267033666), + T(-0.0043081475729438235), + T(0.003976050440932701), + T(0.0019880497026345716), + T(0.0089576046614601966)); testTinySVD_3x3 ( - 2.3588321752040035e-09, - -9.6558131480729038e-09, - 1.0959850449366498e-09, - 8.8671829608044748e-09, - 1.6771794267033661e-09, - -4.3081475729438225e-09, - 3.9760504409327016e-09, - 1.9880497026345722e-09, - 8.9576046614601957e-09); + T(2.3588321752040035e-09), + T(-9.6558131480729038e-09), + T(1.0959850449366498e-09), + T(8.8671829608044748e-09), + T(1.6771794267033661e-09), + T(-4.3081475729438225e-09), + T(3.9760504409327016e-09), + T(1.9880497026345722e-09), + T(8.9576046614601957e-09)); testTinySVD_3x3 ( - -0.46673855799602715, - 0.67466260360310948, - 0.97646986796448998, - -0.032460753747103721, - 0.046584527749418278, - 0.067431228641151142, - -0.088885055229687815, - 0.1280389179308779, - 0.18532617511453064); - testTinySVD_3x3 (1e-8, 0, 0, 0, 1e-8, 0, 0, 0, 1e-8); - testTinySVD_3x3 (1, 0, 0, 0, .00036, 0, 1e-18, 0, .00018); - testTinySVD_3x3 (1.3, 0, 0, 0, .0003, 0, 1e-17, 0, 0); - testTinySVD_3x3 (1, 0, 0, 0, 1e-2, 0, 0, 0, 1e-2); + T(-0.46673855799602715), + T(0.67466260360310948), + T(0.97646986796448998), + T(-0.032460753747103721), + T(0.046584527749418278), + T(0.067431228641151142), + T(-0.088885055229687815), + T(0.1280389179308779), + T(0.18532617511453064)); + testTinySVD_3x3 (T(1e-8), 0, 0, 0, T(1e-8), 0, 0, 0, T(1e-8)); + testTinySVD_3x3 (1, 0, 0, 0, T(.00036), 0, T(1e-18), 0, T(.00018)); + testTinySVD_3x3 (T(1.3), 0, 0, 0, T(.0003), 0, T(1e-17), 0, 0); + testTinySVD_3x3 (1, 0, 0, 0, T(1e-2), 0, 0, 0, T(1e-2)); testTinySVD_3x3 (1, 0, 0, 0, 1, 0, 0, 0, 0); - testTinySVD_3x3 (1, 0, 0, 0, 1e-3, 0, 0, 0, 1e-6); + testTinySVD_3x3 (1, 0, 0, 0, T(1e-3), 0, 0, 0, T(1e-6)); testTinySVD_3x3 ( - 0.59588638570136332, - -0.79761234126107794, + T(0.59588638570136332), + T(-0.79761234126107794), -1, - 0.39194500425202045, - 0.91763115383440363, - -0.341818175044664, - -0.45056075218951946, - -0.71259057727425101, - 0.47125008216720271); + T(0.39194500425202045), + T(0.91763115383440363), + T(-0.341818175044664), + T(-0.45056075218951946), + T(-0.71259057727425101), + T(0.47125008216720271)); testTinySVD_3x3 ( - 4.38805348e-09, - -2.53189691e-09, - -4.65678607e-09, - -3.23000099e-10, - 1.86370294e-10, - 3.42781192e-10, - -4.61572824e-09, - 2.6632645e-09, - 4.89840346e-09); + T(4.38805348e-09), + T(-2.53189691e-09), + T(-4.65678607e-09), + T(-3.23000099e-10), + T(1.86370294e-10), + T(3.42781192e-10), + T(-4.61572824e-09), + T(2.6632645e-09), + T(4.89840346e-09)); // problematic 2x2 one for lapack on suse (see below), padded with 0's - testTinySVD_3x3 (0, -1.00000003e-22, 0, 1.00000001e-07, 0, 0, 0, 0, 0); + testTinySVD_3x3 (0, T(-1.00000003e-22), 0, T(1.00000001e-07), 0, 0, 0, 0, 0); // problematic 2x2 one for lapack on suse (see below), padded with 0's and 1 - testTinySVD_3x3 (0, -1.00000003e-22, 0, 1.00000001e-07, 0, 0, 0, 0, 1); + testTinySVD_3x3 (0, T(-1.00000003e-22), 0, T(1.00000001e-07), 0, 0, 0, 0, 1); // Now, 4x4 matrices: testTinySVD_4x4 (1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); @@ -357,10 +357,10 @@ testTinySVDImp () testTinySVD_4x4 (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); testTinySVD_4x4 ( 0, - -1.00000003e-22, + T(-1.00000003e-22), 0, 0, - 00000001e-07, + T(00000001e-07), 0, 0, 0, @@ -373,14 +373,14 @@ testTinySVDImp () 0, 1); testTinySVD_4x4 (outerProduct ( - IMATH_INTERNAL_NAMESPACE::Vec4 (100, 1e-5, 0, 0), - IMATH_INTERNAL_NAMESPACE::Vec4 (100, 1e-5, 0, 0))); + IMATH_INTERNAL_NAMESPACE::Vec4 (100, T(1e-5), 0, 0), + IMATH_INTERNAL_NAMESPACE::Vec4 (100, T(1e-5), 0, 0))); testTinySVD_4x4 (outerProduct ( - IMATH_INTERNAL_NAMESPACE::Vec4 (245, 20, 1, 0.5), + IMATH_INTERNAL_NAMESPACE::Vec4 (245, 20, 1, T(0.5)), IMATH_INTERNAL_NAMESPACE::Vec4 (256, 300, 20, 10))); testTinySVD_4x4 ( outerProduct ( - IMATH_INTERNAL_NAMESPACE::Vec4 (245, 20, 1, 0.5), + IMATH_INTERNAL_NAMESPACE::Vec4 (245, 20, 1, T(0.5)), IMATH_INTERNAL_NAMESPACE::Vec4 (256, 300, 20, 10)) + outerProduct ( IMATH_INTERNAL_NAMESPACE::Vec4 (30, 10, 10, 10),