mirror of https://github.com/CGAL/cgal
Add overload for two vectors
This commit is contained in:
parent
47fe2ee58e
commit
42af962bc2
|
|
@ -1782,10 +1782,18 @@ public:
|
||||||
/// A model of this concept must provide:
|
/// A model of this concept must provide:
|
||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returns an approximation of the angle between `u` and `v`.
|
||||||
|
The angle is given in degrees.
|
||||||
|
\pre `u`and `v` are not equal to the null vector.
|
||||||
|
*/
|
||||||
|
Kernel::FT operator()(const Kernel::Vector_3& u,
|
||||||
|
const Kernel::Vector_3& v) const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
returns an approximation of the angle between `p-q` and `r-q`.
|
returns an approximation of the angle between `p-q` and `r-q`.
|
||||||
The angle is given in degrees.
|
The angle is given in degrees.
|
||||||
\pre `p`and `r` are not equal to `q`.
|
\pre `p` and `r` are not equal to `q`.
|
||||||
*/
|
*/
|
||||||
Kernel::FT operator()(const Kernel::Point_3& p,
|
Kernel::FT operator()(const Kernel::Point_3& p,
|
||||||
const Kernel::Point_3& q,
|
const Kernel::Point_3& q,
|
||||||
|
|
@ -6920,7 +6928,7 @@ public:
|
||||||
Kernel::Vector_2 operator()(const Kernel::Line_2 &l);
|
Kernel::Vector_2 operator()(const Kernel::Line_2 &l);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
introduces a null vector .
|
introduces a null vector.
|
||||||
*/
|
*/
|
||||||
Kernel::Vector_2 operator()(const Null_vector &NULL_VECTOR);
|
Kernel::Vector_2 operator()(const Null_vector &NULL_VECTOR);
|
||||||
|
|
||||||
|
|
@ -6979,7 +6987,7 @@ public:
|
||||||
Kernel::Vector_3 operator()(const Kernel::Line_3 &l);
|
Kernel::Vector_3 operator()(const Kernel::Line_3 &l);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
introduces a null vector .
|
introduces a null vector.
|
||||||
*/
|
*/
|
||||||
Kernel::Vector_3 operator()(const Null_vector &NULL_VECTOR);
|
Kernel::Vector_3 operator()(const Null_vector &NULL_VECTOR);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -832,21 +832,18 @@ namespace CommonKernelFunctors {
|
||||||
template <typename K>
|
template <typename K>
|
||||||
class Compute_approximate_angle_3
|
class Compute_approximate_angle_3
|
||||||
{
|
{
|
||||||
typedef typename K::Point_3 Point_3;
|
typedef typename K::Point_3 Point_3;
|
||||||
|
typedef typename K::Vector_3 Vector_3;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef typename K::FT result_type;
|
typedef typename K::FT result_type;
|
||||||
|
|
||||||
result_type
|
result_type
|
||||||
operator()(const Point_3& p, const Point_3& q, const Point_3& r) const
|
operator()(const Vector_3& u, const Vector_3& v) const
|
||||||
{
|
{
|
||||||
K k;
|
K k;
|
||||||
typename K::Construct_vector_3 vector = k.construct_vector_3_object();
|
|
||||||
typename K::Compute_scalar_product_3 scalar_product =
|
typename K::Compute_scalar_product_3 scalar_product =
|
||||||
k.compute_scalar_product_3_object();
|
k.compute_scalar_product_3_object();
|
||||||
typedef typename K::Vector_3 Vector_3;
|
|
||||||
|
|
||||||
Vector_3 u = vector(q,p);
|
|
||||||
Vector_3 v = vector(q,r);
|
|
||||||
|
|
||||||
double product = CGAL::sqrt(to_double(scalar_product(u,u))) * CGAL::sqrt(to_double(scalar_product(v,v)));
|
double product = CGAL::sqrt(to_double(scalar_product(u,u))) * CGAL::sqrt(to_double(scalar_product(v,v)));
|
||||||
|
|
||||||
|
|
@ -866,6 +863,19 @@ namespace CommonKernelFunctors {
|
||||||
|
|
||||||
return std::acos(cosine) * 180./CGAL_PI;
|
return std::acos(cosine) * 180./CGAL_PI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
result_type
|
||||||
|
operator()(const Point_3& p, const Point_3& q, const Point_3& r) const
|
||||||
|
{
|
||||||
|
K k;
|
||||||
|
typename K::Construct_vector_3 vector = k.construct_vector_3_object();
|
||||||
|
|
||||||
|
Vector_3 u = vector(q,p);
|
||||||
|
Vector_3 v = vector(q,r);
|
||||||
|
|
||||||
|
return this->operator()(u,v);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename K>
|
template <typename K>
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,15 @@ angle(const Point_3<K> &p, const Point_3<K> &q,
|
||||||
return internal::angle(p, q, r, v, K());
|
return internal::angle(p, q, r, v, K());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template < class K >
|
||||||
|
inline
|
||||||
|
typename K::FT
|
||||||
|
approximate_angle(const Vector_3<K> &u,
|
||||||
|
const Vector_3<K> &v)
|
||||||
|
{
|
||||||
|
return internal::approximate_angle(u, v, K());
|
||||||
|
}
|
||||||
|
|
||||||
template < class K >
|
template < class K >
|
||||||
inline
|
inline
|
||||||
typename K::FT
|
typename K::FT
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,15 @@ angle(const typename K::Point_3 &p,
|
||||||
return k.angle_3_object()(p, q, r, v);
|
return k.angle_3_object()(p, q, r, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template < class K >
|
||||||
|
inline
|
||||||
|
typename K::FT
|
||||||
|
approximate_angle(const typename K::Vector_3 &u,
|
||||||
|
const typename K::Vector_3 &v , const K& k)
|
||||||
|
{
|
||||||
|
return k.compute_approximate_angle_3_object()(u, v);
|
||||||
|
}
|
||||||
|
|
||||||
template < class K >
|
template < class K >
|
||||||
inline
|
inline
|
||||||
typename K::FT
|
typename K::FT
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,7 @@ _test_angle(const R&)
|
||||||
assert( CGAL::angle( org3, sx, sy, vcoplanar) == CGAL::RIGHT );
|
assert( CGAL::angle( org3, sx, sy, vcoplanar) == CGAL::RIGHT );
|
||||||
assert( CGAL::angle( org3, sx, sy, vmz) == CGAL::OBTUSE );
|
assert( CGAL::angle( org3, sx, sy, vmz) == CGAL::OBTUSE );
|
||||||
assert( CGAL::approximate_angle( sx, org3, sy ) > RT(89.9) );
|
assert( CGAL::approximate_angle( sx, org3, sy ) > RT(89.9) );
|
||||||
|
assert( CGAL::approximate_angle( sx-org3, sy-org3 ) > RT(89.9) );
|
||||||
assert( CGAL::approximate_angle( sx, org3, sy ) < RT(90.1) );
|
assert( CGAL::approximate_angle( sx, org3, sy ) < RT(90.1) );
|
||||||
assert( CGAL::approximate_angle( sx, org3, sx ) == RT(0) );
|
assert( CGAL::approximate_angle( sx, org3, sx ) == RT(0) );
|
||||||
assert( CGAL::approximate_angle( sx, org3, msx ) > RT(179.9) );
|
assert( CGAL::approximate_angle( sx, org3, msx ) > RT(179.9) );
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue