Go to the documentation of this file.00001 #ifndef OPENTISSUE_CORE_GEOMETRY_GEOMETRY_SPHERICAL_GROWTH_H
00002 #define OPENTISSUE_CORE_GEOMETRY_GEOMETRY_SPHERICAL_GROWTH_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <OpenTissue/core/math/math_constants.h>
00013
00014 #include <OpenTissue/core/geometry/geometry_quadric.h>
00015
00016 namespace OpenTissue
00017 {
00018 namespace geometry
00019 {
00020
00021
00040 template<typename real_type, typename vector3_type, typename vector3_iterator>
00041 Quadric<real_type> spherical_growth(
00042 vector3_type const & p
00043 , vector3_type const & n
00044 , vector3_iterator begin
00045 , vector3_iterator end
00046 , real_type & radius
00047 , vector3_type & q
00048 )
00049 {
00050 radius = math::detail::highest<real_type>();
00051 for(vector3_iterator x = begin;x!=end;++x)
00052 {
00053 vector3_type dx = ((*x) - p);
00054 real_type tmp = dx*n;
00055 if( tmp <= 0)
00056 {
00057 real_type tst = - (dx*dx) / (2.0*dx*n);
00058 if(0<tst && tst < radius)
00059 {
00060 radius = tst;
00061 q = (*x);
00062 }
00063 }
00064 }
00065 assert(radius>0 || !"spherical_growth(): radius was non-positive");
00066 assert(radius < math::detail::highest<real_type>() || !"spherical_growth(): radius was infinite" );
00067
00068 vector3_type center = p - n*radius;
00069 return make_sphere_quadric(radius,center);
00070 }
00071
00072 }
00073 }
00074
00075
00076 #endif