本文整理汇总了C++中GeomGlut类的典型用法代码示例。如果您正苦于以下问题:C++ GeomGlut类的具体用法?C++ GeomGlut怎么用?C++ GeomGlut使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GeomGlut类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: double
void GeomGlut::initGraphicsWin( unsigned int pixelWinX, unsigned int pixelWinY, double _xMin, double _xMax, double _yMin, double _yMax ,long double (*func)(long double))
{
f = func;
if(_xMax-_xMin<=0)
return;
winFuncPixels.x = pixelWinX;
winFuncPixels.y = pixelWinY;
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA);
glutInitWindowPosition(0, 0);
glutInitWindowSize(winFuncPixels.x, winFuncPixels.y);
// at the begining, the function win pixel and the actual win pixel are identical:
graphWin.setWinPixels( winFuncPixels.x, winFuncPixels.y );
minWin.x = _xMin;
minWin.y = _yMin;
maxWin.x = _xMax;
maxWin.y = _yMax;
glutCreateWindow("Algorithmes numériques: labo#4 - Part 1");
// Initialiser la couleur du fond (blanc)
glClearColor(0.9f, 0.9f, 0.9f, 1.0f);
glutReshapeFunc( Reshape );
glutDisplayFunc( Display );
glutMainLoop();
}
示例2: initGraphicsWin
void GeomGlut::initGraphicsWin( unsigned int pixelWinX, double xMin, double xMax, double yMin, double yMax )
{
if(xMax-xMin<=0)
{
cout << "xMax-xMin cannot be < or = to 0" << endl << endl;
return;
}
winFuncPixels.x = pixelWinX;
winFuncPixels.y = (unsigned int)((yMax-yMin) * (double)winFuncPixels.x/(xMax-xMin));
int argc = 1;
char *argv[1] = {(char*)"Glut"};
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_SINGLE | GLUT_RGBA | GLUT_MULTISAMPLE);
glutInitWindowPosition(0, 0);
cout << "System coordinate min(" << xMin << ", " << yMin << ") max(" << xMax << ", " << yMax << " give for " << winFuncPixels.x << " pixels in X, a Y pixel number of " << winFuncPixels.y << endl << endl;
cout << "pixelWin(" << winFuncPixels.x << ", " << winFuncPixels.y << ")...";
glutInitWindowSize(winFuncPixels.x, winFuncPixels.y);
cout << " success!" << endl << endl;
// at the begining, the function win pixel and the actual win pixel are identical:
graphWin.setWinPixels( winFuncPixels.x, winFuncPixels.y );
minWin.x = xMin;
minWin.y = yMin;
maxWin.x = xMax;
maxWin.y = yMax;
glutCreateWindow("Algorithmes numeriques: labo#6");
// Initialiser la couleur du fond (blanc)
glClearColor(0.9f, 0.9f, 0.9f, 1.0f);
glutMouseFunc( Click );
glutReshapeFunc( Reshape );
glutDisplayFunc( Display );
glutMainLoop();
}
示例3: plotFunction
/*------------------------------------------------------------------*\
|* Visualization functions *|
\*------------------------------------------------------------------*/
void plotFunction(FunctionENUM function)
{
switch (function)
{
case FUNCTION1:
for (double i = LEFT; i <= RIGHT; i += 0.001)
{
graphWin.plot(i, f1(i), 1);
}
break;
case FUNCTION2:
for (double i = LEFT; i <= RIGHT; i += 0.0001)
{
graphWin.plot(i, f2(i), 1);
}
break;
case GOLD_FUNCTION:
for (int i = 0; i < 19; i++)
{
graphWin.segment(map(i, 0, 19, 0, RIGHT), map(arrayGold[i], 250, 1700, 0, TOP), map(i + 1, 0, 19, 0, RIGHT), map(arrayGold[i + 1], 250, 1700, 0, TOP));
}
break;
default:
cout << "The given function does not exist";
break;
}
}
示例4: plotCurrentFunction
/****************************************************
* Helper functions
****************************************************/
void plotCurrentFunction()
{
for(double i = LEFTLIMIT; i <= RIGHTLIMIT; i = i + 0.01)
{
#ifdef USING_FIRST_FUNCTION
graphWin.plot(i,f(i),1);
#else
graphWin.plot(i,g(i),1);
#endif
}
}
示例5: plotAdaptedFunction
void plotAdaptedFunction(double lambda)
{
for(double i = LEFTLIMIT; i < RIGHTLIMIT; i += 0.01)
{
graphWin.plot(i, fixedPointAdapterFunction(i, lambda), 1);
}
}
示例6: main
int main(int argc, char **argv)
{
glutInit(&argc, argv);
graphWin.initGraphicsWin( 1000, -15.1, 15.1, -4.1, 4.1 );
return(0);
}
示例7: Display
void Display()
{
glClear(GL_COLOR_BUFFER_BIT);
graphWin.drawAxes();
mainFunction();
glFlush();
}
示例8: main
int main()
{
setlocale(LC_ALL, "frs");
const vector<pair<string,long double> > goldValues = createMapGold();
const vector<pair<string,long double> > goldInflations = createInflationChart(goldValues);
graphWin.initGraphicsWin( 1400, 800, 0, goldValues.size(), 0, 3000, goldValues, goldInflations);
return( 0 );
}
示例9: plotSecondDegreeDerivatedFunction
void plotSecondDegreeDerivatedFunction(FunctionENUM function, double h)
{
if (function != GOLD_FUNCTION)
{
for (double i = LEFT; i <= RIGHT; i += 0.001)
{
graphWin.plot(i, calculateSecondDegreeDerivative(function, i, h), 1);
}
}
else
{
for (double i = 0; i < 18; i += 1)
{
double secondDegreeDerivative = calculateSecondDegreeDerivative(function, i, h);
double secondDegreeDerivativePlusOne = calculateSecondDegreeDerivative(function, i + 1, h);
graphWin.segment(map(i, 0, 19, 0, RIGHT), map(secondDegreeDerivative, 250, 1700, 0, TOP), map(i + 1, 0, 19, 0, RIGHT), map(secondDegreeDerivativePlusOne, 250, 1700, 0, TOP));
}
}
}
示例10: bolzanoBisectionRecursive
void bolzanoBisectionRecursive(double a, double b, double epsilon)
{
if(fabs(b-a) <= epsilon)
{
#ifdef USING_FIRST_FUNCTION
if (f(a) <= epsilon )
#else
if (g(a) <= epsilon )
#endif
cout << endl << ">>> " << b << " <<<<" << endl << endl;
return;
}
double c = (a+b)/2;
graphWin.segment(a,MAXHEIGHT,a,MINHEIGHT);
graphWin.segment(b,MAXHEIGHT,b,MINHEIGHT);
graphWin.segment(c,MAXHEIGHT,c,MINHEIGHT);
cout << "Analysing interval [" << a <<", " << b << "] with middle point at : "<< c <<endl;
if (c == 0)
{
cout << "0 is in " << c << endl;
}
#ifdef USING_FIRST_FUNCTION
if (oppositeSigns(f(a),f(c)))
#else
if (oppositeSigns(g(a),g(c)))
#endif
{
cout << " Narrowing interval to [" << a <<", " << c << "]" << endl;
bolzanoBisectionRecursive(a,c,epsilon);
}
#ifdef USING_FIRST_FUNCTION
if (oppositeSigns(f(c), f(b)))
#else
if (oppositeSigns(g(c), g(b)))
#endif
{
cout << " Narrowing interval to [" << c <<", " << b << "]" << endl;
bolzanoBisectionRecursive(c,b,epsilon);
}
}
示例11: plotDerivatedFunction
void plotDerivatedFunction(FunctionENUM function, DerivationMethodENUM derivationMethod, double h)
{
if (function != GOLD_FUNCTION)
{
for (double i = LEFT; i <= RIGHT; i += 0.001)
{
graphWin.plot(i, calculateDerivative(function, i, h, derivationMethod), 1);
}
}
else
{
double leftLimit = derivationMethod == CENTRAL_DIFFERENCE ? 1 : 0;
for (double i = leftLimit; i < 18; i += 1)
{
double derivative = calculateDerivative(function, i, h, derivationMethod);
double derivativePlusOne = calculateDerivative(function, i + 1, h, derivationMethod);
graphWin.segment(map(i, 0, 19, 0, RIGHT), map(derivative, 250, 1700, 0, TOP), map(i + 1, 0, 19, 0, RIGHT), map(derivativePlusOne, 250, 1700, 0, TOP));
}
}
}
示例12: mainFunction
void mainFunction( void )
{
graphWin.drawAxes();
RectangleV1 rec(-2,2,4,2);
rec.draw();
CircleV1 cercle(0,0,1,300);
cercle.draw();
TriangleV1 triangle(2.0,2.0,1.0,3.0,2.0,1.0);
triangle.draw();
SquareV1 square(2.0,2.0,0.5);
square.draw();
}
示例13: fixedPoint
void fixedPoint(double epsilon, double lambda, double startingPoint,bool isFirst)
{
double previousPoint = startingPoint;
int loopCounter = 0;
while (fabs(fixedPointAdapterFunction(previousPoint) - previousPoint) > epsilon && loopCounter < LOOP_LIMIT)
{
previousPoint=fixedPointAdapterFunction(previousPoint, lambda);
if(numberLine == 2)
{
plotAdaptedFunction(lambda);//we plot it here to have the proper lamda drawn
graphWin.segment(previousPoint, fixedPointAdapterFunction(previousPoint, lambda), fixedPointAdapterFunction(previousPoint, lambda), fixedPointAdapterFunction(previousPoint, lambda));
graphWin.segment(previousPoint, previousPoint, previousPoint, fixedPointAdapterFunction(previousPoint, lambda));
}
loopCounter++;
}
#ifdef USING_FIRST_FUNCTION
if(f(previousPoint) <= epsilon)
#else
if(g(previousPoint) <= epsilon)
#endif
{
graphWin.plot(previousPoint,fixedPointAdapterFunction(previousPoint, lambda),5);
cout << "x = " << previousPoint << endl;
}
else
{
cout << "x MAUVAIS = " << previousPoint << endl;
}
double tester = 2.0;
if(lambda > tester)
{
numberLine++;
lambda -= tester;
fixedPoint(epsilon, lambda,startingPoint);
}
}
示例14: Click
void Click(int button, int state, int x, int y)
{
double posX, posY;
switch(button)
{
case 0:
posX = ((double)x / (double)graphWin.xWinFunc()) * (graphWin.xMax() - graphWin.xMin()) + graphWin.xMin();
posY = ((1 - (double)y / (double)graphWin.yWinFunc())) * (graphWin.yMax() - graphWin.yMin()) + graphWin.yMin();
dessinerCourbe(posX, posY);
break;
}
}
示例15: main
int main(int argc, char *argv[])
{
cout << "Choisir une fonction a afficher : " << endl;
cout << "1) x^5 + 5*x^3 + 2*x" << endl;
cout << "2) x/(1-x^2)" << endl;
cout << "x) Quitter" << endl << endl;
cout << "Choix : ";
cin >> res1;
cout << "Choix de la derivee:" << endl;
cout << "1) derivee premiere" << endl;
cout << "2) derivee seconde" << endl;
cout << "Choix : ";
cin >> res2;
graphWin.initGraphicsWin(1000, X_MIN, X_MAX, Y_MIN, Y_MAX);
return 0;
}