Geodesic4D.hpp

00001 
00002 //
00003 // $Id: Geodesic4D.hpp,v 1.2 2004/05/06 22:42:16 werner Exp $
00004 //
00005 // $Log: Geodesic4D.hpp,v $
00006 // Revision 1.2  2004/05/06 22:42:16  werner
00007 // Towards a specification of a spacetime via the Acceleration structure.
00008 //
00009 // Revision 1.1  2004/05/05 15:56:52  werner
00010 // Separation of DOP core routines with dynamic size into the ODE library.
00011 //
00012 // Revision 1.2  2004/05/03 13:33:33  werner
00013 // integration improved
00014 //
00015 // Revision 1.1  2004/04/28 14:06:37  werner
00016 // Integrators may be safely derived from the dop853 template now.
00017 // The template definition does not include the member functions, these
00018 // need to be included explicitely when instantiating the dop853 integrator.
00019 //
00020 //
00022 #ifndef __GEODESIC4D_HPP
00023 #define __GEODESIC4D_HPP "Created 27.03.2004 13:48:45 by werner benger"
00024 
00025 #include "Geodesic.hpp"
00026 #include "Integrate4D.hpp"
00027 
00028 namespace Traum
00029 {
00030 using namespace VecAl;
00031 
00032 template <class Acceleration>
00033 class   Geodesic4D : public IntegratePath4D
00034 {
00035 public: typedef IntegratePath4D::real real;
00036 
00037         typedef typename Acceleration::Scalar_t Scalar_t;
00038         typedef typename Acceleration::Point_t  Point_t;
00039         typedef typename Acceleration::Vector_t Vector_t;
00040         enum { dim = Acceleration::Dims };
00041 
00042         const Acceleration&myAcceleration;
00043 
00044         Geodesic4D(const Acceleration&A)
00045         : myAcceleration(A)
00046         {}
00047 
00048         void restart(const real&s, const Point_t&x0, const Vector_t&v0)
00049         {
00050                 init(s, x0.const_ptr(), v0.const_ptr() );
00051         }
00052 
00053         void Accel(real, const real *x, const real *v, real *d2x_ds2)
00054         {
00055         Point_t  P;
00056         Vector_t V;
00057                 for(int k=0; k<dim; k++)
00058                 {
00059                         P[k] = x[k];
00060                         V[k] = v[k];
00061                 }
00062         const Vector_t&a = myAcceleration(P, V);
00063                 for(int i=0; i<nPaths(); i++)
00064                         d2x_ds2[i] = -a[i];
00065         }
00066 
00067         Point_t  position() const
00068         {
00069         Point_t  retval;
00070                 for(int i=0; i<dim; i++)
00071                         retval[i] = q(i);
00072                 return retval;
00073         }
00074 
00075         Vector_t velocity() const
00076         {
00077         Vector_t retval;
00078                 for(int i=0; i<dim; i++)
00079                         retval[i] = dq(i);
00080                 return retval;
00081         }
00082 
00083         Point_t  position(real s) const
00084         {
00085         Point_t  retval;
00086                 for(int i=0; i<dim; i++)
00087                         retval[i] = q(i, s);
00088                 return retval;
00089         }
00090 
00091         Vector_t velocity(real s) const
00092         {
00093         Vector_t retval;
00094                 for(int i=0; i<dim; i++)
00095                         retval[i] = dq(i, s);
00096                 return retval;
00097         }
00098 };
00099 
00100 
00101 } // namespace 
00102 
00103 #endif // __GEODESIC4D_HPP