Add angle(Point_3, Point_3,Point_3,Vector_3)

This commit is contained in:
Andreas Fabri 2017-01-05 16:03:06 +01:00 committed by Sébastien Loriot
parent 061a9b1ecd
commit 5f8bc52082
7 changed files with 63 additions and 1 deletions

View File

@ -96,6 +96,13 @@ namespace CartesianKernelFunctors {
r.x(), r.y(), r.z(), r.x(), r.y(), r.z(),
s.x(), s.y(), s.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<Angle>(orientation(p,q,r,r+n));
}
}; };
template <typename K> template <typename K>

View File

@ -112,6 +112,12 @@ namespace HomogeneousKernelFunctors {
const Point_3& r, const Point_3& s) const const Point_3& r, const Point_3& s) const
{ return enum_cast<Angle>(CGAL_NTS sign(c(q,p) * c(s,r))); } { return enum_cast<Angle>(CGAL_NTS sign(c(q,p) * c(s,r))); }
// FIXME: scalar product // 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<Angle>(orientation(p,q,r,r+n));
}; };

View File

@ -37,6 +37,7 @@ const CGAL::Point_2<Kernel>& q,
const CGAL::Point_2<Kernel>& r, const CGAL::Point_2<Kernel>& r,
const CGAL::Point_2<Kernel>& s); const CGAL::Point_2<Kernel>& s);
/*! /*!
returns `CGAL::OBTUSE`, `CGAL::RIGHT` or `CGAL::ACUTE` depending returns `CGAL::OBTUSE`, `CGAL::RIGHT` or `CGAL::ACUTE` depending
@ -61,6 +62,17 @@ Kernel::FT approximate_dihedral_angle(const CGAL::Point_3<Kernel>& p,
const CGAL::Point_3<Kernel>& r, const CGAL::Point_3<Kernel>& r,
const CGAL::Point_3<Kernel>& s); const CGAL::Point_3<Kernel>& 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 <typename Kernel>
Angle angle(const CGAL::Point_3<Kernel>& p,
const CGAL::Point_3<Kernel>& q,
const CGAL::Point_3<Kernel>& r,
const CGAL::Vector_3<Kernel>& v);
/// @} /// @}

View File

@ -86,6 +86,15 @@ public:
const Kernel::Point_3&q, const Kernel::Point_3&q,
const Kernel::Point_3&r, 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 */ }; /* end Kernel::Angle_3 */

View File

@ -59,6 +59,15 @@ angle(const Point_3<K> &p, const Point_3<K> &q,
return internal::angle(p, q, r, s, K()); return internal::angle(p, q, r, s, K());
} }
template <typename K>
inline
Angle
angle(const Point_3<K> &p, const Point_3<K> &q,
const Point_3<K> &r, const Vector_3<K> &v)
{
return internal::angle(p, q, r, v, K());
}
template < class K > template < class K >
inline inline
typename K::FT typename K::FT

View File

@ -70,6 +70,18 @@ angle(const typename K::Point_3 &p,
return k.angle_3_object()(p, q, r, s); return k.angle_3_object()(p, q, r, s);
} }
template <typename K>
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 > template < class K >
inline inline
typename K::FT typename K::FT

View File

@ -33,6 +33,7 @@ _test_angle(const R&)
typedef CGAL::Point_3<R> Point_3; typedef CGAL::Point_3<R> Point_3;
typedef CGAL::Vector_2<R> Vector_2; typedef CGAL::Vector_2<R> Vector_2;
typedef CGAL::Vector_3<R> Vector_3;
Point_2 p(RT(2),RT(1)); Point_2 p(RT(2),RT(1));
Point_2 q(RT(5),RT(4)); 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 - sz, sz - sy) == CGAL::OBTUSE );
assert( CGAL::angle( org3 - sx, sy - sx) == CGAL::ACUTE ); 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; return true;
} }