本文整理汇总了C++中GeomGlut::xMax方法的典型用法代码示例。如果您正苦于以下问题:C++ GeomGlut::xMax方法的具体用法?C++ GeomGlut::xMax怎么用?C++ GeomGlut::xMax使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeomGlut
的用法示例。
在下文中一共展示了GeomGlut::xMax方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawFunctions
void drawFunctions()
{
const float STEP = graphWin.findSmartStepX();
glPointSize(2.0f);
//Draw selected (f(x))
for(float x=graphWin.xMin(); x<graphWin.xMax(); x+=STEP)
graphWin.plot(x, f(x), 1.0f,0.5f,0.0f);
//Draw f(x) = x
for(float x=graphWin.xMin(); x<graphWin.xMax(); x+=STEP)
graphWin.plot( x, x, 0.5f,0.5f,0.5f);
//Draw g(x)
for(float x=graphWin.xMin()+STEP; x<graphWin.xMax(); x+=STEP)
graphWin.plot(x, g(x), 1.0f,0.5f,1.0f);
clear();
printHeader();
std::cout << "x est compris dans l'ensemble [" << graphWin.xMin() << ";" << graphWin.xMax() << "[" << std::endl;
std::cout << "y est compris dans l'ensemble [" << graphWin.yMin() << ";" << graphWin.yMax() << "[" << std::endl << std::endl;
std::cout << "Information graphique : " << std::endl
<< "- Fonction choisie (f(x)) en orange" << std::endl
<< "- Fonction h(x) = x, en gris" << std::endl
<< "- Fonction g(x) = x + l*f(x), l = 1, en rose" << std::endl
<< "- Les axes x,y en bleu " << std::endl
<< "- Les vecteurs unitaires en rouge " << std::endl
<< "- Les solutions de la fonction en vert" << std::endl << std::endl;
vector<long double> solutions = findRoot();
std::cout << "Solutions : " << std::endl;
glColor3f(0.0f, 1.0f, 0.0f);
glPointSize(10);
//Draw solutions
for(unsigned int i = 0;i < solutions.size(); ++i)
{
std::cout << "[" << i << "] -> " << static_cast<double>(solutions[i]) << std::endl;
glBegin( GL_POINTS );
glVertex3d(solutions[i], 0, 0.0);
glEnd();
}
}
示例2: 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;
}
}
示例3: Reshape
void Reshape(int w, int h)
{
if (h == 0) h = 1;
if (w == 0) w = 1;
glViewport(0, 0, w, h);
graphWin.setWinPixels( w, h );
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
float xRatio = static_cast<float>(w)/static_cast<float>(graphWin.xWinFunc());
float yRatio = static_cast<float>(h)/static_cast<float>(graphWin.yWinFunc());
// Volume de clipping : (left, right, bottom, top, near, far)
glOrtho(graphWin.xMin()*xRatio, graphWin.xMax()*xRatio, graphWin.yMin()*yRatio, graphWin.yMax()*yRatio, -2.0f, 2.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
示例4: findRoot
std::vector<long double> findRoot()
{
const long double epsilon = std::numeric_limits<double>::epsilon();
const long double STEP = 2*epsilon;
std::vector<long double> solutions;
//FindRoot
//Recherche les racines du côté x >= 0
long double oldStep = 2*epsilon;
for(long double x=oldStep; x<graphWin.xMax(); x+=fabsl(g(x)-x))
{
//Dessin des barres comme dans le cours
graphWin.segment(x-oldStep,x-oldStep,x-oldStep,g(x-oldStep));
if(x > g(x))
{
if(f == f1)
graphWin.segment(x-oldStep,g(x-oldStep),x,g(x-oldStep));
else
graphWin.segment(x-oldStep,x-oldStep,x,x-oldStep);
}
else
graphWin.segment(x-oldStep,x,x,x);
if(fabsl(g(x)-x) <= epsilon)
{
solutions.push_back(x);
x+=STEP;//On ajoute suffisement de STEP pour que la fonction puisse repartir et chercher d'autres solutions
}
oldStep = fabsl(g(x)-x);
}
oldStep = 2*epsilon;
//Recherche les racines du côté x < 0
for(long double x=-epsilon; x > graphWin.xMin(); x-=fabsl(g(x)-x))
{
//Dessin des barres comme dans le cours
graphWin.segment(x+oldStep,x+oldStep,x+oldStep,g(x+oldStep));
if(x < g(x))
{
if(f == f1)
graphWin.segment(x+oldStep,g(x+oldStep),x,g(x+oldStep));
else
graphWin.segment(x+oldStep,x+oldStep,x,x+oldStep);
}
else
graphWin.segment(x+oldStep,x,x,x);
if(fabsl(g(x)-x) <= epsilon)
{
solutions.push_back(x);
x-=STEP;//On ajoute le STEP initiale pour que la fonction puisse repartir et chercher d'autres solutions
}
oldStep = fabsl(g(x)-x);
}
sort(solutions.begin(),solutions.end());
return solutions;
}