Go to the documentation of this file.00001 #ifndef OPENTISSUE_COLLISION_GJK_GJK_OUTSIDE_TRIANGLE_H
00002 #define OPENTISSUE_COLLISION_GJK_GJK_OUTSIDE_TRIANGLE_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 <cassert>
00015
00016 namespace OpenTissue
00017 {
00018 namespace gjk
00019 {
00020
00021 namespace detail
00022 {
00023
00036 template< typename V >
00037 inline bool outside_triangle(
00038 V const & p
00039 , V const & A
00040 , V const & B
00041 , V const & C
00042 , V const & q
00043 )
00044 {
00045 typedef typename V::value_traits value_traits;
00046 typedef typename V::value_type T;
00047
00048 V const n = cross( A-B, C-B );
00049
00050 assert( dot( n, n ) > value_traits::zero() || !"outside_triangle(): Degenerate triangle encountered");
00051
00052 T const sign_p = dot( n, p-B );
00053 T const sign_q = dot( n, q-B );
00054
00055 assert( is_number( sign_p ) || !"outside_triangle(): Not a Number encountered");
00056 assert( is_number( sign_q ) || !"outside_triangle(): Not a Number encountered");
00057
00058 assert( sign_q < value_traits::zero() || sign_q > value_traits::zero() || !"outside_triangle(): q was in plane, can not be used to determine sign");
00059
00060 return (sign_p*sign_q) <= value_traits::zero();
00061 }
00062
00063 }
00064
00065 }
00066
00067 }
00068
00069
00070 #endif