Go to the documentation of this file.00001 #ifndef OPENTISSUE_CORE_GEOMETRY_GEOMETRY_ANGLE_FROM_COT_H
00002 #define OPENTISSUE_CORE_GEOMETRY_GEOMETRY_ANGLE_FROM_COT_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <cmath>
00013 #include <cassert>
00014
00015 namespace OpenTissue
00016 {
00017 namespace geometry
00018 {
00019
00032 template<typename vector_type>
00033 typename vector_type::value_type angle_from_cot(vector_type const & p,vector_type const & pi,vector_type const & pj)
00034 {
00035 using std::sqrt;
00036 using std::fabs;
00037 using std::atan2;
00038
00039 typedef typename vector_type::value_type real_type;
00040
00041 vector_type u = pi-p;
00042 vector_type v = pj-p;
00043 real_type dot = u*v;
00044 real_type denom = sqrt( (u*u)*(v*v) - dot*dot );
00045
00046 return fabs(atan2(denom,dot));
00047 }
00048
00049 }
00050 }
00051
00052
00053 #endif