Add determinant(Vector_2, Vector_2)

Add determinant(Vector_3, Vector_3, Vector_3)
And corresponding functor.
This commit is contained in:
Sylvain Pion 2006-08-02 18:57:40 +00:00
parent 540406f767
commit 6ee4e656e7
25 changed files with 203 additions and 15 deletions

View File

@ -804,6 +804,40 @@ namespace CartesianKernelFunctors {
{ return t.area(); }
};
template <typename K>
class Compute_determinant_2
{
typedef typename K::FT FT;
typedef typename K::Vector_2 Vector_2;
public:
typedef FT result_type;
typedef Arity_tag< 2 > Arity;
result_type
operator()(const Vector_2& v, const Vector_2& w) const
{
return det2x2_by_formula(v.x(), v.y(), w.x(), w.y());
}
};
template <typename K>
class Compute_determinant_3
{
typedef typename K::FT FT;
typedef typename K::Vector_3 Vector_3;
public:
typedef FT result_type;
typedef Arity_tag< 3 > Arity;
result_type
operator()(const Vector_3& v, const Vector_3& w, const Vector_3& t) const
{
return det3x3_by_formula(v.x(), v.y(), v.z(),
w.x(), w.y(), w.z(),
t.x(), t.y(), t.z());
}
};
template <typename K>
class Compute_scalar_product_2
{

View File

@ -1235,6 +1235,42 @@ namespace HomogeneousKernelFunctors {
{ return t.area(); }
};
template <typename K>
class Compute_determinant_2
{
typedef typename K::FT FT;
typedef typename K::Vector_2 Vector_2;
public:
typedef FT result_type;
typedef Arity_tag< 2 > Arity;
result_type
operator()(const Vector_2& v, const Vector_2& w) const
{
return det2x2_by_formula(v.hx(), v.hy(),
w.hx(), w.hy()) / FT(v.hw() * w.hw());
}
};
template <typename K>
class Compute_determinant_3
{
typedef typename K::FT FT;
typedef typename K::Vector_3 Vector_3;
public:
typedef FT result_type;
typedef Arity_tag< 3 > Arity;
result_type
operator()(const Vector_3& v, const Vector_3& w, const Vector_3& t) const
{
return det3x3_by_formula(v.hx(), v.hy(), v.hz(),
w.hx(), w.hy(), w.hz(),
t.hx(), t.hy(), t.hz())
/ FT(v.hw() * w.hw() * t.hw());
}
};
template <typename K>
class Compute_scalar_product_2
{

View File

@ -0,0 +1,17 @@
\begin{ccRefFunctionObjectConcept}{Kernel::ComputeDeterminant_2}
A model for this must provide:
\ccCreationVariable{fo}
\ccMemberFunction{Kernel::FT operator()(const Kernel::Vector_2& v,
const Kernel::Vector_2& w);}
{returns the determinant of the two vectors $v$ and $w$. }
\ccRefines
AdaptableFunctor (with two arguments)
\ccSeeAlso
\ccRefIdfierPage{CGAL::Vector_2<Kernel>} \\
\ccRefIdfierPage{CGAL::determinant} \\
\end{ccRefFunctionObjectConcept}

View File

@ -0,0 +1,18 @@
\begin{ccRefFunctionObjectConcept}{Kernel::ComputeDeterminant_3}
A model for this must provide:
\ccCreationVariable{fo}
\ccMemberFunction{Kernel::FT operator()(const Kernel::Vector_2& u,
const Kernel::Vector_2& v,
const Kernel::Vector_2& w);}
{returns the determinant of the three vectors $u$, $v$ and $w$. }
\ccRefines
AdaptableFunctor (with three arguments)
\ccSeeAlso
\ccRefIdfierPage{CGAL::Vector_3<Kernel>} \\
\ccRefIdfierPage{CGAL::determinant} \\
\end{ccRefFunctionObjectConcept}

View File

@ -14,5 +14,6 @@ AdaptableFunctor (with two arguments)
\ccSeeAlso
\ccRefIdfierPage{CGAL::cross_product}\\
\ccRefIdfierPage{CGAL::determinant}\\
\end{ccRefFunctionObjectConcept}

View File

@ -3,13 +3,10 @@ A model for this must provide:
\ccCreationVariable{fo}
\ccMemberFunction{Kernel::Vector_2 operator()(const Kernel::Vector_2 &v1,
const Kernel::Vector_2 &v2);}
{introduces the vector $v1 - v2$.}
\ccRefines
AdaptableFunctor (with two arguments)

View File

@ -3,8 +3,6 @@ A model for this must provide:
\ccCreationVariable{fo}
\ccMemberFunction{Kernel::Vector_2 operator()(const Kernel::Vector_2 &v,
const Kernel::RT s);}
{introduces the vector $v/s$.}

View File

@ -19,4 +19,5 @@ AdaptableFunctor (with one argument)
\ccSeeAlso
\ccRefIdfierPage{CGAL::Plane_3<Kernel>} \\
\ccRefIdfierPage{Kernel::ConstructCrossProductVector_3}\\
\end{ccRefFunctionObjectConcept}

View File

@ -3,7 +3,6 @@ A model for this must provide:
\ccCreationVariable{fo}
\ccMemberFunction{
Kernel::Vector_2 operator()(const Kernel::Vector_2 &v,
const Kernel::RT& scale);}
@ -14,7 +13,6 @@ Kernel::Vector_2 operator()(const Kernel::Vector_2 &v,
const Kernel::FT& scale);}
{produces the vector \ccc{v} scaled by a factor \ccc{scale}.}
\ccRefines
AdaptableFunctor (with two arguments)

View File

@ -3,7 +3,6 @@ A model for this must provide:
\ccCreationVariable{fo}
\ccMemberFunction{
Kernel::Vector_3 operator()(const Kernel::Vector_3 &v,
const Kernel::RT& scale);}

View File

@ -3,8 +3,6 @@ A model for this must provide:
\ccCreationVariable{fo}
\ccMemberFunction{Kernel::Vector_2 operator()(const Kernel::Vector_2 &v1,
const Kernel::Vector_2 &v2);}
{introduces the vector $v1 + v2$.}

View File

@ -7,6 +7,7 @@ CopyConstructible, Assignable, DefaultConstructible
\ccSeeAlso
\ccRefIdfierPage{CGAL::Vector_2<Kernel>} \\
\ccRefConceptPage{Kernel::ComputeDeterminant_2} \\
\ccRefConceptPage{Kernel::ComputeX_2} \\
\ccRefConceptPage{Kernel::ComputeY_2} \\
\ccRefConceptPage{Kernel::ComputeHx_2} \\

View File

@ -7,6 +7,7 @@ CopyConstructible, Assignable, DefaultConstructible
\ccSeeAlso
\ccRefIdfierPage{CGAL::Vector_3<Kernel>} \\
\ccRefConceptPage{Kernel::ComputeDeterminant_3} \\
\ccRefConceptPage{Kernel::ConstructCrossProductVector_3} \\
\ccRefConceptPage{Kernel::ConstructDirection_3} \\
\ccRefConceptPage{Kernel::ConstructOppositeVector_3} \\

View File

@ -147,5 +147,6 @@ The following operations can be applied on vectors:
\ccSeeAlso
\ccRefConceptPage{Kernel::Vector_3} \\
\ccRefIdfierPage{CGAL::cross_product} \\
\ccRefIdfierPage{CGAL::determinant} \\
\end{ccRefClass}

View File

@ -0,0 +1,22 @@
%\ccHtmlNoRefLinks
\begin{ccRefFunction}{determinant}
\ccHtmlNoLinks
\ccFunction{Kernel::FT determinant(const Vector_2<Kernel>& v,
const Vector_2<Kernel>& w);}
{returns the determinant of $v$ and $w$.}
\ccHtmlNoLinks
\ccFunction{Kernel::FT determinant(const Vector_3<Kernel>& u,
const Vector_3<Kernel>& v,
const Vector_3<Kernel>& w);}
{returns the determinant of $u$, $v$ and $w$.}
\ccSeeAlso
\ccRefIdfierPage{CGAL::orientation}
\ccRefIdfierPage{CGAL::collinear}
\ccRefIdfierPage{CGAL::left_turn}
\ccRefIdfierPage{CGAL::right_turn}
\end{ccRefFunction}

View File

@ -176,6 +176,7 @@ in the kernel.
\input{Kernel_23_ref/coplanar_orientation.tex}
\input{Kernel_23_ref/coplanar_side_of_bounded_circle.tex}
\input{Kernel_23_ref/cross_product.tex}
\input{Kernel_23_ref/determinant.tex}
\input{Kernel_23_ref/do_intersect.tex}
\input{Kernel_23_ref/do_overlap.tex}
\input{Kernel_23_ref/enum_cast.tex}
@ -259,6 +260,8 @@ in the kernel.
\input{Kernel_23_ref/Kernel_ComputeC_2.tex}
\input{Kernel_23_ref/Kernel_ComputeArea_2.tex}
\input{Kernel_23_ref/Kernel_ComputeArea_3.tex}
\input{Kernel_23_ref/Kernel_ComputeDeterminant_2.tex}
\input{Kernel_23_ref/Kernel_ComputeDeterminant_3.tex}
\input{Kernel_23_ref/Kernel_ComputeScalarProduct_2.tex}
\input{Kernel_23_ref/Kernel_ComputeScalarProduct_3.tex}
\input{Kernel_23_ref/Kernel_ComputeSquaredArea_3.tex}

View File

@ -445,6 +445,14 @@ compare_yx(const Point_2<K> &p, const Point_2<K> &q)
return CGALi::compare_yx(p, q, K());
}
template < class K >
inline
typename K::FT
determinant(const Vector_2<K> &v0, const Vector_2<K> &v1)
{
return CGALi::determinant(v0, v1, K());
}
template <class K>
inline
bool

