明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 4721|回复: 1

用双圆弧来拟合非圆曲线(如椭圆)

[复制链接]
发表于 2007-4-2 23:28 | 显示全部楼层 |阅读模式

用双圆弧来拟合非圆曲线(如椭圆)

对这方面有研究的高手,希望能联系我。85315168@vip.163.com

我们出开发费用,请人帮我们兼职开发这方面的算法函数。

发表于 2007-4-8 17:02 | 显示全部楼层

Here's some java code that should help you out. (modify to suit your
language needs)

If anyone sees any problems with this code, please let me know so I can
fix my stuff :)

float x, y, width, height - these are already set.

float hwidth = width / 2;
float hheight = height / 2;
float ab = (float)(hwidth * (4.0/3.0*(Math.sqrt(2.0)-1.0)));
float cd = (float)(hheight * (4.0/3.0*(Math.sqrt(2.0)-1.0)));

pdf.moveto(x, y + hheight);

// top right
pdf.curveto(x + ab, y + hheight, // B
x + hwidth, y + cd, // C
x + hwidth, y);

// bottom right
pdf.curveto(x + hwidth, y - cd, x + ab, y - hheight, x, y - hheight);

// bottom left
pdf.curveto(x - ab, y - hheight, x - hwidth, y - cd, x - hwidth, y);

// top left
pdf.curveto(x - hwidth, y + cd, x - ab, y + hheight, x, y + hheight);

pdf.moveto(x, y + hheight);

pdf.fill();

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-5 17:27 , Processed in 0.711944 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表