begin process at 2012 05 27 17:36:54
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Maths & Algorithmes

 > OPENGL : SINUSOIDES 3D

OPENGL : SINUSOIDES 3D


 Information sur la source

Note :
10 / 10 - par 3 personnes
10,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :Maths & Algorithmes Niveau :Débutant Date de création :07/12/2003 Vu / téléchargé :2 548 / 254

Auteur : JCDjcd

Ecrire un message privé
Ce membre participe au partage de revenus publicitaires
Commentaire sur cette source (6)
Ajouter un commentaire et/ou une note


 Description

Cliquez pour voir la capture en taille normale
Programme qui montre deux sons.
L'intensite du son decroit avec la distance.
En plus il y a le tracage des decibels de la somme des deux bruit en un point donne.

Source

  • #include <windows.h>
  • #include <math.h>
  • #include <gl/gl.h>
  • #include <gl/glu.h>
  • #include <gl/glaux.h>
  • typedef struct tagFUNC_SINUS
  • {
  • double dx; // delta x
  • double dy; // delta y
  • double dz; // delta z
  • double h; // amplitude
  • double lambda; // longeur d'onde
  • void (*funcColor)(double); // fonction de coloriage
  • double arg;
  • }FUNC_SINUS,*P_FUNC_SINUS;
  • typedef struct tagFUNC_SUM
  • {
  • double dz; // delta z
  • void (*funcColor)(double); // fonction de coloriage
  • P_FUNC_SINUS a;
  • P_FUNC_SINUS b;
  • double arg;
  • }FUNC_SUM,*P_FUNC_SUM;
  • //------------------------------------------------------------
  • #define PI 3.1415926535
  • //------------------------------------------------------------
  • #define MY_MIN_ZOOM 1
  • #define MY_MAX_ZOOM 100
  • #define MY_CUBE_LINE 100
  • #define MY_SINUS_1 101
  • #define MY_SINUS_2 102
  • #define MY_SUM 103
  • //------------------------------------------------------------
  • void RePaint(HDC DC,double zoom,double theta,double phi)
  • {
  • glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  • glMatrixMode(GL_MODELVIEW);
  • glLoadIdentity();
  • // position de l'oeil
  • gluLookAt(zoom*cos(theta)*cos(phi),zoom*sin(theta)*cos(phi),zoom*sin(phi),0,0,0,cos(theta-PI)*cos(PI/2.-phi),sin(theta-PI)*cos(PI/2.-phi),sin(PI/2.-phi));
  • // on trace les lignes du cube
  • glCallList(MY_CUBE_LINE);
  • // on trace la premire sinusoide
  • glCallList(MY_SINUS_1);
  • // on trace la seconde sinusoide
  • glCallList(MY_SINUS_2);
  • // on trace la somme (franges d'interferences)
  • glCallList(MY_SUM);
  • glPopMatrix();
  • SwapBuffers(DC);
  • }
  • //------------------------------------------------------------
  • void InitPixelFormat(HDC hdc)
  • {
  • PIXELFORMATDESCRIPTOR pfd = {sizeof (PIXELFORMATDESCRIPTOR),1,PFD_SUPPORT_OPENGL | PFD_TYPE_RGBA | PFD_DRAW_TO_WINDOW | PFD_DOUBLEBUFFER,16,0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,0,0,0,0,0,0};
  • SetPixelFormat(hdc,ChoosePixelFormat(hdc,&pfd),&pfd);
  • }
  • //------------------------------------------------------------
  • // degrades du rouge
  • void FillColorRedToYellow(double x)
  • {glColor3d(1.,x,0.);}
  • void FillColorRedToMagenta(double x)
  • {glColor3d(1.,0.,x);}
  • void FillColorRedToWhite(double x)
  • {glColor3d(1.,x,x);}
  • // degrades du vert
  • void FillColorGreenToRed(double x)
  • {glColor3d(1.-x,x,x);}
  • void FillColorGreenToWhite(double x)
  • {glColor3d(x,1.,x);}
  • void FillColorGreenYellow(double x)
  • {glColor3d(x,1.,0.);}
  • void FillColorGreenToCyan(double x)
  • {glColor3d(0.,1.,x);}
  • // degrades du bleu
  • void FillColorBlueToMaganta(double x)
  • {glColor3d(x,0.,1.);}
  • void FillColorBlueToWhite(double x)
  • {glColor3d(x,x,1.);}
  • void FillColorBlueToCyan(double x)
  • {glColor3d(0.,x,1.);}
  • // degrade de gris
  • void FillColorBlackToWhite(double x)
  • {glColor3d(x,x,x);}
  • //------------------------------------------------------------
  • // construit un sinusoide 3D de centre (dx,dy,0)
  • // d'amplitude <h>, et de longueur d'onde <lambda>
  • double calcR(P_FUNC_SINUS p,double x,double y)
  • {
  • return sqrt((x-p->dx)*(x-p->dx)+(y-p->dy)*(y-p->dy));
  • }
  • double funcSinus(P_FUNC_SINUS p,double x,double y)
  • {
  • // distance
  • double r;
  • p->arg = r = calcR(p,x,y);
  • if(r > 0.)
  • {
  • return p->dz - p->h*sin(r*2.*PI/p->lambda)/r;
  • }
  • else
  • {
  • return p->dz - p->h*2.*PI/p->lambda;
  • }
  • }
  • void colorSinus(P_FUNC_SINUS p,double z)
  • {
  • p->funcColor(0.5+(z-p->dz)/(2.*p->h));
  • //p->funcColor(1.-1./(1.+p->arg));
  • }
  • //------------------------------------------------------------
  • // construit l'interference de deux sinusoides
  • // Ici calculs complexes ...
  • double funcSum(P_FUNC_SUM p,double x,double y)
  • {
  • double rA,rB;
  • double reA,imA;
  • double reB,imB;
  • double k;
  • k = 2.*PI/p->a->lambda;
  • rA = calcR(p->a,x,y);
  • rB = calcR(p->b,x,y);
  • if(rA <= 0. || rB <= 0.)
  • {
  • p->arg = 0.;
  • return 0.;
  • }
  • reA = cos(k*rA)/rA;
  • reB = cos(k*rB)/rB;
  • imA = sin(k*rA)/rA;
  • imB = sin(k*rB)/rB;
  • // l'argument
  • p->arg = atan2(imA + imB,reA + reB);
  • // le module
  • return p->dz+4*log10((reA + reB)*(reA + reB)+(imA + imB)*(imA + imB));
  • }
  • void colorSum(P_FUNC_SUM p,double z)
  • {
  • //p->funcColor(0.5+(p->arg/(2.*PI)));
  • p->funcColor(0.6-(7+z-p->dz)/(9.));
  • }
  • //------------------------------------------------------------
  • void CreateGraph3D(double (*calcFunc)(void*,double,double),void (*funcColor)(void*,double),void *param)
  • {
  • double x,y;
  • double step;
  • step = 0.2;
  • for(y=-10.+step;y<=+10.;y+=step)
  • {
  • glBegin(GL_QUAD_STRIP);
  • for(x=-10.;x<=+10.;x+=step)
  • {
  • double z;
  • // on doit garantir qu'il faut faire le calcul
  • // AVANT le coloriage
  • z = calcFunc(param,x,y - step);
  • funcColor(param,z);
  • glVertex3d(x,y - step,z);
  • z = calcFunc(param,x,y);
  • funcColor(param,z);
  • glVertex3d(x,y,calcFunc(param,x,y));
  • }
  • glEnd();
  • }
  • }
  • //------------------------------------------------------------
  • void CreateNewList(void)
  • {
  • FUNC_SINUS f1,f2;
  • FUNC_SUM fs;
  • glNewList(MY_CUBE_LINE,GL_COMPILE);
  • glColor3d(0.,1.,0.);
  • glBegin(GL_LINE_LOOP);
  • glVertex3d(-10.,-10.,-10.);
  • glVertex3d(-10.,-10.,+10.);
  • glVertex3d(-10.,+10.,+10.);
  • glVertex3d(-10.,+10.,-10.);
  • glEnd();
  • glBegin(GL_LINE_LOOP);
  • glVertex3d(+10.,-10.,-10.);
  • glVertex3d(+10.,-10.,+10.);
  • glVertex3d(+10.,+10.,+10.);
  • glVertex3d(+10.,+10.,-10.);
  • glEnd();
  • glBegin(GL_LINES);
  • glVertex3d(+10.,-10.,-10.);
  • glVertex3d(-10.,-10.,-10.);
  • glVertex3d(+10.,-10.,+10.);
  • glVertex3d(-10.,-10.,+10.);
  • glVertex3d(+10.,+10.,+10.);
  • glVertex3d(-10.,+10.,+10.);
  • glVertex3d(+10.,+10.,-10.);
  • glVertex3d(-10.,+10.,-10.);
  • glEnd();
  • glEndList();
  • glNewList(MY_SINUS_1,GL_COMPILE);
  • f1.dx = -0.;
  • f1.dy = -5.5;
  • f1.dz = -10.;
  • f1.h = 5.;
  • f1.lambda = 1.5;
  • f1.funcColor = FillColorRedToYellow;
  • CreateGraph3D(funcSinus,colorSinus,&f1);
  • glEndList();
  • glNewList(MY_SINUS_2,GL_COMPILE);
  • f2.dx = +0.;
  • f2.dy = +5.5;
  • f2.dz = -10.;
  • f2.h = 5.;
  • f2.lambda = 1.5;
  • f2.funcColor = FillColorBlueToCyan;
  • CreateGraph3D(funcSinus,colorSinus,&f2);
  • glEndList();
  • glNewList(MY_SUM,GL_COMPILE);
  • fs.dz = 12.5;
  • fs.a = &f1;
  • fs.b = &f2;
  • fs.funcColor = FillColorGreenToRed;
  • CreateGraph3D(funcSum,colorSum,&fs);
  • glEndList();
  • }
  • //------------------------------------------------------------
  • LRESULT CALLBACK WindowProc(HWND hwnd,UINT iMsg,WPARAM wParam,LPARAM lParam)
  • {
  • static HDC DC;
  • static HGLRC RC;
  • static int cxClient,cyClient;
  • static double zoom,theta,phi,_theta,_phi;
  • static BOOL isMouseDown;
  • static int xMouseStart,yMouseStart;
  • // traitement des messages
  • switch (iMsg)
  • {
  • case WM_CREATE:
  • {
  • DC = GetDC(hwnd);
  • InitPixelFormat(DC);
  • RC = wglCreateContext(DC);
  • wglMakeCurrent(DC,RC);
  • glEnable(GL_DEPTH_TEST);
  • glClearColor(0,0,0,0);
  • zoom = 50.;
  • theta = 0.;
  • phi = 0.;
  • CreateNewList();
  • break;
  • }
  • case WM_SIZE:
  • {
  • cxClient = LOWORD(lParam); cxClient = (cxClient ? cxClient : 1);
  • cyClient = HIWORD(lParam); cyClient = (cyClient ? cyClient : 1);
  • glViewport(0,0,cxClient,cyClient);
  • glMatrixMode(GL_PROJECTION);
  • glLoadIdentity();
  • gluPerspective(45.,(float)(cxClient)/(float)(cyClient),0.1,1000);
  • break;
  • }
  • case WM_CHAR:
  • {
  • switch((char)wParam)
  • {
  • case 'a':
  • {
  • zoom -= 1.;
  • if(zoom < MY_MIN_ZOOM) zoom = MY_MIN_ZOOM;
  • return 0;
  • }
  • case 'q':
  • {
  • zoom += 1.;
  • if(zoom > MY_MAX_ZOOM) zoom = MY_MAX_ZOOM;
  • return 0;
  • }
  • }
  • break;
  • }
  • case WM_LBUTTONDOWN:
  • {
  • xMouseStart = LOWORD(lParam);
  • yMouseStart = HIWORD(lParam);
  • // on sauvegarde les angles
  • _theta = theta;
  • _phi = phi;
  • isMouseDown = TRUE;
  • SetCapture(hwnd);
  • return 0;
  • }
  • case WM_LBUTTONUP:
  • {
  • if(isMouseDown)
  • {
  • ReleaseCapture();
  • isMouseDown = FALSE;
  • }
  • return 0;
  • }
  • case WM_MOUSEMOVE:
  • {
  • if(isMouseDown)
  • {
  • int x,y;
  • x = (int) (__int16) LOWORD(lParam);
  • y = (int) (__int16) HIWORD(lParam);
  • // attention, comme les coordonnees en Y
  • // client sont inversees (de haut en bas)
  • // il faut faire -, et non +
  • // comme pout le X
  • theta = _theta + ((xMouseStart - x)*2*PI)/(double)cxClient;
  • phi = _phi - ((yMouseStart - y)*2*PI)/(double)cyClient;
  • }
  • return 0;
  • }
  • case WM_PAINT:
  • {
  • RePaint(DC,zoom,theta,phi);
  • return 0;
  • }
  • case WM_DESTROY:
  • {
  • glDeleteLists(MY_CUBE_LINE,1);
  • wglMakeCurrent(NULL, NULL);
  • wglDeleteContext(RC);
  • ReleaseDC(hwnd,DC);
  • PostQuitMessage(0);
  • break;
  • }
  • }
  • return DefWindowProc(hwnd,iMsg,wParam,lParam);
  • }
  • //------------------------------------------------------------
  • int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int CmdShow)
  • {
  • WNDCLASS wc;
  • MSG msg;
  • HWND hWnd;
  • wc.style = CS_OWNDC;
  • wc.lpfnWndProc = WindowProc;
  • wc.cbClsExtra = 0;
  • wc.cbWndExtra = 0;
  • wc.hInstance = hInstance;
  • wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  • wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  • wc.hbrBackground = NULL;
  • wc.lpszMenuName = NULL;
  • wc.lpszClassName = "jcdSINUS3D";
  • RegisterClass(&wc);
  • hWnd = CreateWindow("jcdSINUS3D","Franges d'interférences 3D à deux sources sinusoïdales (JCD)",
  • WS_OVERLAPPEDWINDOW | WS_VISIBLE,
  • CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,
  • NULL,NULL,hInstance,NULL
  • );
  • while(GetMessage(&msg,NULL,0,0))
  • {
  • TranslateMessage(&msg);
  • DispatchMessage(&msg);
  • }
  • return 0;
  • }
