Páginas

domingo, 27 de noviembre de 2011

GENERACION DE LA CIRCUNFERENCIA USANDO EL TEOREMA DE PITAGORAS

//---------------------------------------------------------------------------

#include
#pragma hdrstop
#include
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
void __fastcall TForm1::FormMouseDown(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y)
{
xc = X;
yc = Y;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
void __fastcall TForm1::FormMouseUp(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y)
{
x1=X;
y1=Y;
this->Repaint();
Canvas->Refresh();
radio=x1-xc;
r=radio;
for (double i=x1;i>=xc-radio;i--,r--)
{
y2=sqrt((radio*radio)-(r*r));
f=fmod(y2,1.0);
if(f>=.50)
y2++;
Canvas->Pixels[(int)i][(int)yc+(int)y2]=clBlue;
Sleep(50);
}
r=radio;
for (double i=xc-radio;i<=x1;i++,r--)
{
y2=sqrt((radio*radio)-(r*r));
f=fmod(y2,1.0);
if(f>=.50)
y2++;
Canvas->Pixels[(int)i][(int)yc-(int)y2]=clBlue;
Sleep(50);
}
}

No hay comentarios:

Publicar un comentario