00001 #include <SyFi.h>
00002
00003 using namespace GiNaC;
00004
00005 int main() {
00006
00007 symbol x0("x0"), x1("x1"), y0("y0"), y1("y1"), z0("z0"), z1("z1");
00008
00009 ex p0 = lst(x0,y0,z0);
00010 ex p1 = lst(x1,y1,z1);
00011
00012 Line line(p0,p1);
00013
00014 symbol t("t");
00015 ex l_repr = line.repr(t);
00016 cout <<"l.repr "<<l_repr<<endl;
00017 EQUAL_OR_DIE(l_repr, "{x==t*(x1-x0)+x0,y==y0+(-y0+y1)*t,z==z0+(z1-z0)*t,{t,0,1}}");
00018
00019 for (int i=0; i< l_repr.nops(); i++) {
00020 cout <<"l_repr.op(" <<i<<"): "<<l_repr.op(i)<<endl;
00021 }
00022
00023 ex f = x*x + y*y*y + z;
00024 ex intf = line.integrate(f);
00025 cout <<"intf "<<intf<<endl;
00026 EQUAL_OR_DIE(intf, "1/4*sqrt(y0^2+z0^2+x1^2-2*x1*x0+y1^2-2*z1*z0-2 *y0*y1+z1^2+x0^2)*y0^3+1/3*sqrt(y0^2+z0^2+x1^2-2*x1*x0+y1^2-2*z1*z0-2*y0*y1+z1^2 +x0^2)*x1^2+1/4*sqrt(y0^2+z0^2+x1^2-2*x1*x0+y1^2-2*z1*z0-2*y0*y1+z1^2+x0^2)*y0*y 1^2+1/2*sqrt(y0^2+z0^2+x1^2-2*x1*x0+y1^2-2*z1*z0-2*y0*y1+z1^2+x0^2)*z0+1/4*sqrt( y0^2+z0^2+x1^2-2*x1*x0+y1^2-2*z1*z0-2*y0*y1+z1^2+x0^2)*y1^3+1/4*sqrt(y0^2+z0^2+x 1^2-2*x1*x0+y1^2-2*z1*z0-2*y0*y1+z1^2+x0^2)*y0^2*y1+1/3*sqrt(y0^2+z0^2+x1^2-2*x1 *x0+y1^2-2*z1*z0-2*y0*y1+z1^2+x0^2)*x1*x0+1/3*sqrt(y0^2+z0^2+x1^2-2*x1*x0+y1^2-2 *z1*z0-2*y0*y1+z1^2+x0^2)*x0^2+1/2*sqrt(y0^2+z0^2+x1^2-2*x1*x0+y1^2-2*z1*z0-2*y0 *y1+z1^2+x0^2)*z1");
00027
00028
00029 return 0;
00030 }
00031