#include <windows.h>
#include <math.h>
#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glaux.h>

typedef struct tagFUNC_SINUS
	{
	double dx;										// delta x
	double dy;										// delta y
	double dz;										// delta z
	double h;											// amplitude
	double lambda;								// longeur d'onde
	void   (*funcColor)(double);	// fonction de coloriage
	double arg;
	}FUNC_SINUS,*P_FUNC_SINUS;

typedef struct tagFUNC_SUM
	{
	double				dz;									// delta z
	void					(*funcColor)(double); // fonction de coloriage
	P_FUNC_SINUS	a;
	P_FUNC_SINUS	b;
	double				arg;
	}FUNC_SUM,*P_FUNC_SUM;
//------------------------------------------------------------
#define PI							3.1415926535
//------------------------------------------------------------
#define MY_MIN_ZOOM			1
#define MY_MAX_ZOOM			100

#define MY_CUBE_LINE		100
#define MY_SINUS_1			101
#define MY_SINUS_2			102
#define MY_SUM					103
//------------------------------------------------------------
void RePaint(HDC DC,double zoom,double theta,double phi)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);	
glLoadIdentity();


// position de l'oeil
gluLookAt(zoom*cos(theta)*cos(phi),zoom*sin(theta)*cos(phi),zoom*sin(phi),0,0,0,cos(theta-PI)*cos(PI/2.-phi),sin(theta-PI)*cos(PI/2.-phi),sin(PI/2.-phi));

