BOOST_FIXTURE_TEST_CASE( math2d__addition, Some2dPoints ) { BOOMST_CHECK_APPROX_EQUAL( real2(6_r,2_r), p0+q0 ); BOOMST_CHECK_APPROX_EQUAL( real2(-2.5_r,0.5_r), p1+q1 ); BOOMST_CHECK_APPROX_EQUAL( real2(0_r,2_r), p0-q0 ); BOOMST_CHECK_APPROX_EQUAL( q0+p0, p0+q0 ); }
BOOST_FIXTURE_TEST_CASE( math2d__multiplication, Some2dPoints ) { BOOMST_CHECK_APPROX_EQUAL( p0*2_r, real2(6_r,4_r) ); BOOMST_CHECK_APPROX_EQUAL( p0*2_r*3_r, real2(18_r,12_r) ); BOOMST_CHECK_APPROX_EQUAL( p0/2_r, real2(1.5_r,1_r) ); BOOMST_CHECK_APPROX_EQUAL( p0/2_r*2_r, p0 ); }
inline real2 rcpUniformSampleSphere(const real3& direction) { auto cosTheta = direction.z; auto v = 0.5 * (cosTheta - 1); auto phi = atan2(direction.y, direction.x); auto u = phi * one_over_two_pi<real>(); return real2(u, v); }
inline real2 rcpCosineSampleHemisphere(const real3& d) { auto cosTheta = d.z; auto v = sqr(cosTheta); auto phi = atan2(d.y, d.x); auto u = phi * one_over_two_pi<real>(); return real2(u, v); }
int main(void) { static const struct st3 a = {1, 2, 3, 4, 5, 6}; l1(100); l2(100, 200); l3(100, 200, 300); l4(100, 200, 300, 400); l5(100, 200, 300, 400, 500); l6(100, 200, 300, 400, 500, 600); l7(100, 200, 300, 400, 500, 600, 700); l8(100, 200, 300, 400, 500, 600, 700, 800); d1(); d2(43); d3(100, 200); d4(a); d5('a', 43, a); d6('a', 1); c1(44); c2(100, 'a', 3.4); c3(200, 2.777, 'q'); c4(200, 1); c5(1.1, 2.2); c6(1.23, 45.6); c7('z', 0x200); a1('a'); a2(10); a3(20); a4(102030405060LL); b1('a', 20); b2(30, 'b'); b3(10, 20, 30, 40, 50, 60); s1(sx); s1p(&sx); s2(sy); s3(sz); s4(sq); s5(sa); s6(sb); r1(); r3(); r4(); q1(200, sx); q2(300, 't', sx); q3(400, 410, sy); q4(500, 510, sq); q5(600, 610, 'z', 'q', sq); real1("fresh air"); real2(); return 0; }
inline real dualParaboloidJacobian(const real2& uv) { auto N = getDualParaboloidNormal(uv); auto ndc = real2(N); if(dot(ndc, ndc) > 1.f) { return 0.f; } auto d = dot(N, N); return 8.f / (d * d * d); }
//! return the value of `s` and `t` such that `p + t*v == q + s*w` holds, or return `{nan,nan}` if there is no solution. inline real2 line_intersection_factors( real2 const& p, real2 const& v, real2 const& q, real2 const& w ) { real v_x_w= crossProduct_z(v,w); if( equals_about(v_x_w, 0_r) ) return nan2; else return real2( crossProduct_z(w,p-q) / v_x_w , crossProduct_z(v,p-q) / v_x_w ); }
int main(int argc, char **argv) { GURL real1("file://localhost/e:/Alex/workspace/demonstrator/Genesis/build/bin/x64/DEBUG/L32f.png"); std::cout << (real1.is_valid() ? "is valid" : "is invalid") << '\n'; std::cout << (real1.IsStandard() ? "is standard" : "is not standard") << '\n'; print_uri(real1); GURL url("http://*****:*****@wwww.furious-typing.com:1234/test/main.html?id=12356&mid=carlos#location"); std::cout << (url.is_valid() ? "is valid" : "is invalid") << '\n'; std::cout << (url.IsStandard() ? "is standard" : "is not standard") << '\n'; print_uri(url); GURL invalid1("c:\\blubber"); std::cout << (invalid1.is_valid() ? "is valid" : "is invalid") << '\n'; std::cout << (invalid1.IsStandard() ? "is standard" : "is not standard") << '\n'; print_uri(invalid1); GURL invalid2("file:/host/path"); std::cout << (invalid2.is_valid() ? "is valid" : "is invalid") << '\n'; std::cout << (invalid2.IsStandard() ? "is standard" : "is not standard") << '\n'; print_uri(invalid2); GURL url1("http://*****:*****@wwww.furious-typing.com:1234/test/main file.html?id=12356&mid=carlos#location"); std::cout << (url1.is_valid() ? "is valid" : "is invalid") << '\n'; std::cout << (url1.IsStandard() ? "is standard" : "is not standard") << '\n'; print_uri(url1); GURL real2("file://localhost///192.168.0.2/path/to/file.txt"); std::cout << (real2.is_valid() ? "is valid" : "is invalid") << '\n'; std::cout << (real2.IsStandard() ? "is standard" : "is not standard") << '\n'; print_uri(real2); GURL real3("file://localhost/e%3A/Alex/workspace/demonstrator/Genesis/build/bin/x64/DEBUG/L%5B32%5Df.pfm"); std::cout << (real3.is_valid() ? "is valid" : "is invalid") << '\n'; std::cout << (real3.IsStandard() ? "is standard" : "is not standard") << '\n'; print_uri(real3); GURL real4("file://localhost/e:/Alex/workspace/demonstrator/Genesis/build/bin/x64/DEBUG/L[32]f.pfm"); std::cout << (real4.is_valid() ? "is valid" : "is invalid") << '\n'; std::cout << (real4.IsStandard() ? "is standard" : "is not standard") << '\n'; print_uri(real4); return 0; }
/*! Uniform sampling of disk. */ inline real2 uniformSampleDisk(const real2& sample, real radius) { const real r = sqrt(sample.x); const real theta = two_pi<real>() * sample.y; return radius * r * real2(cos(theta), sin(theta)); }
inline real2 uniformSampleTriangleUVs(real u, real v, const real3& A, const real3& B, const real3& C) { real su = sqrt(u); return real2(1.f - su, v * su); }
void drive_operation() { // Uint64 tests CQLValue a1(Uint64(10)); CQLValue a2(Uint64(15)); CQLValue a3(Uint64(25)); CQLValue a4(Uint64(30)); CQLValue a5(Uint64(150)); PEGASUS_TEST_ASSERT(a1 != a2); PEGASUS_TEST_ASSERT(a5 == a5); PEGASUS_TEST_ASSERT(a1 < a2); PEGASUS_TEST_ASSERT(a2 >= a1); PEGASUS_TEST_ASSERT(a1 <= a2); PEGASUS_TEST_ASSERT(a2 > a1); // Sint64 tests CQLValue b1(Sint64(10)); CQLValue b2(Sint64(15)); CQLValue b3(Sint64(25)); CQLValue b4(Sint64(30)); CQLValue b5(Sint64(150)); PEGASUS_TEST_ASSERT(b1 != b2); PEGASUS_TEST_ASSERT(b5 == b5); PEGASUS_TEST_ASSERT(b1 < b2); PEGASUS_TEST_ASSERT(b2 >= b1); PEGASUS_TEST_ASSERT(b1 <= b2); PEGASUS_TEST_ASSERT(b2 > b1); // Real64 tests CQLValue c1(Real64(10.00)); CQLValue c2(Real64(15.00)); CQLValue c3(Real64(25.00)); CQLValue c4(Real64(30.00)); CQLValue c5(Real64(150.00)); PEGASUS_TEST_ASSERT(c1 != c2); PEGASUS_TEST_ASSERT(c5 == c5); PEGASUS_TEST_ASSERT(c1 < c2); PEGASUS_TEST_ASSERT(c2 >= c1); PEGASUS_TEST_ASSERT(c1 <= c2); PEGASUS_TEST_ASSERT(c2 > c1); // Misc PEGASUS_TEST_ASSERT(a1 == b1); PEGASUS_TEST_ASSERT(a1 == c1); PEGASUS_TEST_ASSERT(b1 == a1); PEGASUS_TEST_ASSERT(b1 == c1); PEGASUS_TEST_ASSERT(c1 == a1); PEGASUS_TEST_ASSERT(c1 == b1); PEGASUS_TEST_ASSERT(a2 != b1); PEGASUS_TEST_ASSERT(a2 != c1); PEGASUS_TEST_ASSERT(b2 != a1); PEGASUS_TEST_ASSERT(b2 != c1); PEGASUS_TEST_ASSERT(c2 != a1); PEGASUS_TEST_ASSERT(c2 != b1); PEGASUS_TEST_ASSERT(a2 >= b1); PEGASUS_TEST_ASSERT(a2 >= c1); PEGASUS_TEST_ASSERT(b2 >= a1); PEGASUS_TEST_ASSERT(b2 >= c1); PEGASUS_TEST_ASSERT(c2 >= a1); PEGASUS_TEST_ASSERT(c2 >= b1); PEGASUS_TEST_ASSERT(a2 <= b3); PEGASUS_TEST_ASSERT(a2 <= c3); PEGASUS_TEST_ASSERT(b2 <= a3); PEGASUS_TEST_ASSERT(b2 <= c3); PEGASUS_TEST_ASSERT(c2 <= a3); PEGASUS_TEST_ASSERT(c2 <= b3); PEGASUS_TEST_ASSERT(a2 > b1); PEGASUS_TEST_ASSERT(a2 > c1); PEGASUS_TEST_ASSERT(b2 > a1); PEGASUS_TEST_ASSERT(b2 > c1); PEGASUS_TEST_ASSERT(c2 > a1); PEGASUS_TEST_ASSERT(c2 > b1); PEGASUS_TEST_ASSERT(a2 < b3); PEGASUS_TEST_ASSERT(a2 < c3); PEGASUS_TEST_ASSERT(b2 < a3); PEGASUS_TEST_ASSERT(b2 < c3); PEGASUS_TEST_ASSERT(c2 < a3); PEGASUS_TEST_ASSERT(c2 < b3); //Overflow testing CQLValue real1(Real64(0.00000001)); CQLValue sint1(Sint64(-1)); CQLValue uint1(Sint64(1)); CQLValue uint2(Uint64(0)); PEGASUS_TEST_ASSERT(uint1 > sint1); PEGASUS_TEST_ASSERT(real1 > sint1); PEGASUS_TEST_ASSERT(uint2 > sint1); PEGASUS_TEST_ASSERT(real1 > uint2); CQLValue real2(Real64(25.00000000000001)); CQLValue real3(Real64(24.99999999999999)); CQLValue sint2(Sint64(25)); CQLValue uint3(Uint64(25)); PEGASUS_TEST_ASSERT(real2 > real3); PEGASUS_TEST_ASSERT(real2 > sint2); PEGASUS_TEST_ASSERT(real2 > uint3); PEGASUS_TEST_ASSERT(real3 < sint2); PEGASUS_TEST_ASSERT(real3 < uint3); // String tests CQLValue d1(String("HELLO")); CQLValue d2(String("HEL")); CQLValue d3(String("LO")); CQLValue d4(String("AHELLO")); CQLValue d5(String("ZHELLO")); PEGASUS_TEST_ASSERT(d1 == d2 + d3); PEGASUS_TEST_ASSERT(d1 != d2 + d4); PEGASUS_TEST_ASSERT(d1 <= d5); PEGASUS_TEST_ASSERT(d1 < d5); PEGASUS_TEST_ASSERT(d1 >= d4); PEGASUS_TEST_ASSERT(d1 > d4); String str1("0x10"); String str2("10"); String str3("10B"); String str4("10.10"); CQLValue e1( str1, CQLValue::Hex); CQLValue e2( str2, CQLValue::Decimal); CQLValue e3( str3, CQLValue::Binary); CQLValue e4( str4, CQLValue::Real); CQLValue e5(Uint64(16)); CQLValue e6(Uint64(10)); CQLValue e7(Uint64(2)); CQLValue e8(Real64(10.10)); PEGASUS_TEST_ASSERT(e1 == e5); PEGASUS_TEST_ASSERT(e2 == e6); PEGASUS_TEST_ASSERT(e3 == e7); PEGASUS_TEST_ASSERT(e4 == e8); Array<Uint64> array1; array1.append(1); array1.append(2); array1.append(3); array1.append(4); array1.append(5); array1.append(6); array1.append(7); array1.append(8); array1.append(9); array1.append(10); Array<Sint64> array2; array2.append(1); array2.append(2); array2.append(3); array2.append(4); array2.append(5); array2.append(6); array2.append(7); array2.append(8); array2.append(9); array2.append(10); array2.append(3); Array<Real64> array3; array3.append(1.00); array3.append(2.00); array3.append(3.00); array3.append(9.00); array3.append(10.00); array3.append(3.00); array3.append(4.00); array3.append(5.00); array3.append(6.00); array3.append(7.00); array3.append(8.00); Array<Uint64> array4; array4.append(1); array4.append(23); array4.append(3); array4.append(4); array4.append(5); array4.append(6); array4.append(7); array4.append(88); array4.append(9); array4.append(10); Array<Sint64> array5; array5.append(-1); array5.append(2); array5.append(3); array5.append(4); array5.append(5); array5.append(-6); array5.append(7); array5.append(8); array5.append(9); array5.append(10); array5.append(-3); Array<Real64> array6; array6.append(1.23); array6.append(2.00); array6.append(3.00); array6.append(9.00); array6.append(10.00); array6.append(3.00); array6.append(4.14); array6.append(5.00); array6.append(6.00); array6.append(7.00); array6.append(8.00); CIMValue cv1(array1); CIMValue cv2(array2); CIMValue cv3(array3); CIMValue cv4(array4); CIMValue cv5(array5); CIMValue cv6(array6); CQLValue vr1(cv1); CQLValue vr2(cv1); CQLValue vr3(cv2); CQLValue vr4(cv3); CQLValue vr5(cv4); CQLValue vr6(cv5); CQLValue vr7(cv6); PEGASUS_TEST_ASSERT(vr1 == vr2); PEGASUS_TEST_ASSERT(vr1 == vr3); PEGASUS_TEST_ASSERT(vr1 == vr4); PEGASUS_TEST_ASSERT(vr4 == vr3); PEGASUS_TEST_ASSERT(vr1 != vr5); PEGASUS_TEST_ASSERT(vr3 != vr6); PEGASUS_TEST_ASSERT(vr4 != vr7); const CIMName _cimName(String("CIM_OperatingSystem")); CIMInstance _i1(_cimName); CIMProperty _p1(CIMName("Description"),CIMValue(String("Dave Rules"))); CIMProperty _p2(CIMName("EnabledState"),CIMValue(Uint16(2))); CIMProperty _p3(CIMName("CurrentTimeZone"),CIMValue(Sint16(-600))); CIMProperty _p4(CIMName("TimeOfLastStateChange"), CIMValue(CIMDateTime(String("20040811105625.000000-360")))); _i1.addProperty(_p1); _i1.addProperty(_p2); _i1.addProperty(_p3); _i1.addProperty(_p4); CIMInstance _i2(_cimName); CIMProperty _p5(CIMName("Description"), CIMValue(String("Dave Rules Everything"))); CIMProperty _p6(CIMName("EnabledState"),CIMValue(Uint16(2))); CIMProperty _p7(CIMName("CurrentTimeZone"),CIMValue(Sint16(-600))); CIMProperty _p8(CIMName("TimeOfLastStateChange"), CIMValue(CIMDateTime(String("20040811105625.000000-360")))); _i2.addProperty(_p5); _i2.addProperty(_p6); _i2.addProperty(_p7); _i2.addProperty(_p8); CQLValue cql1(_i1); CQLValue cql2(_i1); CQLValue cql3(_i2); CQLValue cql4(_i2); //PEGASUS_TEST_ASSERT(cql1 == cql1); return; }
BOOST_FIXTURE_TEST_CASE( math2d__orthogonal, Some2dPoints ) { BOOMST_CHECK_APPROX_EQUAL( real2(-2_r,-2_r), rightOrthogonal(p3) ); BOOMST_CHECK_APPROX_EQUAL( real2(2_r,2_r), leftOrthogonal(p3) ); BOOMST_CHECK_APPROX_EQUAL( real2(0_r,3_r), leftOrthogonal(q0) ); }
real2 to_screen_coordinates_factor (aabr const& screen_zone, size_t_2 screen_resolution) { return real2( real(screen_resolution.x) / screen_zone.width() , real(screen_resolution.y) / screen_zone.height() ); }
real2 to_physical_coordinates_factor (aabr const& screen_zone, size_t_2 screen_resolution) { return real2( screen_zone.width() / real(screen_resolution.x) , screen_zone.height() / real(screen_resolution.y) ); }
int real1(const char *w) { puts(w); real2(); return 3; }