Exemple #1
0
/* Display function, depending on flags. */
void display() {
	glEnable(GL_DEPTH_TEST);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);


	if(BEGINNING) {
		makePoints();
	}

	if(ROTATED & !POINTS) {
		lighting();
		if(WIRE) {
			drawWireRotatedPoints();
		}
		else {
			drawSolidRotatedPoints();
		}
	}

	if(POINTS) {
		drawPoints();
	}

    glFlush();  /* Flush all executed OpenGL ops finish */

    /*
     * Since we are using double buffers, we need to call the swap
     * function every time we are done drawing.
     */
    glutSwapBuffers();
}
void Obstacles::makeObstacles(string _inFile){
	ifstream theFile(_inFile.c_str());
	vector <string> splitReturn;
	obPoints newPoints;
	string line;
	if(theFile.is_open()){
		while(!theFile.eof()){
			getline(theFile,line);
			cout<<line<<endl;
			splitReturn = ofSplitString(line, ",");
			vector<string>::iterator iter;
			newPoints.clear();
			for(iter = splitReturn.begin();iter != splitReturn.end();iter++){
				//cout<<*iter<<endl;
				int a = ofToInt(*(iter++));
				int b = ofToInt(*(iter));
				newPoints.push_back(ofxVec2f(a,b));
			}
			allObstacles.push_back(newPoints);
		}
		cout<<allObstacles.size()<<endl;
		makePoints();
		draw();
	} else {
		cout<<"NO FILE!"<<endl;
	}
}
Exemple #3
0
	PlotWithDomain::PlotWithDomain(F1P *f1 ,std::vector<domain *> domains, double ymin, double ymax)
	{
		f=f1;
		this->Domains=domains;
		this->WithDomain=true;
        this->ymax = ymax;
        this->ymin = ymin;
		makePoints(domains);
	}
Exemple #4
0
void GlobalGrid::setUpdate( const IndexSet *update ){
        tensorList->add( update );

        makeOnedRule( getMaxLevel(tensorList) );

        makeTensorsArray();
        makeBalanceWeights();
        makePoints();
};
    static void apply( const SURF& surf, std::ostream& out )
    {
        std::vector<Point> points;
        makePoints( surf, points );

        std::vector<Element> elements;
        makeElements( surf, elements );

        write( surf, points, elements, out );
    }
Exemple #6
0
	PlotWithDomain::PlotWithDomain(F1P *f1 ,std::vector<domain *> domains,F1P *cf, double ymin, double ymax)
	{
		f=f1;
		this->Domains=domains;
		this->WithDomain=true;
        this->ymax = ymax;
        this->ymin = ymin;
		makePoints(domains);
		isColorfulCurve = true;
        this->cf = cf;
		useColorFunction();
	}