View File

@ -314,6 +314,15 @@ cross_product(const Vector_3<K> &v, const Vector_3<K> &w)
return CGALi::cross_product(v, w, K());
}
template < class K >
inline
typename K::FT
determinant(const Vector_3<K> &v0, const Vector_3<K> &v1,
const Vector_3<K> &v2)
{
return CGALi::determinant(v0, v1, v2, K());
}
template < class K >
inline
bool

View File

@ -447,6 +447,15 @@ compare_y_at_x(const typename CGAL_WRAP(K)::Line_2 &l1,
return k.compare_y_at_x_2_object()(l1, l2, h1, h2);
}
template < class K >
inline
typename K::FT
determinant(const typename CGAL_WRAP(K)::Vector_2 &v0,
const typename CGAL_WRAP(K)::Vector_2 &v1, const K &k)
{
return k.compute_determinant_2_object()(v0, v1);
}
template <class K>
inline
bool

View File

@ -333,6 +333,16 @@ cross_product(const typename CGAL_WRAP(K)::Vector_3 &v,
return k.construct_cross_product_vector_3_object()(v, w);
}
template < class K >
inline
typename K::FT
determinant(const typename CGAL_WRAP(K)::Vector_3 &v0,
const typename CGAL_WRAP(K)::Vector_3 &v1,
const typename CGAL_WRAP(K)::Vector_3 &v2, const K &k)
{
return k.compute_determinant_3_object()(v0, v1, v2);
}
template < class K >
inline
bool