// on trace les lignes du cube
glCallList(MY_CUBE_LINE);
// on trace la premire sinusoide
glCallList(MY_SINUS_1);
// on trace la seconde sinusoide
glCallList(MY_SINUS_2);
// on trace la somme (franges d'interferences)
glCallList(MY_SUM);

glPopMatrix();

SwapBuffers(DC);
}
//------------------------------------------------------------
void InitPixelFormat(HDC hdc)
{	
PIXELFORMATDESCRIPTOR pfd = {sizeof (PIXELFORMATDESCRIPTOR),1,PFD_SUPPORT_OPENGL | PFD_TYPE_RGBA | PFD_DRAW_TO_WINDOW | PFD_DOUBLEBUFFER,16,0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,0,0,0,0,0,0};
SetPixelFormat(hdc,ChoosePixelFormat(hdc,&pfd),&pfd);
}
//------------------------------------------------------------	
// degrades du rouge
void FillColorRedToYellow(double x)
{glColor3d(1.,x,0.);}
void FillColorRedToMagenta(double x)
{glColor3d(1.,0.,x);}
void FillColorRedToWhite(double x)
{glColor3d(1.,x,x);}
// degrades du vert
void FillColorGreenToRed(double x)
{glColor3d(1.-x,x,x);}
void FillColorGreenToWhite(double x)
{glColor3d(x,1.,x);}
void FillColorGreenYellow(double x)
{glColor3d(x,1.,0.);}
void FillColorGreenToCyan(double x)
{glColor3d(0.,1.,x);}
// degrades du bleu
void FillColorBlueToMaganta(double x)
{glColor3d(x,0.,1.);}
void FillColorBlueToWhite(double x)
{glColor3d(x,x,1.);}
void FillColorBlueToCyan(double x)
{glColor3d(0.,x,1.);}
// degrade de gris
void FillColorBlackToWhite(double x)
{glColor3d(x,x,x);}
//------------------------------------------------------------	
// construit un sinusoide 3D de centre (dx,dy,0)
// d'amplitude <h>, et de longueur d'onde <lambda>
double calcR(P_FUNC_SINUS p,double x,double y)
{
return sqrt((x-p->dx)*(x-p->dx)+(y-p->dy)*(y-p->dy));
}

