y=4λx(1-x) y=x 逻辑图 源代码
来源:互联网 发布:淘宝学生手表 编辑:程序博客网 时间:2024/06/05 06:25
#include<windows.h>
#include<math.h>
#include <gl/Glut.h>
#include <iostream>
using namespace std;
struct GLPoint{
GLdouble x, y;
};
GLPoint pt[2]={{0,0},{0,0}};
const GLint num = 50; //循环最大限制
const GLint screenWidth = 600;
const GLint screenHeight = 600;
GLdouble A, B, C, D;
static GLdouble lambda = 0.7; //λ = 0.7
static GLdouble startNum = 0.1; // x的初始值
void myDisplay(void);
void myInit(void);
void setWindow(GLdouble left, GLdouble right , GLdouble botton, GLdouble top);
void setViewport(GLdouble left, GLdouble right , GLdouble botton, GLdouble top);
void drawLineToCurve(GLint i);
void drawLineToLine(GLint i);
int main(int argc, char ** argv){
//cout<<"输入x起始值(0~)";
pt[0].x = startNum;
pt[0].y = 0.0;
cout<<pt[0].x<<pt[0].y<<endl;
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(screenWidth,screenHeight);
glutInitWindowPosition(100,100);
glutCreateWindow("y=4λx(1-x) y=x 逻辑图");
setWindow(0,1,0,1);
setViewport(0,screenWidth,0,screenHeight);
glutDisplayFunc(myDisplay);
myInit();
glutMainLoop();
return 0;
}
void setViewport(GLdouble left, GLdouble right , GLdouble botton, GLdouble top){
glViewport(left,right,right-left,top-botton);
}
void setWindow(GLdouble left, GLdouble right , GLdouble botton, GLdouble top){
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(left,right,botton,top);
}
void drawLineToCurve(GLint i){
pt[1].x = pt[0].x;
pt[1].y = 4*lambda*pt[1].x*(1-pt[1].x);
cout<<pt[1].x<<","<<pt[1].y<<" ";
glBegin(GL_LINES);
glVertex2d(pt[0].x,pt[0].y);
glVertex2d(pt[1].x,pt[1].y);
glEnd();
glFlush();
}
void drawLineToLine(GLint i){
pt[0].y = pt[1].y;
pt[0].x = pt[0].y;
cout<<pt[0].x<<","<<pt[0].y<<" ";
glBegin(GL_LINES);
glVertex2d(pt[1].x,pt[1].y);
glVertex2d(pt[0].x,pt[0].y);
glEnd();
glFlush();
}
void myDisplay(void){
glClear(GL_COLOR_BUFFER_BIT);
// y = x ; 直线方程
glBegin(GL_LINES);
glVertex2d(0.0,0.0);
glVertex2d(1.0,1.0);
glEnd();
glFlush();
//曲线方程
glBegin(GL_LINE_STRIP);
for (GLdouble x = 0 ; x < 1 ; x += 0.01)
{
glVertex2d(x, 4*lambda*x*(1-x));
}
glEnd();
glFlush();
//曲线==》折线==》曲线==》折线... 焦点
for (int i= 0 ; i < num; i ++)
{
if (i%2 == 0 )
{
drawLineToCurve(i);
}
else{
drawLineToLine(i);
}
}
}
void myInit(void){
glClearColor(1.0,1.0,1.0,0.0);
glColor3f(0.0f, 0.0f, 0.0f);
glPointSize(1.0);
glLineWidth(1.0);
#include<math.h>
#include <gl/Glut.h>
#include <iostream>
using namespace std;
struct GLPoint{
GLdouble x, y;
};
GLPoint pt[2]={{0,0},{0,0}};
const GLint num = 50; //循环最大限制
const GLint screenWidth = 600;
const GLint screenHeight = 600;
GLdouble A, B, C, D;
static GLdouble lambda = 0.7; //λ = 0.7
static GLdouble startNum = 0.1; // x的初始值
void myDisplay(void);
void myInit(void);
void setWindow(GLdouble left, GLdouble right , GLdouble botton, GLdouble top);
void setViewport(GLdouble left, GLdouble right , GLdouble botton, GLdouble top);
void drawLineToCurve(GLint i);
void drawLineToLine(GLint i);
int main(int argc, char ** argv){
//cout<<"输入x起始值(0~)";
pt[0].x = startNum;
pt[0].y = 0.0;
cout<<pt[0].x<<pt[0].y<<endl;
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(screenWidth,screenHeight);
glutInitWindowPosition(100,100);
glutCreateWindow("y=4λx(1-x) y=x 逻辑图");
setWindow(0,1,0,1);
setViewport(0,screenWidth,0,screenHeight);
glutDisplayFunc(myDisplay);
myInit();
glutMainLoop();
return 0;
}
void setViewport(GLdouble left, GLdouble right , GLdouble botton, GLdouble top){
glViewport(left,right,right-left,top-botton);
}
void setWindow(GLdouble left, GLdouble right , GLdouble botton, GLdouble top){
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(left,right,botton,top);
}
void drawLineToCurve(GLint i){
pt[1].x = pt[0].x;
pt[1].y = 4*lambda*pt[1].x*(1-pt[1].x);
cout<<pt[1].x<<","<<pt[1].y<<" ";
glBegin(GL_LINES);
glVertex2d(pt[0].x,pt[0].y);
glVertex2d(pt[1].x,pt[1].y);
glEnd();
glFlush();
}
void drawLineToLine(GLint i){
pt[0].y = pt[1].y;
pt[0].x = pt[0].y;
cout<<pt[0].x<<","<<pt[0].y<<" ";
glBegin(GL_LINES);
glVertex2d(pt[1].x,pt[1].y);
glVertex2d(pt[0].x,pt[0].y);
glEnd();
glFlush();
}
void myDisplay(void){
glClear(GL_COLOR_BUFFER_BIT);
// y = x ; 直线方程
glBegin(GL_LINES);
glVertex2d(0.0,0.0);
glVertex2d(1.0,1.0);
glEnd();
glFlush();
//曲线方程
glBegin(GL_LINE_STRIP);
for (GLdouble x = 0 ; x < 1 ; x += 0.01)
{
glVertex2d(x, 4*lambda*x*(1-x));
}
glEnd();
glFlush();
//曲线==》折线==》曲线==》折线... 焦点
for (int i= 0 ; i < num; i ++)
{
if (i%2 == 0 )
{
drawLineToCurve(i);
}
else{
drawLineToLine(i);
}
}
}
void myInit(void){
glClearColor(1.0,1.0,1.0,0.0);
glColor3f(0.0f, 0.0f, 0.0f);
glPointSize(1.0);
glLineWidth(1.0);
}
- y=4λx(1-x) y=x 逻辑图 源代码
- 解方程: x+y=x|y
- (x&y)+((x^y)>>1)
- (x&y)+((x^y)>>1)
- (x&y)+((x^y)>>1)
- (x&y)+((x^y)>>1)
- (x&y)+((x^y)>>1)
- $$x^y+y^x>1$$
- x=min(x, y)
- y=mysqrt(x)
- 数学方法,证明:(x&y)+((x^y)>>1)=(x+y)/2
- x+=y与x=x+y的区别
- x+=y与x=x+y的区别
- bzoj 4152 the camptin (dis[x][y]=min(|x.x-y.x|,|x.y-y.y|),求1,n最短路)
- train_test_split(X, y, stratify=y)
- (x&y) + ( (x^y)>>1 )证明
- (x&y) + ( (x^y)>>1 )证明
- (x&y)+((x^y)>>1)用法
- 视频带宽计算公式(码流_分辨率_帧率)
- Android中集成第三方软件包(.jar, .so)
- 20个免费的网络电话
- 关于adb命令没有权限访问手机设备的问题
- android抽屉效果的实现
- y=4λx(1-x) y=x 逻辑图 源代码
- 如何自学好Java(相当经典)
- SQL Server链接Oracle的方法
- java 21点
- poj1061 青蛙的约会 扩展欧几里德
- hdu 4248 A Famous Stone Collector(组合数学&DP)
- JBoss 系列三十:JBoss Data Grid(Infinispan)服务器
- ICE C++ Hello World
- 单点登录加验证码例子