diff --git a/NewKernel_d/include/CGAL/Vector/array.h b/NewKernel_d/include/CGAL/Vector/array.h index 58ae05a1399..e7f63e31ccc 100644 --- a/NewKernel_d/include/CGAL/Vector/array.h +++ b/NewKernel_d/include/CGAL/Vector/array.h @@ -13,6 +13,8 @@ namespace CGAL { // In that case, we should store the real dim next to the array. template struct Array_vector { typedef NT_ NT; + typedef Dim_ Dimension; + typedef Max_dim_ Max_dimension; template< class D2, class D3=D2 > struct Rebind_dimension { typedef Array_vector< NT, D2, D3 > Other; diff --git a/NewKernel_d/include/CGAL/Vector/determinant_of_points.h b/NewKernel_d/include/CGAL/Vector/determinant_of_points.h new file mode 100644 index 00000000000..ecdcb47eac6 --- /dev/null +++ b/NewKernel_d/include/CGAL/Vector/determinant_of_points.h @@ -0,0 +1,90 @@ +#ifndef CGAL_VECTOR_DETPTS_H +#define CGAL_VECTOR_DETPTS_H +#include +#include + +namespace CGAL { + +template ::value, + bool = LA::template Property::value + && LA::template Property::value> +struct Add_determinant_of_points_from_vectors_and_minus : LA { + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef typename LA::template Rebind_dimension LA2; + typedef Add_determinant_of_vectors_small_dim Other; + }; +}; + +//FIXME: Use variadics and boost so it works in any dimension. +template +struct Add_determinant_of_points_from_vectors_and_minus +, Max_dim_, false, true> : LA { + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef typename LA::template Rebind_dimension LA2; + typedef Add_determinant_of_points_from_vectors_and_minus Other; + }; + template struct Property : LA::template Property

{}; + template struct Property : + boost::true_type {}; + + static NT determinant_of_points(Vector const&a, Vector const&b, + Vector const&c){ + return LA::determinant_of_vectors(b-a,c-a); + } + static Sign sign_of_determinant_of_points(Vector const&a, Vector const&b, + Vector const&c){ + return LA::sign_of_determinant_of_vectors(b-a,c-a); + } +}; + +template +struct Add_determinant_of_points_from_vectors_and_minus +, Max_dim_, false, true> : LA { + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef typename LA::template Rebind_dimension LA2; + typedef Add_determinant_of_points_from_vectors_and_minus Other; + }; + template struct Property : LA::template Property

{}; + template struct Property : + boost::true_type {}; + + static NT determinant_of_points(Vector const&a, Vector const&b, + Vector const&c, Vector const&d){ + return LA::determinant_of_vectors(b-a,c-a,d-a); + } + static Sign sign_of_determinant_of_points(Vector const&a, Vector const&b, + Vector const&c, Vector const&d){ + return LA::sign_of_determinant_of_vectors(b-a,c-a,d-a); + } +}; + +template +struct Add_determinant_of_points_from_vectors_and_minus +, Max_dim_, false, true> : LA { + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef typename LA::template Rebind_dimension LA2; + typedef Add_determinant_of_points_from_vectors_and_minus Other; + }; + template struct Property : LA::template Property