double funcSinus(P_FUNC_SINUS p,double x,double y)
{
// distance
double r;

p->arg = r = calcR(p,x,y);

if(r > 0.)
	{
	return p->dz - p->h*sin(r*2.*PI/p->lambda)/r;
	}
else
	{
	return p->dz - p->h*2.*PI/p->lambda;
	}
}
void colorSinus(P_FUNC_SINUS p,double z)
{
p->funcColor(0.5+(z-p->dz)/(2.*p->h));
//p->funcColor(1.-1./(1.+p->arg));
}
//------------------------------------------------------------	
// construit l'interference de deux sinusoides
// Ici calculs complexes ...
double funcSum(P_FUNC_SUM p,double x,double y)
{
double rA,rB;
double reA,imA;
double reB,imB;
double k;

k		= 2.*PI/p->a->lambda;
rA	= calcR(p->a,x,y);
rB	= calcR(p->b,x,y);

if(rA <= 0. || rB <= 0.)
	{
	p->arg = 0.;
	return 0.;
	}

reA = cos(k*rA)/rA;
reB = cos(k*rB)/rB;
imA = sin(k*rA)/rA;
imB = sin(k*rB)/rB;

// l'argument
p->arg = atan2(imA + imB,reA + reB);
// le module
return p->dz+4*log10((reA + reB)*(reA + reB)+(imA + imB)*(imA + imB));
}
void colorSum(P_FUNC_SUM p,double z)
{
//p->funcColor(0.5+(p->arg/(2.*PI)));
p->funcColor(0.6-(7+z-p->dz)/(9.));
}