Exemple #7
0
Points getPoints(int x1, int y1, int x2, int y2) {
	int i,dx,dy,sdx,sdy,dxabs,dyabs,x,y,px,py;
	int counter = 0;
	Point temp;	
	dx=x2-x1;			//Delta x
	dy=y2-y1;			//Delta y
	dxabs=abs(dx);		//Absolute delta
	dyabs=abs(dy);		//Absolute delta
	sdx=(dx>0)?1:-1; //signum function
	sdy=(dy>0)?1:-1; //signum function
	x=dyabs>>1;
	y=dxabs>>1;
	px=x1;
	py=y1;
	Points p = makePoints();
	if (dxabs>=dyabs)
	{
		for(i=0;i<dxabs;i++)
		{
			y+=dyabs;
			if (y>=dxabs)
			{
				y-=dxabs;
				py+=sdy;
			}
			px+=sdx;
			temp = MakePOINT(px,py);
	        p.tabPoint[p.neff]=temp;
			//printf("(%d, %d)\n", p.tabPoint[p.neff].X, p.tabPoint[p.neff].Y);		
			p.neff++;
		}
	}
	else
	{
		for(i=0;i<dyabs;i++)
		{
			x+=dxabs;
			if (x>=dyabs)
			{
				x-=dyabs;
				px+=sdx;
			}
			py+=sdy;
			temp = MakePOINT(px,py);
	        p.tabPoint[p.neff]=temp;
			//printf("(%d, %d)\n", p.tabPoint[p.neff].X, p.tabPoint[p.neff].Y);		
			p.neff++;
		}
	}
	return p;
}
Exemple #8
0
void GlobalGrid::setState( const IndexSet* state ){
        TypeOneDRule oldRuleType = ruleType;
        int outputs = num_outputs;
        clear();
        ruleType = oldRuleType;
        num_outputs = outputs;

        makeOnedRule( getMaxLevel(state) );

        num_dimensions = state->getNumDimensions();

        tensorList = new IndexSet( num_dimensions );
        tensorList->copy( state );

        makeTensorsArray();
        makeBalanceWeights();
        makePoints();
};
Exemple #9
0
void GlobalGrid::reset( int dimensions, int outputs, int depth, TypeDepth type, TypeOneDRule oned, const int *anisotropic_weights, const double *alpha_beta ){
        clear();
        ruleType = oned;

        num_dimensions = dimensions;
        num_outputs = outputs;

        if ( (oned == rule_gaussgegenbauer) || (oned == rule_gausslaguerre) || (oned == rule_gausshermite) ){
                alpha = alpha_beta[0];
        }
        if ( (oned == rule_gaussjacobi) ){
                alpha = alpha_beta[0];
                beta  = alpha_beta[1];
        }

        if ( anisotropic_weights != 0 ){
                anisotropic = new int[num_dimensions+1];
                tcopy( num_dimensions, anisotropic_weights, anisotropic );
                anisotropic[num_dimensions] = tsum( num_dimensions, anisotropic_weights );
        }

        if ( type == type_level ){
                makeOnedRule( depth );
        }else if ( type == type_basis ){
                makeOnedRule( 3 );
                makeOnedRule( getLevelNeededForBasis( depth ) );
        }else{
                makeOnedRule( getLevelNeededForHyperbolic( depth ) );
        }

        makeTensorList( depth, type );

        makeTensorsArray();

        makeBalanceWeights();

        makePoints();
}
Exemple #10
0
void Application::_doRun
(
double& pbaTimeSum,
double& starTimeSum,
double& splayTimeSum,
double& outTimeSum,
double& gregTimeSum
)
{
    Config& config = getConfig();

    cout << "Run: " << config._run << endl;

    // Get points and weights

    if ( config._inFile ) readPoints();
    else                  makePoints();

    makeWeights();

    // Initialize

    gdelInit( config, _pointVec, _weightVec );

    // Compute Delaunay

    double timePba, timeInitialStar, timeConsistent, timeOutput; 

    HostTimer timerAll;
    timerAll.start();
        gdelCompute( timePba, timeInitialStar, timeConsistent, timeOutput );
    timerAll.stop();

    const double timeTotal = timerAll.value();

    cout << "PBA:         " << timePba         << endl; 
    cout << "InitStar:    " << timeInitialStar << endl;
    cout << "Consistency: " << timeConsistent  << endl;
    cout << "StarOutput:  " << timeOutput      << endl;
    cout << "TOTAL Time:  " << timeTotal       << endl;

    pbaTimeSum   += timePba;
    starTimeSum  += timeInitialStar;
    splayTimeSum += timeConsistent;
    outTimeSum   += timeOutput;
    gregTimeSum  += timeTotal;

    // Check

    if ( config._doCheck )
    {
        TetraMesh tetMesh;
        tetMesh.setPoints( _pointVec, _weightVec );
        getTetraFromGpu( tetMesh );
        tetMesh.check();
    }

    // Destroy

    gdelDeInit();
    _pointVec.clear();
    _weightVec.clear();

    return;
}
Exemple #11
0
void fitLinear()
{
   Int_t n = 40;
   Double_t *x = new Double_t[n];
   Double_t *y = new Double_t[n];
   Double_t *e = new Double_t[n];
   TCanvas *myc = new TCanvas("myc",
      "Fitting 3 TGraphErrors with linear functions");
   myc->SetGrid();

   //Generate points along a 3rd degree polynomial:
   makePoints(n, x, y, e, 3);
   TGraphErrors *gre3 = new TGraphErrors(n, x, y, 0, e);
   gre3->Draw("a*");
   //Fit the graph with the predefined "pol3" function
   gre3->Fit("pol3");
   //Access the fit resuts
   TF1 *f3 = gre3->GetFunction("pol3");
   f3->SetLineWidth(1);

   //Generate points along a sin(x)+sin(2x) function
   makePoints(n, x, y, e, 2);
   TGraphErrors *gre2=new TGraphErrors(n, x, y, 0, e);
   gre2->Draw("*same");
   gre2->SetMarkerColor(kBlue);
   gre2->SetLineColor(kBlue);
   //The fitting function can be predefined and passed to the Fit function
   //The "++" mean that the linear fitter should be used, and the following
   //formula is equivalent to "[0]*sin(x) + [1]*sin(2*x)"
   //A function, defined this way, is in no way different from any other TF1,
   //it can be evaluated, drawn, you can get its parameters, etc.
   //The fit result (parameter values, parameter errors, chisquare, etc) are
   //written into the fitting function.
   TF1 *f2 = new TF1("f2", "sin(x) ++ sin(2*x)", -2, 2);
   gre2->Fit(f2);
   f2 = gre2->GetFunction("f2");
   f2->SetLineColor(kBlue);
   f2->SetLineWidth(1);

   //Generate points along a -2+exp(-x) function
   makePoints(n, x, y, e, 4);
   TGraphErrors *gre4=new TGraphErrors(n, x, y, 0, e);
   gre4->Draw("*same");
   gre4->SetMarkerColor(kRed);
   gre4->SetLineColor(kRed);
   //If you don't want to define the function, you can just pass the string
   //with the the formula:
   gre4->Fit("1 ++ exp(-x)");
   //Access the fit results:
   TF1 *f4 = gre4->GetFunction("1 ++ exp(-x)");
   f4->SetName("f4");
   f4->SetLineColor(kRed);
   f4->SetLineWidth(1);

   TLegend *leg = new TLegend(0.3, 0.7, 0.65, 0.9);
   leg->AddEntry(gre3, " -7 + 2*x*x + x*x*x", "p");
   leg->AddEntry(gre2, "sin(x) + sin(2*x)", "p");
   leg->AddEntry(gre4, "-2 + exp(-x)", "p");
   leg->Draw();

}