Salut à tous,
svp, je dois tracez un cercle à l'aide d'une matrix de rotation (dimension 2)
et j'utilise la matrix suivante avec Coordonnés Homogene:
(x') (x) (cos(a) -sin(a) xm * (1 - cos(a)) + ym * sin(a))
(y') = (y) * (sin(a) cos(a) ym * (1 - cos(a)) - xm * sin(a))
(1 ) (1) ( 0 0 1 )
et j'obtiens cet Algoritme :
#include "Drehmatrix.h"
extern FrameGrabber *fg;
extern BYTE *puffer1; // Originalbild
extern BYTE *puffer2; // ziel Bil
// Bildmitte ermitteln MAX_ZEILE ist 576 und MAX_SPALTE ist 768
const int Xm = MAX_SPALTE / 2;
const int Ym = MAX_ZEILE / 2;
void Drehmatrix(HDC hdc,COLORREF farbe)
{
double x_Neu, y_Neu;
double phi;
int pixel;
double radius = 100.5;
int x_puffer1, y_puffer1;
int x, y, i;
//Umrechnung von Grad nach Bogenmass
//phi = PI * phi_in_deg / 180;
pixel=(int)(2.0*(double)radius*PI);
for (y = 0; y < MAX_ZEILE; y++)
{
for (x = 0; x < MAX_SPALTE; x++)
{
i = y * MAX_SPALTE + x;
phi =(double)i/pixel*2*PI;
// Koordinaten aus dem originalen Bild ermitteln
x_Neu =(double) Xm + cos(phi) * (double)(x - Xm) - sin(phi) *(double) (y - Ym);
y_Neu = (double)Ym + sin(phi) * (double)(x - Xm) + cos(phi) * (double)(y - Ym);
// originalen Bild neu Koordinaten
x_puffer1 = (int) (x_Neu);
y_puffer1 = (int) (y_Neu);
SetPixel (hdc, x_puffer1, y_puffer1 ,farbe);
}
}
}
LRESULT CALLBACK DialogProc_Drehmatrix(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
//COLORREF farbe = RGB(255,0,0);
COLORREF farbe;
switch (message)
{
case WM_PAINT:
HDC hdc;
PAINTSTRUCT ps;
farbe = 0x0000FF;
hdc = BeginPaint(hwnd, &ps); //ganze Bild
fg->ZeichneFrame(2,hwnd);//
Drehmatrix(hdc, farbe);
EndPaint(hwnd, &ps);
return 0;
break;
default: // Nachrichten weiterleiten
return DefWindowProc(hwnd, message, wParam, lParam);
}
return 0;
}
mon Problem est que au lieu d'obtenir un cercle j'ai plusieurs cercles.
SVP aidez moi je voudrais bien obtenir un Cercle