View File

@ -151,6 +151,10 @@ CGAL_Kernel_cons(Compute_area_2,
compute_area_2_object)
CGAL_Kernel_cons(Compute_area_3,
compute_area_3_object)
CGAL_Kernel_cons(Compute_determinant_2,
compute_determinant_2_object)
CGAL_Kernel_cons(Compute_determinant_3,
compute_determinant_3_object)
CGAL_Kernel_cons(Compute_scalar_product_2,
compute_scalar_product_2_object)
CGAL_Kernel_cons(Compute_scalar_product_3,

View File

@ -60,6 +60,12 @@ _test_fct_vector_2(const R& )
assert( orientation(v1, v2) == CGAL::RIGHT_TURN );
assert( orientation(v2, v1) == CGAL::LEFT_TURN );
assert( determinant(v0, v0) == 0 );
assert( determinant(v1, v1) == 0 );
assert( determinant(v1, v0) == 0 );
assert( determinant(v1, v2) == -30 );
assert( determinant(v2, v1) == 30 );
assert( v1 + v2 == v3 );
assert( v1 - v2 == v4 );
assert( v3 - v1 == v2 );

View File

@ -66,6 +66,15 @@ _test_fct_vector_3(const R& )
assert( orientation(v1, v2, v12) == CGAL::POSITIVE );
assert( orientation(v1, v12, v2) == CGAL::NEGATIVE );
assert( determinant(v0, v0, v0) == 0 );
assert( determinant(v1, v1, v1) == 0 );
assert( determinant(v1, v1, v2) == 0 );
assert( determinant(v1, v2, v1) == 0 );
assert( determinant(v2, v1, v1) == 0 );
assert( determinant(v1, v2, v3) == 0 );
assert( determinant(v1, v2, v12) == 180 );
assert( determinant(v1, v12, v2) == -180 );
assert( v1 + v2 == v3 );
assert( v1 - v2 == v4 );
assert( v3 - v1 == v2 );

View File

@ -343,15 +343,19 @@ test_new_2(const R& rep)
tmp22a = compute_area_2(rec2);
tmp22a = compute_area_2(p3, p4, p5);
typename R::Compute_determinant_2 compute_determinant_2
= rep.compute_determinant_2_object();
FT tmp22b = compute_determinant_2(v3, v4);
typename R::Compute_scalar_product_2 Compute_scalar_product
= rep.compute_scalar_product_2_object();
FT tmp22b = Compute_scalar_product(v3, v4);
FT tmp22c = Compute_scalar_product(v3, v4);
typename R::Compute_squared_distance_2 Compute_squared_distance
= rep.compute_squared_distance_2_object();
FT tmp22c = Compute_squared_distance(p1, p2);
tmp22c = Compute_squared_distance(p1, r2);
tmp22c = Compute_squared_distance(p1, t2);
FT tmp22d = Compute_squared_distance(p1, p2);
tmp22d = Compute_squared_distance(p1, r2);
tmp22d = Compute_squared_distance(p1, t2);
typename R::Compute_squared_length_2 Compute_squared_length
= rep.compute_squared_length_2_object();

View File

@ -391,6 +391,10 @@ test_new_3(const R& rep)
(void) tmp12a;
(void) tmp12b;
typename R::Compute_determinant_3 compute_determinant_3
= rep.compute_determinant_3_object();
FT tmp12aa = compute_determinant_3(v3, v4, v5);
typename R::Compute_scalar_product_3 Compute_scalar_product
= rep.compute_scalar_product_3_object();
FT tmp12bb = Compute_scalar_product(v3, v4);
@ -708,7 +712,7 @@ test_new_3(const R& rep)
use(tmp3); use(tmp3a);
use(tmp9); use(tmp14a); use(tmp5); use(tmp6);
use(tmp7); use(tmp71); use(sp1a); use(tmp72);
use(tmp12a); use(tmp12b);
use(tmp12a); use(tmp12aa); use(tmp12b);
use(bb1); use(bb2); use(bb3); use(bb4); use(bb5); use(bb6);
use(r4); use(r5); use(l7); use(l8); use(v7); use(v8); use(v9); use(h8);
use(cccit);