//------------------------------------------------------------	
void CreateGraph3D(double (*calcFunc)(void*,double,double),void (*funcColor)(void*,double),void *param)
{
double x,y;
double step;

step = 0.2;

for(y=-10.+step;y<=+10.;y+=step)
	{
	glBegin(GL_QUAD_STRIP);
	for(x=-10.;x<=+10.;x+=step)
		{
		double z;

		// on doit garantir qu'il faut faire le calcul
		// AVANT le coloriage
		z	= calcFunc(param,x,y - step);
		funcColor(param,z);
		glVertex3d(x,y - step,z);

		z	= calcFunc(param,x,y);
		funcColor(param,z);
		glVertex3d(x,y,calcFunc(param,x,y));
		}
	glEnd();
	}

}
//------------------------------------------------------------	
void CreateNewList(void)
{
FUNC_SINUS	f1,f2;
FUNC_SUM		fs;

glNewList(MY_CUBE_LINE,GL_COMPILE);
	glColor3d(0.,1.,0.);


	glBegin(GL_LINE_LOOP);
		glVertex3d(-10.,-10.,-10.);
		glVertex3d(-10.,-10.,+10.);
		glVertex3d(-10.,+10.,+10.);
		glVertex3d(-10.,+10.,-10.);
	glEnd();

	glBegin(GL_LINE_LOOP);
		glVertex3d(+10.,-10.,-10.);
		glVertex3d(+10.,-10.,+10.);
		glVertex3d(+10.,+10.,+10.);
		glVertex3d(+10.,+10.,-10.);
	glEnd();

	glBegin(GL_LINES);
		glVertex3d(+10.,-10.,-10.);
		glVertex3d(-10.,-10.,-10.);
		glVertex3d(+10.,-10.,+10.);
		glVertex3d(-10.,-10.,+10.);
		glVertex3d(+10.,+10.,+10.);
		glVertex3d(-10.,+10.,+10.);
		glVertex3d(+10.,+10.,-10.);
		glVertex3d(-10.,+10.,-10.);
	glEnd();

glEndList();

glNewList(MY_SINUS_1,GL_COMPILE);
	
	f1.dx					= -0.;
	f1.dy					= -5.5;
	f1.dz					= -10.;
	f1.h					= 5.;
	f1.lambda			= 1.5;
	f1.funcColor	= FillColorRedToYellow;

	CreateGraph3D(funcSinus,colorSinus,&f1);

glEndList();

glNewList(MY_SINUS_2,GL_COMPILE);

	f2.dx					= +0.;
	f2.dy					= +5.5;
	f2.dz					= -10.;
	f2.h					= 5.;
	f2.lambda			= 1.5;
	f2.funcColor	= FillColorBlueToCyan;

	CreateGraph3D(funcSinus,colorSinus,&f2);

glEndList();

glNewList(MY_SUM,GL_COMPILE);
	
	fs.dz					= 12.5;
	fs.a					= &f1;
	fs.b					= &f2;
	fs.funcColor	=	FillColorGreenToRed;

	CreateGraph3D(funcSum,colorSum,&fs);

glEndList();

}
//------------------------------------------------------------	
LRESULT CALLBACK WindowProc(HWND hwnd,UINT iMsg,WPARAM wParam,LPARAM lParam)
{
static HDC						DC;
static HGLRC					RC;
static int						cxClient,cyClient;
static double					zoom,theta,phi,_theta,_phi;
static BOOL						isMouseDown;
static int						xMouseStart,yMouseStart;

// traitement des messages
switch (iMsg)
	{
	case WM_CREATE:
		{
		DC	=	GetDC(hwnd);
		InitPixelFormat(DC);
		RC	= wglCreateContext(DC);
		wglMakeCurrent(DC,RC);
		glEnable(GL_DEPTH_TEST); 
		glClearColor(0,0,0,0); 

		zoom	= 50.;
		theta = 0.;
		phi		= 0.;

		CreateNewList();
		break;
		}
  case WM_SIZE:
		{
		cxClient = LOWORD(lParam);	cxClient = (cxClient ? cxClient : 1);
		cyClient = HIWORD(lParam);	cyClient = (cyClient ? cyClient : 1);
    glViewport(0,0,cxClient,cyClient);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(45.,(float)(cxClient)/(float)(cyClient),0.1,1000);
   	break;
		}
	case WM_CHAR:
		{
		switch((char)wParam)
			{
			case 'a':
				{
				zoom -= 1.;
				if(zoom < MY_MIN_ZOOM)	zoom = MY_MIN_ZOOM;
				return 0;
				}
			case 'q':
				{
				zoom += 1.;
				if(zoom > MY_MAX_ZOOM)	zoom = MY_MAX_ZOOM;
				return 0;
				}
			}
		break;
		}
	case WM_LBUTTONDOWN:
		{
		xMouseStart = LOWORD(lParam);
		yMouseStart = HIWORD(lParam);
		// on sauvegarde les angles
		_theta	= theta;
		_phi		= phi;
		isMouseDown = TRUE;
		SetCapture(hwnd);
		return 0;
		}
	case WM_LBUTTONUP:
		{
		if(isMouseDown)
			{
			ReleaseCapture();
			isMouseDown = FALSE;
			}
		return 0;
		}
	case WM_MOUSEMOVE:
		{
		if(isMouseDown)
			{
			int x,y;
			x = (int) (__int16) LOWORD(lParam);
			y = (int) (__int16) HIWORD(lParam);

			// attention, comme les coordonnees en Y
			// client sont inversees (de haut en bas)
			// il faut faire -, et non +
			// comme pout le X
			theta = _theta + ((xMouseStart - x)*2*PI)/(double)cxClient;
			phi		= _phi	 - ((yMouseStart - y)*2*PI)/(double)cyClient;
			}
		return 0;
		}
  case WM_PAINT:
		{
		RePaint(DC,zoom,theta,phi);
		return 0;
		}
	case WM_DESTROY:
		{
		glDeleteLists(MY_CUBE_LINE,1);

    wglMakeCurrent(NULL, NULL);
    wglDeleteContext(RC);
    ReleaseDC(hwnd,DC);
		PostQuitMessage(0);
		break;
		}
	}
return DefWindowProc(hwnd,iMsg,wParam,lParam);
}	
//------------------------------------------------------------
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int CmdShow)
{
WNDCLASS	wc;
MSG				msg;
HWND			hWnd;

wc.style					= CS_OWNDC;
wc.lpfnWndProc		= WindowProc;
wc.cbClsExtra			= 0;
wc.cbWndExtra			= 0;
wc.hInstance			= hInstance;
wc.hIcon					= LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor				= LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground	= NULL;
wc.lpszMenuName		= NULL;
wc.lpszClassName	= "jcdSINUS3D";

RegisterClass(&wc);

hWnd = CreateWindow("jcdSINUS3D","Franges d'interférences 3D à deux sources sinusoïdales (JCD)",
										WS_OVERLAPPEDWINDOW | WS_VISIBLE,
										CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,
										NULL,NULL,hInstance,NULL
										);
	
while(GetMessage(&msg,NULL,0,0))
	{
	TranslateMessage(&msg);
	DispatchMessage(&msg);
	}
	
return 0;
}


 Fichier Zip

