コード例 #1
0
ファイル: main.cpp プロジェクト: sambatyon/googleurl
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;
}
コード例 #2
0
/*! Samples hemisphere with power cosine distribution. Up direction
 *  is provided as argument. */
inline direction_sample powerCosineSampleHemisphere(real u, real v, const real3& N, real exp) {
    direction_sample s = powerCosineSampleHemisphere(u,v,exp);
    return direction_sample(frameZ(N) * real3(s.value()), s.density());
}
コード例 #3
0
ファイル: math.cpp プロジェクト: rserban/chrono_models
int main() {

	quaternion q1(1, 2, 3, 4);
	q1 = normalize(q1);

// real3 v(1,2,3);

// real3 Pl_1 = MatTMult(AMat(q1), v);

// cout<<Pl_1<<endl;

// real3 Pl_2 = quatRotate(v, ~q1);
// cout<<Pl_2<<endl;

// M33 Ps = XMatrix(v);
// M33 Jtemp = MatMult(AMat(q1), Ps);
// cout<<Jtemp.U;
// cout<<Jtemp.V;
// cout<<Jtemp.W;
	quaternion E1(1, 2, 3, 4);
	E1 = normalize(E1);
	real3 sbar(1, 2, 3);

//real3 vnew1 = quatRotate(sbar,~E1);
//real3 vnew2 = quatRotateMatT(sbar,E1);
//
//
//
////real3 t = 2 * cross(real3(E1.x,E1.y,E1.z), sbar);
////real3 vnew2 = sbar + E1.w * t + cross(real3(E1.x,E1.y,E1.z), t);
//
//cout<<vnew1<<endl;
////
//cout<<vnew2<<endl;;

	real3 U = normalize(real3(1, 7, 3));
	real3 V, W;

	W = cross(U, R3(0, 1, 0));
	real mzlen = length(W);
	if (mzlen < .0001) {     // was near singularity? change singularity reference custom_vector!
		real3 mVsingular = R3(1, 0, 0);
		W = cross(U, mVsingular);
		mzlen = length(W);
	}
	W /= mzlen;
	V = cross(W, U);
//
	M33 contact_plane;
	contact_plane.U = U;
	contact_plane.V = V;
	contact_plane.W = W;
//
	sbar = quatRotate(sbar, ~E1);     //A^T*s
////
////			M33 sbartilde = XMatrix(sbar);
////			M33 Jtemp = MatMult(AMat(E1), sbartilde);
////			M33 Jr = MatTMult(contact_plane, Jtemp);
	real3 col1 = cross(quatRotate(U, ~E1), sbar);
	real3 col2 = cross(quatRotate(V, ~E1), sbar);
	real3 col3 = cross(quatRotate(W, ~E1), sbar);
	cout << col1;
	cout << col2;
	cout << col3;

	real3 A = normalize(quatRotate(U, ~E1));
	real3 B, C;
	C = cross(A, R3(0, 1, 0));
	 mzlen = length(C);
	if (mzlen < .0001) {     // was near singularity? change singularity reference custom_vector!
		real3 mVsingular = R3(1, 0, 0);
		C = cross(A, mVsingular);
		mzlen = length(C);
	}
	C /= mzlen;
	B = cross(C, A);

	 col1 = cross(A, sbar);
	 col2 = cross(B, sbar);
	 col3 = cross(C, sbar);

	 cout<<endl;

	 cout << col1;
	 	cout << col2;
	 	cout << col3;
//
//
////
//	M33 Jr = MatTMult(contact_plane, AMat(E1));
////
//	real3 T1 = R3(Jr.U.x, Jr.V.x, Jr.W.x);
//	real3 T2 = R3(Jr.U.y, Jr.V.y, Jr.W.y);
//	real3 T3 = R3(Jr.U.z, Jr.V.z, Jr.W.z);
////
//	real3 col1 = quatRotate(U, ~E1);
//	real3 col2 = quatRotate(V, ~E1);
//	real3 col3 = quatRotate(W, ~E1);
//	cout << col1;
//	cout << col2;
//	cout << col3;
//
//	cout << endl;
//	cout << T1;
//	cout << T2;
//	cout << T3;
	/*
	 [-1.5185, -2.30493, 1.89737]
	 [-0.347087, -0.52684, -2.9093]
	 [1.34496, 2.04151, 1.3914]
	 */
//  [0.650787, 0.178357, 0.737865]
//  [0.0780945, -0.982338, 0.168655]
//  [0.754913, -0.0521351, -0.653537]
	return 0;

}
コード例 #4
0
/*! Cosine weighted hemisphere sampling. Up direction is provided as argument. */
inline direction_sample cosineSampleHemisphere(real u, real v, const real3& N) {
    direction_sample s = cosineSampleHemisphere(u, v);
    return direction_sample(frameZ(N) * real3(s.value()), s.density());
}
コード例 #5
0
ファイル: CQLValue.cpp プロジェクト: deleisha/neopegasus
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;
}