diff --git a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h index c23d442fa63..a7ccc4e66bb 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h @@ -96,6 +96,13 @@ namespace CartesianKernelFunctors { r.x(), r.y(), r.z(), s.x(), s.y(), s.z()); } + + result_type + operator()(const Point_3& p, const Point_3& q, + const Point_3& r, const Vector_3& n) const + { + return enum_cast(orientation(p,q,r,r+n)); + } }; template diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h b/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h index b3dc18a7bb4..5a213bfd0dc 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h @@ -112,6 +112,12 @@ namespace HomogeneousKernelFunctors { const Point_3& r, const Point_3& s) const { return enum_cast(CGAL_NTS sign(c(q,p) * c(s,r))); } // FIXME: scalar product + + result_type + operator()(const Point_3& p, const Point_3& q, + const Point_3& r, const Vector_3& n) const + { + return enum_cast(orientation(p,q,r,r+n)); }; diff --git a/Kernel_23/doc/Kernel_23/CGAL/Kernel/global_functions.h b/Kernel_23/doc/Kernel_23/CGAL/Kernel/global_functions.h index cb2c3223511..bd5215b1858 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Kernel/global_functions.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Kernel/global_functions.h @@ -37,6 +37,7 @@ const CGAL::Point_2& q, const CGAL::Point_2& r, const CGAL::Point_2& s); + /*! returns `CGAL::OBTUSE`, `CGAL::RIGHT` or `CGAL::ACUTE` depending @@ -61,6 +62,17 @@ Kernel::FT approximate_dihedral_angle(const CGAL::Point_3& p, const CGAL::Point_3& r, const CGAL::Point_3& s); +/*! + +returns `CGAL::OBTUSE`, `CGAL::RIGHT` or `CGAL::ACUTE` depending +on the angle formed by the normal vector of the plane `pqr` and `v`. +*/ +template +Angle angle(const CGAL::Point_3& p, +const CGAL::Point_3& q, +const CGAL::Point_3& r, +const CGAL::Vector_3& v); + /// @} diff --git a/Kernel_23/doc/Kernel_23/Concepts/FunctionObjectConcepts.h b/Kernel_23/doc/Kernel_23/Concepts/FunctionObjectConcepts.h index 1dc0d82158d..848d3eb6a2d 100644 --- a/Kernel_23/doc/Kernel_23/Concepts/FunctionObjectConcepts.h +++ b/Kernel_23/doc/Kernel_23/Concepts/FunctionObjectConcepts.h @@ -85,7 +85,16 @@ public: Angle operator()(const Kernel::Point_3&p, const Kernel::Point_3&q, const Kernel::Point_3&r, - const Kernel::Point_3&s); + const Kernel::Point_3&s); + + /*! + returns \ref CGAL::OBTUSE, \ref CGAL::RIGHT or \ref CGAL::ACUTE depending + on the angle formed by the twonormal vector of the plane `pqr` and `v`. + */ + Angle operator()(const Kernel::Point_3&p, + const Kernel::Point_3&q, + const Kernel::Point_3&r, + const Kernel::Vector_3&s); /// @} }; /* end Kernel::Angle_3 */ diff --git a/Kernel_23/include/CGAL/Kernel/global_functions_3.h b/Kernel_23/include/CGAL/Kernel/global_functions_3.h index 5a561b9094f..83530bb8c4d 100644 --- a/Kernel_23/include/CGAL/Kernel/global_functions_3.h +++ b/Kernel_23/include/CGAL/Kernel/global_functions_3.h @@ -59,6 +59,15 @@ angle(const Point_3 &p, const Point_3 &q, return internal::angle(p, q, r, s, K()); } +template +inline +Angle +angle(const Point_3 &p, const Point_3 &q, + const Point_3 &r, const Vector_3 &v) +{ + return internal::angle(p, q, r, v, K()); +} + template < class K > inline typename K::FT diff --git a/Kernel_23/include/CGAL/Kernel/global_functions_internal_3.h b/Kernel_23/include/CGAL/Kernel/global_functions_internal_3.h index ee77794fbc4..eb4887b7724 100644 --- a/Kernel_23/include/CGAL/Kernel/global_functions_internal_3.h +++ b/Kernel_23/include/CGAL/Kernel/global_functions_internal_3.h @@ -70,6 +70,18 @@ angle(const typename K::Point_3 &p, return k.angle_3_object()(p, q, r, s); } +template +inline +typename K::Angle +angle(const typename K::Point_3 &p, + const typename K::Point_3 &q, + const typename K::Point_3 &r, + const typename K::Vector_3 &v, + const K &k) +{ + return k.angle_3_object()(p, q, r, v); +} + template < class K > inline typename K::FT diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_angle.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_angle.h index eb11c1e3f2f..17b2bbbf889 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_angle.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_angle.h @@ -33,6 +33,7 @@ _test_angle(const R&) typedef CGAL::Point_3 Point_3; typedef CGAL::Vector_2 Vector_2; + typedef CGAL::Vector_3 Vector_3; Point_2 p(RT(2),RT(1)); Point_2 q(RT(5),RT(4)); @@ -67,6 +68,12 @@ _test_angle(const R&) assert( CGAL::angle( org3 - sz, sz - sy) == CGAL::OBTUSE ); assert( CGAL::angle( org3 - sx, sy - sx) == CGAL::ACUTE ); + Vector_3 vz(RT0, RT0, RT1); + Vector_3 vcoplanar(RT1, RT1, RT0); + Vector_3 vmz(RT0, RT0, -RT1); + assert( CGAL::angle( org3, sx, sy, vz) == CGAL::ACUTE ); + assert( CGAL::angle( org3, sx, sy, vcoplanar) == CGAL::RIGHT ); + assert( CGAL::angle( org3, sx, sy, vmz) == CGAL::OBTUSE ); return true; }