mirror of https://github.com/CGAL/cgal
Move some Vector_3 functions to user class level.
This commit is contained in:
parent
8e22345d08
commit
a63e4909f9
|
|
@ -2132,6 +2132,19 @@ namespace CartesianKernelFunctors {
|
|||
{ return Vector_2(v.x()-w.x(), v.y()-w.y()); }
|
||||
};
|
||||
|
||||
template <typename K>
|
||||
class Construct_difference_of_vectors_3
|
||||
{
|
||||
typedef typename K::Vector_3 Vector_3;
|
||||
public:
|
||||
typedef Vector_3 result_type;
|
||||
typedef Arity_tag< 2 > Arity;
|
||||
|
||||
Vector_3
|
||||
operator()( const Vector_3& v, const Vector_3& w) const
|
||||
{ return Vector_3(v.x()-w.x(), v.y()-w.y(), v.z()-w.z()); }
|
||||
};
|
||||
|
||||
template <typename K>
|
||||
class Construct_sum_of_vectors_2
|
||||
{
|
||||
|
|
@ -2145,6 +2158,19 @@ namespace CartesianKernelFunctors {
|
|||
{ return Vector_2(v.x()+w.x(), v.y()+w.y()); }
|
||||
};
|
||||
|
||||
template <typename K>
|
||||
class Construct_sum_of_vectors_3
|
||||
{
|
||||
typedef typename K::Vector_3 Vector_3;
|
||||
public:
|
||||
typedef Vector_3 result_type;
|
||||
typedef Arity_tag< 2 > Arity;
|
||||
|
||||
Vector_3
|
||||
operator()( const Vector_3& v, const Vector_3& w) const
|
||||
{ return Vector_3(v.x()+w.x(), v.y()+w.y(), v.z()+w.z()); }
|
||||
};
|
||||
|
||||
template <typename K>
|
||||
class Construct_opposite_vector_3
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2286,6 +2286,25 @@ namespace HomogeneousKernelFunctors {
|
|||
}
|
||||
};
|
||||
|
||||
template <typename K>
|
||||
class Construct_difference_of_vectors_3
|
||||
{
|
||||
typedef typename K::Vector_3 Vector_3;
|
||||
public:
|
||||
typedef Vector_3 result_type;
|
||||
typedef Arity_tag< 2 > Arity;
|
||||
|
||||
Vector_3
|
||||
operator()(const Vector_3& v, const Vector_3& w) const
|
||||
{
|
||||
return Vector_3( v.hx()*w.hw() - w.hx()*v.hw(),
|
||||
v.hy()*w.hw() - w.hy()*v.hw(),
|
||||
v.hz()*w.hw() - w.hz()*v.hw(),
|
||||
v.hw()*w.hw() );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename K>
|
||||
class Construct_direction_2
|
||||
{
|
||||
|
|
@ -2385,6 +2404,24 @@ namespace HomogeneousKernelFunctors {
|
|||
}
|
||||
};
|
||||
|
||||
template <typename K>
|
||||
class Construct_sum_of_vectors_3
|
||||
{
|
||||
typedef typename K::Vector_3 Vector_3;
|
||||
public:
|
||||
typedef Vector_3 result_type;
|
||||
typedef Arity_tag< 2 > Arity;
|
||||
|
||||
Vector_3
|
||||
operator()(const Vector_3& v, const Vector_3& w) const
|
||||
{
|
||||
return Vector_3(v.hx()*w.hw() + w.hx()*v.hw(),
|
||||
v.hy()*w.hw() + w.hy()*v.hw(),
|
||||
v.hz()*w.hw() + w.hz()*v.hw(),
|
||||
v.hw()*w.hw());
|
||||
}
|
||||
};
|
||||
|
||||
template <typename K>
|
||||
class Construct_divided_vector_2
|
||||
{
|
||||
|
|
|
|||
|
|
@ -273,8 +273,12 @@ CGAL_Kernel_cons(Construct_opposite_vector_2,
|
|||
construct_opposite_vector_2_object)
|
||||
CGAL_Kernel_cons(Construct_difference_of_vectors_2,
|
||||
construct_difference_of_vectors_2_object)
|
||||
CGAL_Kernel_cons(Construct_difference_of_vectors_3,
|
||||
construct_difference_of_vectors_3_object)
|
||||
CGAL_Kernel_cons(Construct_sum_of_vectors_2,
|
||||
construct_sum_of_vectors_2_object)
|
||||
CGAL_Kernel_cons(Construct_sum_of_vectors_3,
|
||||
construct_sum_of_vectors_3_object)
|
||||
CGAL_Kernel_cons(Construct_opposite_vector_3,
|
||||
construct_opposite_vector_3_object)
|
||||
CGAL_Kernel_cons(Construct_orthogonal_vector_3,
|
||||
|
|
|
|||
|
|
@ -92,6 +92,21 @@ public:
|
|||
return t.transform(*this);
|
||||
}
|
||||
|
||||
Vector_3 operator-() const
|
||||
{
|
||||
return R().construct_opposite_vector_3_object()(*this);
|
||||
}
|
||||
|
||||
Vector_3 operator-(const Vector_3& v) const
|
||||
{
|
||||
return R().construct_difference_of_vectors_3_object()(*this,v);
|
||||
}
|
||||
|
||||
Vector_3 operator+(const Vector_3& v) const
|
||||
{
|
||||
return R().construct_sum_of_vectors_3_object()(*this,v);
|
||||
}
|
||||
|
||||
Vector_3 operator/(const RT& c) const
|
||||
{
|
||||
return R().construct_divided_vector_3_object()(*this,c);
|
||||
|
|
@ -102,6 +117,78 @@ public:
|
|||
return R().construct_divided_vector_3_object()(*this,c);
|
||||
}
|
||||
|
||||
typename Qualified_result_of<typename R::Compute_x_3, Vector_3>::type
|
||||
x() const
|
||||
{
|
||||
return R().compute_x_3_object()(*this);
|
||||
}
|
||||
|
||||
typename Qualified_result_of<typename R::Compute_y_3, Vector_3>::type
|
||||
y() const
|
||||
{
|
||||
return R().compute_y_3_object()(*this);
|
||||
}
|
||||
|
||||
typename Qualified_result_of<typename R::Compute_z_3, Vector_3>::type
|
||||
z() const
|
||||
{
|
||||
return R().compute_z_3_object()(*this);
|
||||
}
|
||||
|
||||
typename Qualified_result_of<typename R::Compute_hx_3, Vector_3>::type
|
||||
hx() const
|
||||
{
|
||||
return R().compute_hx_3_object()(*this);
|
||||
}
|
||||
|
||||
typename Qualified_result_of<typename R::Compute_hy_3, Vector_3>::type
|
||||
hy() const
|
||||
{
|
||||
return R().compute_hy_3_object()(*this);
|
||||
}
|
||||
|
||||
typename Qualified_result_of<typename R::Compute_hz_3, Vector_3>::type
|
||||
hz() const
|
||||
{
|
||||
return R().compute_hz_3_object()(*this);
|
||||
}
|
||||
|
||||
typename Qualified_result_of<typename R::Compute_hw_3, Vector_3>::type
|
||||
hw() const
|
||||
{
|
||||
return R().compute_hw_3_object()(*this);
|
||||
}
|
||||
|
||||
typename Qualified_result_of<typename R::Compute_x_3, Vector_3>::type
|
||||
cartesian(int i) const
|
||||
{
|
||||
CGAL_kernel_precondition( (i == 0) || (i == 1) || (i == 2) );
|
||||
if (i==0) return x();
|
||||
if (i==1) return y();
|
||||
return z();
|
||||
}
|
||||
|
||||
typename Qualified_result_of<typename R::Compute_hw_3, Vector_3>::type
|
||||
homogeneous(int i) const
|
||||
{
|
||||
CGAL_kernel_precondition( (i >= 0) || (i <= 3) );
|
||||
if (i==0) return hx();
|
||||
if (i==1) return hy();
|
||||
if (i==2) return hz();
|
||||
return hw();
|
||||
}
|
||||
|
||||
int dimension() const
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
typename Qualified_result_of<typename R::Compute_x_3, Vector_3>::type
|
||||
operator[](int i) const
|
||||
{
|
||||
return cartesian(i);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#ifndef CGAL_NO_OSTREAM_INSERT_VECTOR_3
|
||||
|
|
|
|||
Loading…
Reference in New Issue