跪求,已知一任意椭圆的圆心坐标和长短轴距离,如何绘制该旋转椭圆? 已知一任意椭圆的圆心坐标和长短轴距离,如何绘制该旋转椭圆?网上找N久了,只有VC代码的,功力不够,一直改不好,大家帮忙啊!!!-----思路是算出13个点坐标,然后用贝塞尔曲线拟合椭圆,帮帮忙啊,有完整代码最好,分不够再开贴加,谢谢啦 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 -------自己顶,找了个以前的帖子-------------const r: Double = 0.2761423749154; Center为椭圆中心、mb为短半轴、ma为长半轴 得到13个点 P[0].x := Center.x; P[0].y := Center.y + mb; P[1].x := Center.x + 2 * ma * r; P[1].y := Center.y + mb; P[2].x := Center.x + ma; P[2].y := Center.y + 2 * mb * r; P[3].x := Center.x + ma; P[3].y := Center.y; P[4].x := Center.x + ma; P[4].y := Center.y - 2 * mb * r; P[5].x := Center.x + 2 * ma * r; P[5].y := Center.y - mb; P[6].x := Center.x; P[6].y := Center.y - mb; P[7].x := Center.x - 2 * ma * r; P[7].y := Center.y - mb; P[8].x := Center.x - ma; P[8].y := Center.y - 2 * mb * r; P[9].x := Center.x - ma; P[9].y := Center.y; P[10].x := Center.x - ma; P[10].y := Center.y + 2 * mb * r; P[11].x := Center.x - 2 * ma * r; P[11].y := Center.y + mb; P[12].x := Center.x; P[12].y := Center.y + mb; 旋转,旋转中心是Center, 旋转角的Cos,Sin值mCosAlpha, mSinAlpha for i := 0 to 12 do begin X := P[i].x - Center.x; Y := P[i].y - Center.y; P[i].x := X * CosAlpha - Y * SinAlpha + Center.x; P[i].y := X * SinAlpha + Y * CosAlpha + Center.y; end; 画Bezier曲线 ThisDxf.DxfCanvas.PolyBezier(P); -----拟合不出来啊,而且PolyBezier()都是integer的类型参数,怎么办??? var points : array [0.. 360] of TPoint; i: Integer; X, Y, A, B: Integer;begin X:= Self.Width div 2; Y:= Self.Height div 2; A:= 100; B:= 40; for i:= 0 to 360 do begin points[i].X:= Round(A * Cos(PI / 180 * i)) + X; points[i].Y:= Round(B * Sin(PI / 180 * i)) + Y; end; Canvas.Polyline(points);end; Canvas.Ellipse(100, 200 ,300 ,250); uses Math;procedure TForm1.Button1Click(Sender: TObject);var points : array [0.. 360] of TPoint; i,j: Integer; X, Y, A, B: Integer; xlen,ylen,len,angle:Extended;begin X:= Self.Width div 2; Y:= Self.Height div 2; A:= 100; B:= 40; j:=0; while j<360 do begin for i:= 0 to 360 do begin xlen:=A * Cos(PI / 180 * i); ylen:=B * Sin(PI / 180 * i); len:=sqrt(xlen*xlen+ylen*ylen); angle:=ArcSin(ylen/len)+ PI / 180 * j; xlen:=len*Cos(angle); ylen:=len*Sin(angle); points[i].X:= Round(xlen) + X; points[i].Y:= Round(ylen) + Y; end; Canvas.Polyline(points); inc(j,45);//旋转递增角度 end;end; 结果是间隔45°角的4个椭圆(X, Y:为中心 A, B为长短轴) 用Delphi2006开发和调试 ActiveX遇到问题…… combobox 的按钮怎样修改呢? ***两台打印机,如果用DELPHI写打印程序,不同按钮调不同打印机打*** 請解決 delphi里有没有字符串匹配函数 小问题 两个unit怎么互相包含? 短信平台软件编写!!! 真诚请教数据库图像问题 在delphi7 中如何使用柯达控件进行图像的双面扫描,和连续扫描? 如何获得 当前有多少个用户读取局域网内的某个共享文件 ? 以及此时的网络流量..具体情况如下: Delphi下获取CPU相关信息
const
r: Double = 0.2761423749154;
Center为椭圆中心、mb为短半轴、ma为长半轴
得到13个点
P[0].x := Center.x;
P[0].y := Center.y + mb;
P[1].x := Center.x + 2 * ma * r;
P[1].y := Center.y + mb;
P[2].x := Center.x + ma;
P[2].y := Center.y + 2 * mb * r;
P[3].x := Center.x + ma;
P[3].y := Center.y;
P[4].x := Center.x + ma;
P[4].y := Center.y - 2 * mb * r;
P[5].x := Center.x + 2 * ma * r;
P[5].y := Center.y - mb;
P[6].x := Center.x;
P[6].y := Center.y - mb;
P[7].x := Center.x - 2 * ma * r;
P[7].y := Center.y - mb;
P[8].x := Center.x - ma;
P[8].y := Center.y - 2 * mb * r;
P[9].x := Center.x - ma;
P[9].y := Center.y;
P[10].x := Center.x - ma;
P[10].y := Center.y + 2 * mb * r;
P[11].x := Center.x - 2 * ma * r;
P[11].y := Center.y + mb;
P[12].x := Center.x;
P[12].y := Center.y + mb;
旋转,旋转中心是Center, 旋转角的Cos,Sin值mCosAlpha, mSinAlpha
for i := 0 to 12 do
begin
X := P[i].x - Center.x;
Y := P[i].y - Center.y;
P[i].x := X * CosAlpha - Y * SinAlpha + Center.x;
P[i].y := X * SinAlpha + Y * CosAlpha + Center.y;
end;
画Bezier曲线
ThisDxf.DxfCanvas.PolyBezier(P);
-----拟合不出来啊,而且PolyBezier()都是integer的类型参数,怎么办???
points : array [0.. 360] of TPoint;
i: Integer;
X, Y, A, B: Integer;
begin
X:= Self.Width div 2;
Y:= Self.Height div 2;
A:= 100;
B:= 40;
for i:= 0 to 360 do begin
points[i].X:= Round(A * Cos(PI / 180 * i)) + X;
points[i].Y:= Round(B * Sin(PI / 180 * i)) + Y;
end;
Canvas.Polyline(points);
end;
uses Math;procedure TForm1.Button1Click(Sender: TObject);
var
points : array [0.. 360] of TPoint;
i,j: Integer;
X, Y, A, B: Integer;
xlen,ylen,len,angle:Extended;
begin
X:= Self.Width div 2;
Y:= Self.Height div 2;
A:= 100;
B:= 40;
j:=0;
while j<360 do
begin
for i:= 0 to 360 do begin
xlen:=A * Cos(PI / 180 * i);
ylen:=B * Sin(PI / 180 * i);
len:=sqrt(xlen*xlen+ylen*ylen);
angle:=ArcSin(ylen/len)+ PI / 180 * j;
xlen:=len*Cos(angle);
ylen:=len*Sin(angle);
points[i].X:= Round(xlen) + X;
points[i].Y:= Round(ylen) + Y;
end;
Canvas.Polyline(points);
inc(j,45);//旋转递增角度
end;
end;