Les Membres Club peuvent télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !
  • interference2.exeTélécharger ce fichier [Réservé aux membres club]93 184 octets
  • interferences.exeTélécharger ce fichier [Réservé aux membres club]93 184 octets
  • main.cTélécharger ce fichier [Réservé aux membres club]Voir ce fichier9 557 octets
  • onde.exeTélécharger ce fichier [Réservé aux membres club]83 456 octets
  • OPEN_GL.DSPTélécharger ce fichier [Réservé aux membres club]Voir ce fichier3 625 octets
  • OPEN_GL.dswTélécharger ce fichier [Réservé aux membres club]Voir ce fichier537 octets
  •   save
    • interference2.exeTélécharger ce fichier [Réservé aux membres club]93 184 octets
    • interferences.exeTélécharger ce fichier [Réservé aux membres club]93 184 octets
    • onde.exeTélécharger ce fichier [Réservé aux membres club]83 456 octets

Télécharger le zip


 Sources du même auteur

Source avec Zip Source avec une capture COLORATION SYNTAXIQUE
Source avec Zip Source avec une capture ORBITES DES SATELLITES GPS
Source avec Zip Source avec une capture DESSIN D'ARBRES
Source avec Zip Source avec une capture PROGRAMMATION LINEAIRE
Source avec Zip EXTENSION DE CORPS (MATH)

 Sources de la même categorie

