# 三阶贝塞尔曲线拟合1/2正弦

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

double bezier3(double a, double b, double c, double d, double t)
{
double nt = 1.0 - t;
double nt2 = nt * nt;
double nt3 = nt * nt * nt;
double t2 = t * t;
double t3 = t * t * t;

return (a * nt3 + b * 3.0 * nt2 * t + c * 3.0 * nt * t2 + d * t3);
}

#define PI 3.1415926
int main()
{
double t, a;
double d, e;
double max_e = 0.0, min_e = 1.0;

double x, y;
double h = PI - 2.0;
for(t = 0.0; t < 1.01; t+=0.01)
{
x = bezier3(-PI / 2.0, -PI / 2.0 + h, PI / 2.0 - h, PI / 2.0, t);
y = bezier3(-1, -1, 1, 1, t);
d = sin(x);
e = y - d;

a = x * 180.0 / 3.1415926;

if(max_e < e) max_e = e;
if(min_e > e) min_e = e;
printf("%4.1f, %f\n", a, e);
}
printf("max_e = %f, min_e = %f\n", max_e, min_e);
return 0;
}

-90.0, -0.000000
-88.0, 0.000012
-86.1, 0.000046
-84.2, 0.000095
-82.2, 0.000155
-80.3, 0.000222
-78.4, 0.000293
-76.5, 0.000364
-74.6, 0.000433
-72.7, 0.000498
-70.8, 0.000559
-69.0, 0.000612
-67.1, 0.000659
-65.2, 0.000697
-63.4, 0.000727
-61.6, 0.000749
-59.7, 0.000762
-57.9, 0.000768
-56.1, 0.000766
-54.3, 0.000756
-52.4, 0.000741
-50.6, 0.000719
-48.8, 0.000692
-47.0, 0.000660
-45.3, 0.000625
-43.5, 0.000587
-41.7, 0.000547
-39.9, 0.000505
-38.2, 0.000462
-36.4, 0.000419
-34.6, 0.000376
-32.9, 0.000335
-31.1, 0.000294
-29.4, 0.000256
-27.6, 0.000220
-25.9, 0.000186
-24.2, 0.000155
-22.4, 0.000127
-20.7, 0.000102
-19.0, 0.000080
-17.2, 0.000061
-15.5, 0.000045
-13.8, 0.000032
-12.0, 0.000022
-10.3, 0.000014
-8.6, 0.000008
-6.9, 0.000004
-5.2, 0.000002
-3.4, 0.000001
-1.7, 0.000000
0.0, 0.000000
1.7, -0.000000
3.4, -0.000001
5.2, -0.000002
6.9, -0.000004
8.6, -0.000008
10.3, -0.000014
12.0, -0.000022
13.8, -0.000032
15.5, -0.000045
17.2, -0.000061
19.0, -0.000080
20.7, -0.000102
22.4, -0.000127
24.2, -0.000155
25.9, -0.000186
27.6, -0.000220
29.4, -0.000256
31.1, -0.000294
32.9, -0.000335
34.6, -0.000376
36.4, -0.000419
38.2, -0.000462
39.9, -0.000505
41.7, -0.000547
43.5, -0.000587
45.3, -0.000625
47.0, -0.000660
48.8, -0.000692
50.6, -0.000719
52.4, -0.000741
54.3, -0.000756
56.1, -0.000766
57.9, -0.000768
59.7, -0.000762
61.6, -0.000749
63.4, -0.000727
65.2, -0.000697
67.1, -0.000659
69.0, -0.000612
70.8, -0.000559
72.7, -0.000498
74.6, -0.000433
76.5, -0.000364
78.4, -0.000293
80.3, -0.000222
82.2, -0.000155
84.2, -0.000095
86.1, -0.000046
88.0, -0.000012
90.0, 0.000000
max_e = 0.000768, min_e = -0.000768

• 本文已收录于以下专栏：

举报原因： 您举报文章：三阶贝塞尔曲线拟合1/2正弦 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)