mirror of https://github.com/CGAL/cgal
small features to add additional operator() to Angle_2.
This is a merge from the branch /branches/experimental-packages/More_robust_Triangulation_2-branch
This commit is contained in:
parent
ace9c87934
commit
78a8e36522
|
|
@ -40,13 +40,28 @@ namespace CartesianKernelFunctors {
|
||||||
template <typename K>
|
template <typename K>
|
||||||
class Angle_2
|
class Angle_2
|
||||||
{
|
{
|
||||||
typedef typename K::Point_2 Point_2;
|
typedef typename K::Point_2 Point_2;
|
||||||
|
typedef typename K::Vector_2 Vector_2;
|
||||||
public:
|
public:
|
||||||
typedef typename K::Angle result_type;
|
typedef typename K::Angle result_type;
|
||||||
|
|
||||||
|
result_type
|
||||||
|
operator()(const Vector_2& u, const Vector_2& v) const
|
||||||
|
{ return angleC2(u.x(), u.y(), v.x(), v.y()); }
|
||||||
|
|
||||||
result_type
|
result_type
|
||||||
operator()(const Point_2& p, const Point_2& q, const Point_2& r) const
|
operator()(const Point_2& p, const Point_2& q, const Point_2& r) const
|
||||||
{ return angleC2(p.x(), p.y(), q.x(), q.y(), r.x(), r.y()); }
|
{ return angleC2(p.x(), p.y(), q.x(), q.y(), r.x(), r.y()); }
|
||||||
|
|
||||||
|
result_type
|
||||||
|
operator()(const Point_2& p, const Point_2& q,
|
||||||
|
const Point_2& r, const Point_2& s) const
|
||||||
|
{
|
||||||
|
return angleC2(p.x(), p.y(),
|
||||||
|
q.x(), q.y(),
|
||||||
|
r.x(), r.y(),
|
||||||
|
s.x(), s.y());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename K>
|
template <typename K>
|
||||||
|
|
|
||||||
|
|
@ -420,6 +420,15 @@ orientationC2(const FT &ux, const FT &uy, const FT &vx, const FT &vy)
|
||||||
return sign_of_determinant(ux, uy, vx, vy);
|
return sign_of_determinant(ux, uy, vx, vy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template < class FT >
|
||||||
|
inline
|
||||||
|
typename Same_uncertainty_nt<Angle, FT>::type
|
||||||
|
angleC2(const FT &ux, const FT &uy,
|
||||||
|
const FT &vx, const FT &vy)
|
||||||
|
{
|
||||||
|
return enum_cast<Angle>(CGAL_NTS sign(ux*vx + uy*vy));
|
||||||
|
}
|
||||||
|
|
||||||
template < class FT >
|
template < class FT >
|
||||||
inline
|
inline
|
||||||
typename Same_uncertainty_nt<Angle, FT>::type
|
typename Same_uncertainty_nt<Angle, FT>::type
|
||||||
|
|
@ -430,6 +439,17 @@ angleC2(const FT &px, const FT &py,
|
||||||
return enum_cast<Angle>(CGAL_NTS sign((px-qx)*(rx-qx)+(py-qy)*(ry-qy)));
|
return enum_cast<Angle>(CGAL_NTS sign((px-qx)*(rx-qx)+(py-qy)*(ry-qy)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template < class FT >
|
||||||
|
inline
|
||||||
|
typename Same_uncertainty_nt<Angle, FT>::type
|
||||||
|
angleC2(const FT &px, const FT &py,
|
||||||
|
const FT &qx, const FT &qy,
|
||||||
|
const FT &rx, const FT &ry,
|
||||||
|
const FT &sx, const FT &sy)
|
||||||
|
{
|
||||||
|
return enum_cast<Angle>(CGAL_NTS sign((px-qx)*(rx-sx)+(py-qy)*(ry-sy)));
|
||||||
|
}
|
||||||
|
|
||||||
template < class FT >
|
template < class FT >
|
||||||
CGAL_KERNEL_MEDIUM_INLINE
|
CGAL_KERNEL_MEDIUM_INLINE
|
||||||
typename Equal_to<FT>::result_type
|
typename Equal_to<FT>::result_type
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ namespace HomogeneousKernelFunctors {
|
||||||
class Angle_2
|
class Angle_2
|
||||||
{
|
{
|
||||||
typedef typename K::Point_2 Point_2;
|
typedef typename K::Point_2 Point_2;
|
||||||
|
typedef typename K::Vector_2 Vector_2;
|
||||||
typedef typename K::Construct_vector_2 Construct_vector_2;
|
typedef typename K::Construct_vector_2 Construct_vector_2;
|
||||||
Construct_vector_2 c;
|
Construct_vector_2 c;
|
||||||
public:
|
public:
|
||||||
|
|
@ -66,7 +67,17 @@ namespace HomogeneousKernelFunctors {
|
||||||
|
|
||||||
result_type
|
result_type
|
||||||
operator()(const Point_2& p, const Point_2& q, const Point_2& r) const
|
operator()(const Point_2& p, const Point_2& q, const Point_2& r) const
|
||||||
{ return enum_cast<Angle>(CGAL_NTS sign(c(q,p) * c(q,r))); }
|
{ return operator()(c(q,p), c(q,r)); }
|
||||||
|
|
||||||
|
result_type
|
||||||
|
operator()(const Point_2& p, const Point_2& q,
|
||||||
|
const Point_2& r, const Point_2& s) const
|
||||||
|
{ return operator()(c(q,p), c(s,r)); }
|
||||||
|
|
||||||
|
result_type
|
||||||
|
operator()(const Vector_2& u, const Vector_2& v) const
|
||||||
|
{ return enum_cast<Angle>(CGAL_NTS sign(u * v)); }
|
||||||
|
|
||||||
// FIXME: scalar product
|
// FIXME: scalar product
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,15 +5,25 @@ A model for this must provide:
|
||||||
|
|
||||||
\ccCreationVariable{fo}
|
\ccCreationVariable{fo}
|
||||||
|
|
||||||
|
\ccMemberFunction{Angle operator()(const Kernel::Vector_2&u,
|
||||||
|
const Kernel::Vector_2&v);}
|
||||||
|
{returns \ccStyle{OBTUSE}, \ccStyle{RIGHT} or \ccStyle{ACUTE} depending
|
||||||
|
on the angle formed by the two vectors $u$ and $v$.}
|
||||||
|
|
||||||
\ccMemberFunction{Angle operator()(const Kernel::Point_2&p,
|
\ccMemberFunction{Angle operator()(const Kernel::Point_2&p,
|
||||||
const Kernel::Point_2&q,
|
const Kernel::Point_2&q,
|
||||||
const Kernel::Point_2&r);}
|
const Kernel::Point_2&r);}
|
||||||
{returns \ccStyle{OBTUSE}, \ccStyle{RIGHT} or \ccStyle{ACUTE} depending
|
{returns \ccStyle{OBTUSE}, \ccStyle{RIGHT} or \ccStyle{ACUTE} depending
|
||||||
on the angle formed by the three points $p$, $q$, $r$ ($q$ being the vertex of
|
on the angle formed by the three points $p$, $q$, $r$ ($q$ being the vertex of
|
||||||
the angle).}
|
the angle). The returned value is the same as \ccc{operator()(p - q, r - q)}.}
|
||||||
|
|
||||||
\ccRefines
|
\ccMemberFunction{Angle operator()(const Kernel::Point_2&p,
|
||||||
\ccc{AdaptableFunctor} (with three arguments)
|
const Kernel::Point_2&q,
|
||||||
|
const Kernel::Point_2&r,
|
||||||
|
const Kernel::Point_2&s);}
|
||||||
|
{returns \ccStyle{OBTUSE}, \ccStyle{RIGHT} or \ccStyle{ACUTE} depending
|
||||||
|
on the angle formed by the two vectors $pq$, $rs$. The returned value is
|
||||||
|
the same as \ccc{operator()(q - p, s - r)}.}
|
||||||
|
|
||||||
\ccSeeAlso
|
\ccSeeAlso
|
||||||
\ccRefIdfierPage{CGAL::angle} \\
|
\ccRefIdfierPage{CGAL::angle} \\
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,28 @@
|
||||||
%\ccHtmlNoRefLinks
|
%\ccHtmlNoRefLinks
|
||||||
\begin{ccRefFunction}{angle}
|
\begin{ccRefFunction}{angle}
|
||||||
|
|
||||||
|
\ccHtmlNoLinks
|
||||||
|
\ccFunction{Angle angle(const Vector_2<Kernel>&u,
|
||||||
|
const Vector_2<Kernel>&v);}
|
||||||
|
{returns \ccStyle{OBTUSE}, \ccStyle{RIGHT} or \ccStyle{ACUTE} depending
|
||||||
|
on the angle formed by the two vectors $u$ and $v$.}
|
||||||
|
|
||||||
\ccHtmlNoLinks
|
\ccHtmlNoLinks
|
||||||
\ccFunction{Angle angle(const Point_2<Kernel>& p,
|
\ccFunction{Angle angle(const Point_2<Kernel>& p,
|
||||||
const Point_2<Kernel>& q,
|
const Point_2<Kernel>& q,
|
||||||
const Point_2<Kernel>& r);}
|
const Point_2<Kernel>& r);}
|
||||||
{returns \ccStyle{OBTUSE}, \ccStyle{RIGHT} or \ccStyle{ACUTE} depending
|
{returns \ccStyle{OBTUSE}, \ccStyle{RIGHT} or \ccStyle{ACUTE} depending
|
||||||
on the angle formed by the three points $p$, $q$, $r$ ($q$ being the vertex of
|
on the angle formed by the three points $p$, $q$, $r$ ($q$ being the vertex of
|
||||||
the angle).}
|
the angle). The returned value is the same as \ccc{angle(p - q, r - q)}.}
|
||||||
|
|
||||||
|
\ccHtmlNoLinks
|
||||||
|
\ccFunction{Angle angle(const Point_2<Kernel>& p,
|
||||||
|
const Point_2<Kernel>& q,
|
||||||
|
const Point_2<Kernel>& r,
|
||||||
|
const Point_2<Kernel>& s);}
|
||||||
|
{returns \ccStyle{OBTUSE}, \ccStyle{RIGHT} or \ccStyle{ACUTE} depending
|
||||||
|
on the angle formed by the two vectors $pq$, $rs$. The returned value is
|
||||||
|
the same as \ccc{angle(q - p, s - r)}.}
|
||||||
|
|
||||||
\ccHtmlNoLinks
|
\ccHtmlNoLinks
|
||||||
\ccFunction{Angle angle(const Point_3<Kernel>& p,
|
\ccFunction{Angle angle(const Point_3<Kernel>& p,
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,15 @@ operator!=(const Point_2<K> &p, const Origin& o)
|
||||||
return p != Point_2<K>(o);
|
return p != Point_2<K>(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template < class K >
|
||||||
|
inline
|
||||||
|
Angle
|
||||||
|
angle(const Vector_2<K> &u,
|
||||||
|
const Vector_2<K> &v)
|
||||||
|
{
|
||||||
|
return internal::angle(u, v, K());
|
||||||
|
}
|
||||||
|
|
||||||
template < class K >
|
template < class K >
|
||||||
inline
|
inline
|
||||||
Angle
|
Angle
|
||||||
|
|
@ -59,6 +68,17 @@ angle(const Point_2<K> &p,
|
||||||
return internal::angle(p, q, r, K());
|
return internal::angle(p, q, r, K());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template < class K >
|
||||||
|
inline
|
||||||
|
Angle
|
||||||
|
angle(const Point_2<K> &p,
|
||||||
|
const Point_2<K> &q,
|
||||||
|
const Point_2<K> &r,
|
||||||
|
const Point_2<K> &s)
|
||||||
|
{
|
||||||
|
return internal::angle(p, q, r, s, K());
|
||||||
|
}
|
||||||
|
|
||||||
template < class K >
|
template < class K >
|
||||||
inline
|
inline
|
||||||
typename K::Boolean
|
typename K::Boolean
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,15 @@ namespace CGAL {
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
|
template < class K >
|
||||||
|
inline
|
||||||
|
typename K::Angle
|
||||||
|
angle(const typename K::Vector_2 &u,
|
||||||
|
const typename K::Vector_2 &v, const K& k)
|
||||||
|
{
|
||||||
|
return k.angle_2_object()(u, v);
|
||||||
|
}
|
||||||
|
|
||||||
template < class K >
|
template < class K >
|
||||||
inline
|
inline
|
||||||
typename K::Angle
|
typename K::Angle
|
||||||
|
|
@ -50,6 +59,17 @@ angle(const typename K::Point_2 &p,
|
||||||
return k.angle_2_object()(p, q, r);
|
return k.angle_2_object()(p, q, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template < class K >
|
||||||
|
inline
|
||||||
|
typename K::Angle
|
||||||
|
angle(const typename K::Point_2 &p,
|
||||||
|
const typename K::Point_2 &q,
|
||||||
|
const typename K::Point_2 &r,
|
||||||
|
const typename K::Point_2 &s, const K& k)
|
||||||
|
{
|
||||||
|
return k.angle_2_object()(p, q, r, s);
|
||||||
|
}
|
||||||
|
|
||||||
template < class K >
|
template < class K >
|
||||||
inline
|
inline
|
||||||
typename K::Boolean
|
typename K::Boolean
|
||||||
|
|
|
||||||
|
|
@ -32,12 +32,23 @@ _test_angle(const R&)
|
||||||
typedef CGAL::Point_2<R> Point_2;
|
typedef CGAL::Point_2<R> Point_2;
|
||||||
typedef CGAL::Point_3<R> Point_3;
|
typedef CGAL::Point_3<R> Point_3;
|
||||||
|
|
||||||
|
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));
|
||||||
Point_2 r(RT(5),RT(10));
|
Point_2 r(RT(5),RT(10));
|
||||||
|
Point_2 s(RT0, RT0);
|
||||||
|
|
||||||
|
Vector_2 qp = p - q;
|
||||||
|
Vector_2 qr = r - q;
|
||||||
|
|
||||||
assert( CGAL::angle( p, q, r ) == CGAL::OBTUSE );
|
assert( CGAL::angle( p, q, r ) == CGAL::OBTUSE );
|
||||||
|
assert( CGAL::angle( qp , qr ) == CGAL::OBTUSE );
|
||||||
|
assert( CGAL::angle( q, p, q, r ) == CGAL::OBTUSE );
|
||||||
assert( CGAL::angle( r, p, q ) == CGAL::ACUTE );
|
assert( CGAL::angle( r, p, q ) == CGAL::ACUTE );
|
||||||
|
assert( CGAL::angle( p, s, q , r) == CGAL::OBTUSE );
|
||||||
|
assert( CGAL::angle( p, r, s , q) == CGAL::ACUTE );
|
||||||
|
|
||||||
Point_2 e0( RT1, RT0);
|
Point_2 e0( RT1, RT0);
|
||||||
Point_2 e1( RT0, RT1);
|
Point_2 e1( RT0, RT1);
|
||||||
|
|
|
||||||
|
|
@ -611,6 +611,8 @@ test_new_2(const R& rep)
|
||||||
typename R::Angle_2 angle
|
typename R::Angle_2 angle
|
||||||
= rep.angle_2_object();
|
= rep.angle_2_object();
|
||||||
Angle tmp58 = angle(p2,p3,p4);
|
Angle tmp58 = angle(p2,p3,p4);
|
||||||
|
tmp58 = angle(p1, p2, p3, p4);
|
||||||
|
tmp58 = angle(v2, v3);
|
||||||
|
|
||||||
use(v1); use(v4); use(r1);
|
use(v1); use(v4); use(r1);
|
||||||
use(d4); use(d5);
|
use(d4); use(d5);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue