#include #include typedef double R; #define lc 1000 R pi = 3.14159265358979323846; typedef struct{R x; R y; R z;} v; R sq(R x){return x*x;} v sp(R s, v vv){return (v){s*vv.x, s*vv.y, s*vv.z};} void pv(v x){printf("%9.3f %9.3f %9.3f\n", x.x, x.y, x.z);} // ... R det(v x, v y, v z){return x.x * (y.y * z.z - y.z * z.y) + x.y * (y.z * z.x - y.x * z.z) + x.z * (y.x * z.y - y.y * z.x);} v vd(v * a, v * b){return (v){a->x - b->x, a->y - b->y, a->z - b->z};} v va(v a, v b){return (v){a.x + b.x, a.y + b.y, a.z + b.z};} void dcir(v * ans, v c, v r1, v r2){ R da = 2.*pi/lc; {int k=lc; while(k--) { ans[k] = va(c, va(sp(cos(da*k), r1), sp(sin(da*k), r2)));}} ans[lc] = ans[0];} v l1[lc+1], l2[lc+1]; // places on the respective curves. int main(){ dcir(l1, (v){0, 0, 0}, (v){1, 0, 0}, (v){0, 1, 0}); dcir(l2, (v){1, 0, 0}, (v){1, 0, 0}, (v){0, 0, 1}); // printf("det=%e\n", det((v){0,2,0}, (v){0,0,1}, (v){1,0,0})); {R s = 0, rm = 1000.; {int j=lc; while(j--) {int k=lc; while(k--) { v r = 0?vd(l1+j, l2+k): sp(0.5, va(vd(l1+j, l2+k), vd(l1+j+1, l2+k+1))); R v2 = sq(r.x) + sq(r.y)+ sq(r.z); s += det(vd(l1+j+1, l1+j), vd(l2+k+1, l2+k), r)/(sqrt(v2)*v2); // printf("(%d %d) %e\n", j, k, det(vd(l1+j+1, l1+j), vd(l2+k+1, l2+k), r)); // ...... // if(!j&&k==1) {pv(vd(l1+j+1, l1+j)); pv(vd(l2+k+1, l2+k)); pv(r);} if(v2