主题:求教大家啦,刚开始玩BCB
elliotann
[专家分:100] 发布于 2007-12-20 21:48:00
void __fastcall TForm1::FormPaint(TObject *Sender)
{
double A,x1,y1,x2,y2;
int D=150,E=50;
double L,M,O,P;
for (int i=0; i<240; i++)
{
A = i*M_PI/120;
L = D+D/3*(1+cos(12*A)/2)*cos(A);
x1 = 240+1.25*L*cos(A);
M = E+E/3*(1+sin(12*A)/2)*cos(A);
x2 = 240+1.25*M*cos(A);
O = D+D/3*(1+cos(10*A)/2)*sin(A);
y1 = 240-O*sin(A);
P = E+E/2*(1+cos(15*A)/2)*sin(A);
y2 = 240-P*sin(A);
Canvas->MoveTo(x1,y1);
Canvas->LineTo(x2,y2);
}
}
为什么这个运行出现错误
回复列表 (共3个回复)
沙发
wjt132 [专家分:50] 发布于 2008-01-03 11:37:00
#include <vcl.h>
#pragma hdrstop
#include <math.h>
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormPaint(TObject *Sender)
{
double A,x1,y1,x2,y2;
int D=150,E=50;
double L,M,O,P;
for (int i=0; i<240; i++)
{
A = i*3.1415/120;
L = D+D/3*(1+cos(12*A)/2)*cos(A);
x1 = 240+1.25*L*cos(A);
M = E+E/3*(1+sin(12*A)/2)*cos(A);
x2 = 240+1.25*M*cos(A);
O = D+D/3*(1+cos(10*A)/2)*sin(A);
y1 = 240-O*sin(A);
P = E+E/2*(1+cos(15*A)/2)*sin(A);
y2 = 240-P*sin(A);
Canvas->MoveTo(x1,y1);
Canvas->LineTo(x2,y2);
}
}
添加了一个数学的头文件,还有,PI必须自己定义,或者去掉,用3.1415 代替
板凳
hehailxy [专家分:0] 发布于 2008-07-28 16:52:00
在Unit1.cpp最上面添加#include<math.h>
#define M_PI 3.1415926
变为下面的样子。
#include <vcl.h>
#pragma hdrstop
#include<math.h>
#include "Unit1.h"
#define M_PI 3.1415926
3 楼
rtgongchengshi [专家分:90] 发布于 2008-08-14 09:16:00
这个问题我以前也接触过,开始的时候我也找不到问题的原因,后来我进了一个技术交流群,这个群里的人挺多的,在里面可以沟通技术,你可以进去看一下.群号是:六#二#八#七#八#零#四#三。另外,这个群里可以接项目。
我来回复