#include <stdlib.h>
#include <stdio.h>
#include <math.h>
Include dependency graph for dumbell.c:
Go to the source code of this file.
Data Structures | |
struct | poly6_t |
Defines | |
#define | POLY(p, x) (p.a + (x)*(p.b + (x)*(p.c + (x)*(p.d + (x)*(p.e + (x)*p.f))))) |
#define | POLY1(p, x) (p.b + (x)*(2.*p.c + (x)*(3.*p.d + (x)*(4.*p.e + (x)*5.*p.f)))) |
#define | POLY2(p, x) (2.*p.c + (x)*(6.*p.d + (x)*(12.*p.e + (x)*20.*p.f))) |
#define | GAUSSTOL 1.e-10 |
Functions | |
void | polycircle (double x1, double y1, double dy1, double ddy1, double x2, double y2, double dy2, double ddy2, poly6_t *poly) |
int | main (int argc, char *argv[]) |
|
|
|
Definition at line 9 of file dumbell.c. Referenced by main(). |
|
|
|
|
|
Definition at line 99 of file dumbell.c. References POLY, and polycircle().
00100 { 00101 int i, n = 200, n1; 00102 double radius = atof(argv[1]); 00103 double height = atof(argv[2]); 00104 double width = atof(argv[3]); 00105 double theta = height/radius, t, x; 00106 double xc1 = radius + width/2. + 0.5, xc2 = -radius - width/2. + 0.5; 00107 poly6_t poly; 00108 00109 for (i = 0; i < n; i++) { 00110 t = (double)i/(double)(n - 1)*(PI - theta); 00111 printf("%g %g\n", xc1 + radius*cos(t), radius*sin(t)); 00112 } 00113 polycircle(xc1 + radius*cos(PI - theta), 00114 radius*sin(PI - theta), 00115 1./tan(theta), 00116 -20./radius, 00117 xc2 + radius*cos(theta), 00118 radius*sin(theta), 00119 -1./tan(theta), 00120 -20./radius, 00121 &poly); 00122 n1 = 50; 00123 for (i = 1; i < n1 - 1; i++) { 00124 x = xc1 + radius*cos(PI - theta) + (double)i/(double)(n1 - 1)* 00125 (xc2 - xc1 + 2.*radius*cos(theta)); 00126 printf("%g %g\n", x, POLY(poly, x)); 00127 } 00128 for (i = 0; i < n; i++) { 00129 t = theta + (double)i/(double)(n - 1)*(PI - theta); 00130 printf("%g %g\n", xc2 + radius*cos(t), radius*sin(t)); 00131 } 00132 return 0; 00133 } |
|
Definition at line 60 of file dumbell.c. References poly6_t::a, poly6_t::b, poly6_t::c, poly6_t::d, poly6_t::e, and poly6_t::f. Referenced by main().
00063 { 00064 double A[6][6], B[6], C[6]; 00065 B[0] = y1; 00066 A[0][0] = 1.0; A[0][1] = x1; A[0][2] = x1*x1; A[0][3] = x1*x1*x1; 00067 A[0][4] = x1*x1*x1*x1; A[0][5] = x1*x1*x1*x1*x1; 00068 00069 B[1] = dy1; 00070 A[1][0] = 0.0; A[1][1] = 1.0; A[1][2] = 2.*x1; A[1][3] = 3.*x1*x1; 00071 A[1][4] = 4.*x1*x1*x1; A[1][5] = 5.*x1*x1*x1*x1; 00072 00073 B[2] = ddy1; 00074 A[2][0] = 0.0; A[2][1] = 0.0; A[2][2] = 2.; A[2][3] = 6.*x1; 00075 A[2][4] = 12.*x1*x1; A[2][5] = 20.*x1*x1*x1; 00076 00077 B[3] = y2; 00078 A[3][0] = 1.0; A[3][1] = x2; A[3][2] = x2*x2; A[3][3] = x2*x2*x2; 00079 A[3][4] = x2*x2*x2*x2; A[3][5] = x2*x2*x2*x2*x2; 00080 00081 B[4] = dy2; 00082 A[4][0] = 0.0; A[4][1] = 1.0; A[4][2] = 2.*x2; A[4][3] = 3.*x2*x2; 00083 A[4][4] = 4.*x2*x2*x2; A[4][5] = 5.*x2*x2*x2*x2; 00084 00085 B[5] = ddy2; 00086 A[5][0] = 0.0; A[5][1] = 0.0; A[5][2] = 2.; A[5][3] = 6.*x2; 00087 A[5][4] = 12.*x2*x2; A[5][5] = 20.*x2*x2*x2; 00088 00089 if (gauss(A, B, C)) { 00090 fprintf(stderr, "gauss: no solution\n"); 00091 exit(1); 00092 } 00093 poly->a = C[0]; poly->b = C[1]; poly->c = C[2]; poly->d = C[3]; 00094 poly->e = C[4]; poly->f = C[5]; 00095 } |