Go to the documentation of this file.00001 #ifndef OPENTISSUE_COLLISION_GJK_GJK_SIGNED_DISTANCE_TO_VERTEX_EDGE_VORONOI_PLANE_H
00002 #define OPENTISSUE_COLLISION_GJK_GJK_SIGNED_DISTANCE_TO_VERTEX_EDGE_VORONOI_PLANE_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <OpenTissue/core/math/math_is_number.h>
00013
00014 #include <cmath>
00015 #include <cassert>
00016
00017 namespace OpenTissue
00018 {
00019 namespace gjk
00020 {
00021 namespace detail
00022 {
00023
00036 template< typename V >
00037 inline typename V::value_type signed_distance_to_vertex_edge_voronoi_plane(
00038 V const & p
00039 , V const & A
00040 , V const & B
00041 )
00042 {
00043 typedef typename V::value_traits value_traits;
00044 typedef typename V::value_type T;
00045
00046 V m = (A-B);
00047
00048 assert( dot( m, m ) > value_traits::zero() || !"signed_distance_to_vertex_edge_voronoi_plane(): Degenerate edge encountered");
00049
00050 V n = unit( m );
00051
00052 T sign_p = dot( n, (p-A) );
00053
00054 assert( is_number( sign_p ) || !"signed_distance_to_vertex_edge_voronoi_plane(): Not a Number encountered");
00055
00056 return sign_p;
00057 }
00058
00059 }
00060 }
00061 }
00062
00063
00064 #endif