Go to the documentation of this file.00001 #ifndef OPENTISSUE_DYNAMICS_EDM_MODELS_EDM_ELLIPSOID_SOLID_H
00002 #define OPENTISSUE_DYNAMICS_EDM_MODELS_EDM_ELLIPSOID_SOLID_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <OpenTissue/dynamics/edm/edm_solid.h>
00013
00014 #include <OpenTissue/core/math/math_constants.h>
00015
00016 #include <cmath>
00017
00018
00019 namespace OpenTissue
00020 {
00021
00022 namespace edm
00023 {
00024
00025 template<typename edm_types>
00026 class EllipsoidSolid
00027 : public Solid<edm_types>
00028 {
00029 public:
00030
00031 typedef Solid<edm_types> base_type;
00032 typedef typename edm_types::value_traits value_traits;
00033 typedef typename edm_types::real_type real_type;
00034 typedef typename edm_types::vector3_type vector3_type;
00035
00036 public:
00037
00038 EllipsoidSolid()
00039 : base_type()
00040 {
00041 base_type::set(NUM_NODES);
00042 }
00043
00044 virtual ~EllipsoidSolid() {}
00045
00046 private:
00047
00048 vector3_type position(vector3_type const * a, real_type const & u, real_type const & v, real_type const & w) const
00049 {
00050 real_type const u_ = u-(u/this->m_M);
00051
00052 real_type const v_ = v==0?0.001:v>=1.?0.999:v;
00053 real_type const theta = value_traits::two()*math::detail::pi<real_type>()*(value_traits::one()-u_);
00054 real_type const phi = math::detail::pi<real_type>()*v_;
00055 vector3_type local = p(a[0][0], a[0][1], a[0][2], theta, phi, value_traits::one()-w);
00056 return vector3_type(local+a[1]);
00057 }
00058
00059 vector3_type normal(size_t l, size_t m, size_t n) const
00060 {
00061 if (n>0)
00062 return vector3_type();
00063
00064
00065
00066
00067 long lm = m;
00068 long ln = n;
00069 long ll = l;
00070
00071 vector3_type const u = this->r(ll+1,lm,ln) - this->r(ll-1,lm,ln);
00072 vector3_type const v = this->r(ll,lm+1,ln) - this->r(ll,lm-1,ln);
00073 vector3_type const normal_ = u%v;
00074 return vector3_type(unit(normal_));
00075 }
00076
00077 private:
00078
00079 vector3_type p(real_type const & a, real_type const & b, real_type const & c, real_type const & theta, real_type const & phi, real_type const & rho) const
00080 {
00081 using std::cos;
00082 using std::sin;
00083 real_type const x = a*rho*cos(theta)*sin(phi);
00084 real_type const y = b*rho*sin(theta)*sin(phi);
00085 real_type const z = c*rho*cos(phi);
00086 return vector3_type(x,y,z);
00087 }
00088
00089 private:
00090
00091 enum {NUM_NODES = 2};
00092
00093 };
00094
00095 }
00096
00097 }
00098
00099
00100 #endif