Go to the documentation of this file.00001 #ifndef OPENTISSUE_CORE_GEOMETRY_GEOMETRY_COT_H
00002 #define OPENTISSUE_CORE_GEOMETRY_GEOMETRY_COT_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <cmath>
00013
00014 namespace OpenTissue
00015 {
00016 namespace geometry
00017 {
00018
00061 template<typename vector_type>
00062 typename vector_type::value_type cot(vector_type const & p, vector_type const & pi, vector_type const & pj)
00063 {
00064 using std::sqrt;
00065 using std::fabs;
00066
00067 typedef typename vector_type::value_type real_type;
00068
00069 static const real_type zero = real_type();
00070
00071 vector_type u = pi-p;
00072 vector_type v = pj-p;
00073 real_type dot = u*v;
00074 real_type denom = sqrt( (u*u)*(v*v) - dot*dot );
00075
00076 return (fabs(denom)>zero)? (dot/denom) : zero;
00077 }
00078
00079 }
00080 }
00081
00082
00083 #endif