Source avec Zip UN EXAMPLE D'APPLICATION EN CUDA DE L'ALGORITHME DE SCAN POU... par oguzaras
Source avec Zip Source avec une capture CHIFFREMENT DE VIGENERE par lajouad
Source avec Zip Source avec une capture ANALYSE SYNTAXIQUE par lajouad
Source avec Zip Source avec une capture STRUCTURE D'UNE MATRICE PAR LES LISTE LINÉAIRE (NON CONTUGUS... par benzarabel
Source avec Zip Source avec une capture DESSINER UNE ARBRE BINAIRE( MODE CONSOLE): par benzarabel

Commentaires et avis

Commentaire de djl le 07/12/2003 15:28:10

en c++ tu pe faire directement
struct tagFUNC_SINUS
{
    double dx;                                      // delta x
    double dy;                                      // delta y
    double dz;                                      // delta z
    double h;                                           // amplitude
    double lambda;                              // longeur d'onde
    void     (*funcColor)(double);  // fonction de coloriage
    double arg;
};

sinon c'est vachement bien fait;)

Commentaire de Saros le 07/12/2003 15:43:41

Dis... Excuse-moi si ça peut sembler impertinent, mais j'aurais plutôt placé cette source niveau 2 ou 3... Mais bon...
10/10
Saros

Commentaire de JCDjcd le 07/12/2003 16:53:34

&gt;&gt; djl

quelle est la difference entre

typedef struct tagFUNC_SINUS ...

et directement ;

struct tagFUNC_SINUS ...


??

Commentaire de djl le 07/12/2003 16:58:21

en C, si tu fait
typedef struct SA
{
...
}A,*PA;
c'est pour eviter d'avoir a faire quand tu declare :
struct SA s;
struct *SA ps;
ainsi t'aura juste a faire ca
A s;
PA ps;

en c++, plus besoin de typedef sur struct

Commentaire de bruniouze le 07/12/2003 22:37:47

Bien joué! J'ai pas encore lu la source en détail mais vraiment je te félicité pour toute ton oeuvre car si tu est réellement en terminale, tu as déja de bonnes bases, tu dois te ballader... Pour moi aussi c'est 10/10

Commentaire de Viper31 le 07/12/2003 23:50:13

Tout simplement Grandiose !!

Gestion Souris / Clavier (+/-)!
Degradé Couleur + un réel effet 3D (dim en profondeur qui decroit !)

Bien Joué 10/10

 Ajouter un commentaire




Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

A découvrir



 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,796 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales