Ejemplo n.º 1
0
    void testCentroid(void) {
////////////////////////////// Centroid Operations - Centroid Operations - Centroid Operations /////////////////////////
        std::string header = "Centroid Operations";
        testSectionHeader(header);
        int testNum = 1;   // Test starting number
        int numDims = 5;   // Dimensions in test arrays (don't go below 2)
////////////////////////////// Centroid Operations - Centroid Operations - Centroid Operations /////////////////////////
        {
            testTitle(testNum++, header, "Centroid Operations - setCentroid(default)");

            Cluster c1(numDims);
            std::cout << "Cluster c" << c1.getId() << ";";
            std::cout << std::endl;

            std::ifstream inFile;
            std::cout << "std::ifstream inFile;";
            std::cout << std::endl;

            // WARNING!! MAKE SURE THE CURRENT WORKING DIRECTORY IS SET TO WHEREVER YOU HAVE main.cpp
            inFile.open("infile_1.txt");
            std::cout << "inFile.open(\"infile_1.txt\");";
            std::cout << std::endl;

            inFile >> c1;
            std::cout << "inFile >> c" << c1.getId() << ";";
            std::cout << std::endl;

            c1.setCentroid();
            std::cout << "c" << c1.getId() << ".setCentroid();";
            std::cout << std::endl;

            testResult();
            std::cout << "c" << c1.getId() << ".getCentroid(): (" << c1.getCentroid() << ")";
            std::cout << std::endl;

            testClose();
        }
////////////////////////////// Centroid Operations - Centroid Operations - Centroid Operations /////////////////////////
        {
            testTitle(testNum++, header, "Centroid Operations - setCentroid(point)");

            Cluster c1(numDims);
            std::cout << "Cluster c" << c1.getId() << ";";
            std::cout << std::endl;

            std::ifstream inFile;
            std::cout << "std::ifstream inFile;";
            std::cout << std::endl;

            // WARNING!! MAKE SURE THE CURRENT WORKING DIRECTORY IS SET TO WHEREVER YOU HAVE main.cpp
            inFile.open("infile_1.txt");
            std::cout << "inFile.open(\"infile_1.txt\");";
            std::cout << std::endl;

            inFile >> c1;
            std::cout << "inFile >> c" << c1.getId() << ";";
            std::cout << std::endl;

            double *p1arr = new double[numDims];

            randPt(numDims, 2, 4, p1arr);

            std::cout << "double p1arr[" << numDims << "] = ";
            testPtArr(numDims, p1arr, "{", "};");

            std::cout << std::endl;
            Point p1(numDims, p1arr);
            std::cout << "Point p1(" << numDims << ", p1arr);";

            std::cout << std::endl;
            c1.add(p1);
            std::cout << "c1.add(p1);";

            delete[] p1arr;

            std::cout << std::endl;
            c1.setCentroid(p1);
            std::cout << "c1.setCentroid(p1);";
            std::cout << std::endl;

            testResult();
            std::cout << "c" << c1.getId() << ".getCentroid(): (" << c1.getCentroid() << ")";
            std::cout << std::endl;
            c1.loud();
            std::cout << std::endl;

            testClose();
        }
////////////////////////////// Centroid Operations - Centroid Operations - Centroid Operations /////////////////////////
        {
            testTitle(testNum++, header, "Centroid Operations - setCentroid(point) [Not in cluster]");

            Cluster c1(numDims);
            std::cout << "Cluster c" << c1.getId() << ";";
            std::cout << std::endl;

            std::ifstream inFile;
            std::cout << "std::ifstream inFile;";
            std::cout << std::endl;

            // WARNING!! MAKE SURE THE CURRENT WORKING DIRECTORY IS SET TO WHEREVER YOU HAVE main.cpp
            inFile.open("infile_1.txt");
            std::cout << "inFile.open(\"infile_1.txt\");";
            std::cout << std::endl;

            inFile >> c1;
            std::cout << "inFile >> c" << c1.getId() << ";";
            std::cout << std::endl;

            double *p1arr = new double[numDims];

            randPt(numDims, 0, 9, p1arr);

            std::cout << "double p1arr[" << numDims << "] = ";
            testPtArr(numDims, p1arr, "{", "};");

            std::cout << std::endl;
            Point p1(numDims, p1arr);
            std::cout << "Point p1(" << numDims << ", p1arr);";

            delete[] p1arr;

            std::cout << std::endl;
            c1.setCentroid(p1);
            std::cout << "c1.setCentroid(p1);";
            std::cout << std::endl;

            testResult();
            std::cout << "c" << c1.getId() << ".getCentroid(): (" << c1.getCentroid() << ")";
            std::cout << std::endl;
            c1.loud();
            std::cout << std::endl;

            testClose();
        }
////////////////////////////// Centroid Operations - Centroid Operations - Centroid Operations /////////////////////////
        {
            testTitle(testNum++, header, "Centroid Operations - computeCentroid() [1]");

            Cluster c1(numDims);
            std::cout << "Cluster c" << c1.getId() << ";";
            std::cout << std::endl;

            std::ifstream inFile;
            std::cout << "std::ifstream inFile;";
            std::cout << std::endl;

            // WARNING!! MAKE SURE THE CURRENT WORKING DIRECTORY IS SET TO WHEREVER YOU HAVE main.cpp
            inFile.open("infile_1.txt");
            std::cout << "inFile.open(\"infile_1.txt\");";
            std::cout << std::endl;

            inFile >> c1;
            std::cout << "inFile >> c" << c1.getId() << ";";
            std::cout << std::endl;

            c1.setCentroid();
            std::cout << "c" << c1.getId() << ".setCentroid();";
            std::cout << std::endl;

            c1.computeCentroid();
            std::cout << "c" << c1.getId() << ".computeCentroid();";
            std::cout << std::endl;

            testResult();
            std::cout << "c" << c1.getId() << ".getCentroid(): (" << c1.getCentroid() << ")";
            std::cout << std::endl;

            testClose();
        }
////////////////////////////// Centroid Operations - Centroid Operations - Centroid Operations /////////////////////////
        {
            testTitle(testNum++, header, "Centroid Operations - computeCentroid() [2]");

            Cluster c1(numDims);
            std::cout << "Cluster c" << c1.getId() << ";";
            std::cout << std::endl;

            double p1arr[] = {21,12,0,0,0};
            double p2arr[] = {0,0,15,0,0};
            double p3arr[] = {0,0,0,9,3};

            std::cout << "double p1arr[" << numDims << "] = ";
            testPtArr(numDims, p1arr, "{", "};");

            std::cout << std::endl;
            std::cout << "double p2arr[" << numDims << "] = ";
            testPtArr(numDims, p2arr, "{", "};");

            std::cout << std::endl;
            std::cout << "double p3arr[" << numDims << "] = ";
            testPtArr(numDims, p3arr, "{", "};");

            std::cout << std::endl;
            Point p1(numDims, p1arr);
            std::cout << "Point p1(" << numDims << ", p1arr);";

            std::cout << std::endl;
            Point p2(numDims, p2arr);
            std::cout << "Point p2(" << numDims << ", p2arr);";

            std::cout << std::endl;
            Point p3(numDims, p3arr);
            std::cout << "Point p3(" << numDims << ", p3arr);";

            std::cout << std::endl;
            c1.add(p1);
            std::cout << "c1.add(p1);";

            std::cout << std::endl;
            c1.add(p2);
            std::cout << "c1.add(p2);";

            std::cout << std::endl;
            c1.add(p3);
            std::cout << "c1.add(p3);";

            std::cout << std::endl;
            c1.setCentroid();
            std::cout << "c" << c1.getId() << ".setCentroid();";
            std::cout << std::endl;

            c1.computeCentroid();
            std::cout << "c" << c1.getId() << ".computeCentroid();";
            std::cout << std::endl;
            testResult();
            std::cout << "c" << c1.getId() << ".getCentroid(): (" << c1.getCentroid() << ")";
            std::cout << std::endl;

            testClose();
        }
////////////////////////////// Centroid Operations - Centroid Operations - Centroid Operations /////////////////////////
        {
            testTitle(testNum++, header, "Centroid Operations - Move(&)");

            Cluster c1(numDims);
            std::cout << "Cluster c1(numDims);";
            std::cout << std::endl;

            Cluster c2(numDims);
            std::cout << "Cluster c2(numDims);";
            std::cout << std::endl;

            double p1arr[] = {6,12,0,0,0};
            double p2arr[] = {0,0,18,0,0};
            double p3arr[] = {0,0,0,24,30};

            std::cout << "double p1arr[" << numDims << "] = ";
            testPtArr(numDims, p1arr, "{", "};");

            std::cout << std::endl;
            std::cout << "double p2arr[" << numDims << "] = ";
            testPtArr(numDims, p2arr, "{", "};");

            std::cout << std::endl;
            std::cout << "double p3arr[" << numDims << "] = ";
            testPtArr(numDims, p3arr, "{", "};");

            std::cout << std::endl;
            Point p1(numDims, p1arr);
            std::cout << "Point p1(" << numDims << ", p1arr);";

            std::cout << std::endl;
            Point p2(numDims, p2arr);
            std::cout << "Point p2(" << numDims << ", p2arr);";

            std::cout << std::endl;
            Point p3(numDims, p3arr);
            std::cout << "Point p3(" << numDims << ", p3arr);";

            std::cout << std::endl;
            c1.add(p1);
            std::cout << "c1.add(p1);";

            std::cout << std::endl;
            c1.add(p2);
            std::cout << "c1.add(p2);";

            std::cout << std::endl;
            c1.add(p3);
            std::cout << "c1.add(p3);";

            std::cout << std::endl;
            std::cout << std::endl << std::endl << "[Current Data Formulation]";

            std::cout << std::endl;
            c1.loud("c1");

            std::cout << std::endl;
            c2.loud("c2");
            std::cout << std::endl;

            c1.computeCentroid();
            std::cout << std::endl;
            std::cout << "c1.computeCentroid(): (" << c1.getCentroid() << ")";

            c2.computeCentroid();
            std::cout << std::endl;
            std::cout << "c2.computeCentroid(): (" << c2.getCentroid() << ")";

            std::cout << std::endl;
            std::cout << std::endl;
            Cluster::Move(&p1,&c1,&c2).perform();
            std::cout << "Cluster::Move(&p1,&c1,&c2).perform();";

            std::cout << std::endl << std::endl << "[Current Data Formulation]";

            std::cout << std::endl;
            std::cout << std::endl;
            c1.loud("c1");

            std::cout << std::endl;
            c2.loud("c2");
            std::cout << std::endl;

            std::cout << std::endl;
            std::cout << "c1.computeCentroid(): (" << c1.getCentroid() << ")";

            c2.computeCentroid();
            std::cout << std::endl;
            std::cout << "c2.computeCentroid(): (" << c2.getCentroid() << ")";

            Cluster::Move(&p2,&c1,&c2).perform();
            std::cout << std::endl;
            std::cout << "Cluster::Move(&p2,&c1,&c2).perform();";

            std::cout << std::endl << std::endl << "[Current Data Formulation]";

            std::cout << std::endl;
            std::cout << std::endl;
            c1.loud("c1");

            std::cout << std::endl;
            c2.loud("c2");
            std::cout << std::endl;

            c1.computeCentroid();
            std::cout << std::endl;
            std::cout << "c1.computeCentroid(): (" << c1.getCentroid() << ")";

            c2.computeCentroid();
            std::cout << std::endl;
            std::cout << "c2.computeCentroid(): (" << c2.getCentroid() << ")";

            std::cout << std::endl;
            Cluster::Move(&p3,&c1,&c2).perform();
            std::cout << "Cluster::Move(&p3,&c1,&c2).perform();";

            std::cout << std::endl << std::endl << "[Current Data Formulation]";

            std::cout << std::endl;
            c1.loud("c1");

            std::cout << std::endl;
            c2.loud("c2");
            std::cout << std::endl;

            testResult();
            c1.computeCentroid();
            std::cout << std::endl;
            std::cout << "c1.computeCentroid(): (" << c1.getCentroid() << ")";


            c2.computeCentroid();
            std::cout << std::endl;
            std::cout << "c2.computeCentroid(): (" << c2.getCentroid() << ")";

            std::cout << std::endl;
            c1.loud("c1");

            std::cout << std::endl;
            c2.loud("c2");
            std::cout << std::endl;

            testCheck();
            std::cout << std::endl << "c1.computeCentroid(): [Garbage]";
            std::cout << std::endl << "c2.computeCentroid(): (2, 4, 6, 8, 10)";
            std::cout << std::endl;
            std::cout << std::endl << "c1: Size(0)   Centroid: (2.07409e-236)";
            std::cout << std::endl << "{}";
            std::cout << std::endl;
            std::cout << std::endl << "c2: Size(3)   Centroid: (2, 4, 6, 8, 10)";
            std::cout << std::endl << "{(0,0,0,24,30),(0,0,18,0,0),(6,12,0,0,0)}";

            testClose();
        }
////////////////////////////// Centroid Operations - Centroid Operations - Centroid Operations /////////////////////////
        {
            numDims = 6;   // Dimensions in test arrays (don't go below 2)
            testTitle(testNum++, header, "Centroid Operations - pickPoints()");

            Cluster c1(numDims);
            std::cout << "Cluster c1(numDims);";
            std::cout << std::endl;

            double p1arr[] = {6,0,0,0,0,0};
            double p2arr[] = {0,12,0,0,0,0};
            double p3arr[] = {0,0,18,0,0,0};
            double p4arr[] = {0,0,0,24,0,0};
            double p5arr[] = {0,0,0,0,30,0};
            double p6arr[] = {0,0,0,0,0,36};

            std::cout << "double p1arr[" << numDims << "] = ";
            testPtArr(numDims, p1arr, "{", "};");

            std::cout << std::endl;
            std::cout << "double p2arr[" << numDims << "] = ";
            testPtArr(numDims, p2arr, "{", "};");

            std::cout << std::endl;
            std::cout << "double p3arr[" << numDims << "] = ";
            testPtArr(numDims, p3arr, "{", "};");

            std::cout << std::endl;
            std::cout << "double p4arr[" << numDims << "] = ";
            testPtArr(numDims, p4arr, "{", "};");

            std::cout << std::endl;
            std::cout << "double p5arr[" << numDims << "] = ";
            testPtArr(numDims, p5arr, "{", "};");

            std::cout << std::endl;
            std::cout << "double p6arr[" << numDims << "] = ";
            testPtArr(numDims, p6arr, "{", "};");

            std::cout << std::endl;
            Point p1(numDims, p1arr);
            std::cout << "Point p1(" << numDims << ", p1arr);";

            std::cout << std::endl;
            Point p2(numDims, p2arr);
            std::cout << "Point p2(" << numDims << ", p2arr);";

            std::cout << std::endl;
            Point p3(numDims, p3arr);
            std::cout << "Point p3(" << numDims << ", p3arr);";

            std::cout << std::endl;
            Point p4(numDims, p4arr);
            std::cout << "Point p4(" << numDims << ", p4arr);";

            std::cout << std::endl;
            Point p5(numDims, p5arr);
            std::cout << "Point p5(" << numDims << ", p5arr);";

            std::cout << std::endl;
            Point p6(numDims, p6arr);
            std::cout << "Point p6(" << numDims << ", p5arr);";

            std::cout << std::endl;
            c1.add(p1);
            std::cout << "c1.add(p1);";

            std::cout << std::endl;
            c1.add(p2);
            std::cout << "c1.add(p2);";

            std::cout << std::endl;
            c1.add(p3);
            std::cout << "c1.add(p3);";

            std::cout << std::endl;
            c1.add(p4);
            std::cout << "c1.add(p4);";

            std::cout << std::endl;
            c1.add(p5);
            std::cout << "c1.add(p5);";

            std::cout << std::endl;
            c1.add(p6);
            std::cout << "c1.add(p6);";

            PointPtr pickArray1[1];
            PointPtr pickArray2[2];
            PointPtr pickArray3[3];
            PointPtr pickArray4[4];
            PointPtr pickArray5[5];
            PointPtr pickArray6[6];
            PointPtr pickArray7[7];

            std::cout << std::endl;
            c1.pickPoints(1,pickArray1);
            std::cout << "c1.pickPoints(1,pickArray1);";

            std::cout << std::endl;
            c1.pickPoints(2,pickArray2);
            std::cout << "c2.pickPoints(2,pickArray2);";

            std::cout << std::endl;
            c1.pickPoints(3,pickArray3);
            std::cout << "c3.pickPoints(3,pickArray3);";

            std::cout << std::endl;
            c1.pickPoints(4,pickArray4);
            std::cout << "c4.pickPoints(4,pickArray4);";

            std::cout << std::endl;
            c1.pickPoints(5,pickArray5);
            std::cout << "c5.pickPoints(5,pickArray5);";

            std::cout << std::endl;
            c1.pickPoints(6,pickArray6);
            std::cout << "c1.pickPoints(6,pickArray6);";

            std::cout << std::endl;
            c1.pickPoints(7,pickArray7);
            std::cout << "c1.pickPoints(7,pickArray7);";

            testResult();
            std::cout << std::endl << "pickArray1:\n(" << *pickArray1[0] << ")";
            std::cout << std::endl << "pickArray2:\n(" << *pickArray2[0] << ")"
            << "\n(" << *pickArray2[1] << ")";
            std::cout << std::endl << "pickArray3:\n(" << *pickArray3[0] << ")"
            << "\n(" << *pickArray3[1] << ")"
            << "\n(" << *pickArray3[2] << ")";
            std::cout << std::endl << "pickArray4:\n(" << *pickArray4[0] << ")"
            << "\n(" << *pickArray4[1] << ")"
            << "\n(" << *pickArray4[2] << ")"
            << "\n(" << *pickArray4[3] << ")";
            std::cout << std::endl << "pickArray5:\n(" << *pickArray5[0] << ")"
            << "\n(" << *pickArray5[1] << ")"
            << "\n(" << *pickArray5[2] << ")"
            << "\n(" << *pickArray5[3] << ")"
            << "\n(" << *pickArray5[4] << ")";
            std::cout << std::endl << "pickArray6:\n(" << *pickArray6[0] << ")"
            << "\n(" << *pickArray6[1] << ")"
            << "\n(" << *pickArray6[2] << ")"
            << "\n(" << *pickArray6[3] << ")"
            << "\n(" << *pickArray6[4] << ")"
            << "\n(" << *pickArray6[5] << ")";
            std::cout << std::endl << "pickArray6:\n(" << *pickArray7[0] << ")"
            << "\n(" << *pickArray7[1] << ")"
            << "\n(" << *pickArray7[2] << ")"
            << "\n(" << *pickArray7[3] << ")"
            << "\n(" << *pickArray7[4] << ")"
            << "\n(" << *pickArray7[5] << ")";
            std::cout << std::endl;

            testClose();
        }
////////////////////////////// Centroid Operations - Centroid Operations - Centroid Operations /////////////////////////
        {
            numDims = 4;   // Dimensions in test arrays (don't go below 2)
            testTitle(testNum++, header, "Centroid Operations - intraClusterDistance()");

            Cluster c1(numDims);
            std::cout << "Cluster c1(numDims);";
            std::cout << std::endl;

            double p1arr[] = {1,2,3,4};
            double p2arr[] = {2,3,4,5};
            double p3arr[] = {3,4,5,6};
            double p4arr[] = {4,5,6,7};

            std::cout << "double p1arr[" << numDims << "] = ";
            testPtArr(numDims, p1arr, "{", "};");

            std::cout << std::endl;
            std::cout << "double p2arr[" << numDims << "] = ";
            testPtArr(numDims, p2arr, "{", "};");

            std::cout << std::endl;
            std::cout << "double p3arr[" << numDims << "] = ";
            testPtArr(numDims, p3arr, "{", "};");

            std::cout << std::endl;
            std::cout << "double p4arr[" << numDims << "] = ";
            testPtArr(numDims, p4arr, "{", "};");

            std::cout << std::endl;
            Point p1(numDims, p1arr);
            std::cout << "Point p1(" << numDims << ", p1arr);";

            std::cout << std::endl;
            Point p2(numDims, p2arr);
            std::cout << "Point p2(" << numDims << ", p2arr);";

            std::cout << std::endl;
            Point p3(numDims, p3arr);
            std::cout << "Point p3(" << numDims << ", p3arr);";

            std::cout << std::endl;
            Point p4(numDims, p4arr);
            std::cout << "Point p4(" << numDims << ", p4arr);";

            std::cout << std::endl;
            c1.add(p1);
            std::cout << "c1.add(p1);";

            std::cout << std::endl;
            c1.add(p2);
            std::cout << "c1.add(p2);";

            std::cout << std::endl;
            c1.add(p3);
            std::cout << "c1.add(p3);";

            std::cout << std::endl;
            c1.add(p4);
            std::cout << "c1.add(p4);";

            testResult();
            std::cout << std::endl << "c1.intraClusterDistance(): " << c1.intraClusterDistance();

            testCheck();
            std::cout << std::endl << "c1.intraClusterDistance(): 20";

            testClose();
        }
////////////////////////////// Centroid Operations - Centroid Operations - Centroid Operations /////////////////////////
        {
            numDims = 4;   // Dimensions in test arrays (don't go below 2)
            testTitle(testNum++, header, "Centroid Operations - interClusterDistance()");

            Cluster c1(numDims);
            std::cout << "Cluster c1(numDims);";
            std::cout << std::endl;

            Cluster c2(numDims);
            std::cout << "Cluster c1(numDims);";
            std::cout << std::endl;

            double p1arr[] = {1,2,3,4};
            double p2arr[] = {2,3,4,5};
            double p3arr[] = {3,4,5,6};
            double p4arr[] = {4,5,6,7};

            std::cout << "double p1arr[" << numDims << "] = ";
            testPtArr(numDims, p1arr, "{", "};");

            std::cout << std::endl;
            std::cout << "double p2arr[" << numDims << "] = ";
            testPtArr(numDims, p2arr, "{", "};");

            std::cout << std::endl;
            std::cout << "double p3arr[" << numDims << "] = ";
            testPtArr(numDims, p3arr, "{", "};");

            std::cout << std::endl;
            std::cout << "double p4arr[" << numDims << "] = ";
            testPtArr(numDims, p4arr, "{", "};");

            std::cout << std::endl;
            Point p1(numDims, p1arr);
            std::cout << "Point p1(" << numDims << ", p1arr);";

            std::cout << std::endl;
            Point p2(numDims, p2arr);
            std::cout << "Point p2(" << numDims << ", p2arr);";

            std::cout << std::endl;
            Point p3(numDims, p3arr);
            std::cout << "Point p3(" << numDims << ", p3arr);";

            std::cout << std::endl;
            Point p4(numDims, p4arr);
            std::cout << "Point p4(" << numDims << ", p4arr);";

            std::cout << std::endl;
            c1.add(p1);
            std::cout << "c1.add(p1);";

            std::cout << std::endl;
            c1.add(p2);
            std::cout << "c1.add(p2);";

            std::cout << std::endl;
            c2.add(p3);
            std::cout << "c2.add(p3);";

            std::cout << std::endl;
            c2.add(p4);
            std::cout << "c2.add(p4);";

            testResult();
            std::cout << std::endl << "c1.interClusterDistance(): " << interClusterDistance(c1,c2);

            testCheck();
            std::cout << std::endl << "c1.interClusterDistance(): 8";

            testClose();
        }
////////////////////////////// Centroid Operations - Centroid Operations - Centroid Operations /////////////////////////
        {
            numDims = 4;   // Dimensions in test arrays (don't go below 2)
            testTitle(testNum++, header, "Centroid Operations - getClusterEdges()");

            Cluster c1(numDims);
            std::cout << "Cluster c1(numDims);";
            std::cout << std::endl;

            double p1arr[] = {1,2,3,4};
            double p2arr[] = {2,3,4,5};
            double p3arr[] = {3,4,5,6};
            double p4arr[] = {4,5,6,7};

            std::cout << "double p1arr[" << numDims << "] = ";
            testPtArr(numDims, p1arr, "{", "};");

            std::cout << std::endl;
            std::cout << "double p2arr[" << numDims << "] = ";
            testPtArr(numDims, p2arr, "{", "};");

            std::cout << std::endl;
            std::cout << "double p3arr[" << numDims << "] = ";
            testPtArr(numDims, p3arr, "{", "};");

            std::cout << std::endl;
            std::cout << "double p4arr[" << numDims << "] = ";
            testPtArr(numDims, p4arr, "{", "};");

            std::cout << std::endl;
            Point p1(numDims, p1arr);
            std::cout << "Point p1(" << numDims << ", p1arr);";

            std::cout << std::endl;
            Point p2(numDims, p2arr);
            std::cout << "Point p2(" << numDims << ", p2arr);";

            std::cout << std::endl;
            Point p3(numDims, p3arr);
            std::cout << "Point p3(" << numDims << ", p3arr);";

            std::cout << std::endl;
            Point p4(numDims, p4arr);
            std::cout << "Point p4(" << numDims << ", p4arr);";

            std::cout << std::endl;
            c1.add(p1);
            std::cout << "c1.add(p1);";

            std::cout << std::endl;
            c1.add(p2);
            std::cout << "c1.add(p2);";

            std::cout << std::endl;
            c1.add(p3);
            std::cout << "c1.add(p3);";

            std::cout << std::endl;
            c1.add(p4);
            std::cout << "c1.add(p4);";

            testResult();
            std::cout << std::endl << "c1.getClusterEdges(): " << c1.getClusterEdges();

            testCheck();
            std::cout << std::endl << "c1.getClusterEdges(): 6";

            testClose();
        }
        testSectionClose(header);
    }
Ejemplo n.º 2
0
RayPDF QuadLight::randRay() const {
    vec3pdf o = randPt();
    vec3pdf d = m_material->randEmit(normal(o.v));
    return RayPDF(Ray(o.v, d.v),o.p,d.p);
}