{}; + template struct Property : + boost::true_type {}; + + static NT determinant_of_points(Vector const&a, Vector const&b, + Vector const&c, Vector const&d, Vector const&e){ + return LA::determinant_of_vectors(b-a,c-a,d-a,e-a); + } + static Sign sign_of_determinant_of_points(Vector const&a, Vector const&b, + Vector const&c, Vector const&d, Vector const&e){ + return LA::sign_of_determinant_of_vectors(b-a,c-a,d-a,e-a); + } +}; + +//TODO: Go up to 6. First check that it won't be done differently eventually. + +} +#endif diff --git a/NewKernel_d/include/CGAL/Vector/determinant_of_vectors_small_dim.h b/NewKernel_d/include/CGAL/Vector/determinant_of_vectors_small_dim.h new file mode 100644 index 00000000000..9e3f5115fc7 --- /dev/null +++ b/NewKernel_d/include/CGAL/Vector/determinant_of_vectors_small_dim.h @@ -0,0 +1,97 @@ +#ifndef CGAL_VECTOR_DETVEC_SMALL_H +#define CGAL_VECTOR_DETVEC_SMALL_H +#include +#include +#include +#include + +namespace CGAL { + +template ::value> +struct Add_determinant_of_vectors_small_dim : LA { + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef typename LA::template Rebind_dimension LA2; + typedef Add_determinant_of_vectors_small_dim Other; + }; +}; + +template +struct Add_determinant_of_vectors_small_dim +, Max_dim_, false> : LA { + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef typename LA::template Rebind_dimension LA2; + typedef Add_determinant_of_vectors_small_dim Other; + }; + template struct Property : LA::template Property

{}; + template struct Property : + boost::true_type {}; + + template + static NT determinant_of_vectors(V1 const&a, V2 const&b){ + return determinant(a[0],a[1],b[0],b[1]); + } + template + static Sign sign_of_determinant_of_vectors(V1 const&a, V2 const&b){ + return sign_of_determinant(a[0],a[1],b[0],b[1]); + } +}; + +template +struct Add_determinant_of_vectors_small_dim +, Max_dim_, false> : LA { + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef typename LA::template Rebind_dimension LA2; + typedef Add_determinant_of_vectors_small_dim Other; + }; + template struct Property : LA::template Property

{}; + template struct Property : + boost::true_type {}; + + static NT determinant_of_vectors(Vector const&a, Vector const&b, + Vector const&c){ + return determinant(a[0],a[1],a[2],b[0],b[1],b[2],c[0],c[1],c[2]); + } + static Sign sign_of_determinant_of_vectors(Vector const&a, Vector const&b, + Vector const&c){ + return sign_of_determinant(a[0],a[1],a[2],b[0],b[1],b[2],c[0],c[1],c[2]); + } +}; + +template +struct Add_determinant_of_vectors_small_dim +, Max_dim_, false> : LA { + template< class D2, class D3=D2 > + struct Rebind_dimension { + typedef typename LA::template Rebind_dimension LA2; + typedef Add_determinant_of_vectors_small_dim Other; + }; + template struct Property : LA::template Property

{}; + template struct Property : + boost::true_type {}; + + static NT determinant_of_vectors(Vector const&a, Vector const&b, + Vector const&c, Vector const&d){ + return determinant( + a[0],a[1],a[2],a[3], + b[0],b[1],b[2],b[3], + c[0],c[1],c[2],c[3], + d[0],d[1],d[2],d[3]); + } + static Sign sign_of_determinant_of_vectors(Vector const&a, Vector const&b, + Vector const&c, Vector const&d){ + return sign_of_determinant( + a[0],a[1],a[2],a[3], + b[0],b[1],b[2],b[3], + c[0],c[1],c[2],c[3], + d[0],d[1],d[2],d[3]); + } +}; + +//TODO: Go up to 6. First check that it won't be done differently eventually. + +} +#endif diff --git a/NewKernel_d/include/CGAL/Vector/vector.h b/NewKernel_d/include/CGAL/Vector/vector.h index a4a910a2137..9db230b1b7d 100644 --- a/NewKernel_d/include/CGAL/Vector/vector.h +++ b/NewKernel_d/include/CGAL/Vector/vector.h @@ -12,6 +12,8 @@ namespace CGAL { //Derive from a class that doesn't depend on Dim, or still use Dim for checking? template struct Vector_vector { typedef NT_ NT; + typedef Dim_ Dimension; + typedef Max_dim_ Max_dimension; typedef std::vector Vector; template< class D2, class D3=D2 > struct Rebind_dimension {