Added Direction_d, Vector_d, Plane_d

Linear_algebra: empty implementation [will not execute properly]
Compiles with egcs 1.1.2, TODO: check with g++ 2.95.2
This commit is contained in:
Hervé Brönnimann 1999-11-17 16:56:41 +00:00
parent bb7bbb890f
commit c739e24650
18 changed files with 151 additions and 57 deletions

View File

@ -5,6 +5,7 @@
#ifndef CGAL_CARTESIAN_DIRECTION_D_C
#define CGAL_CARTESIAN_DIRECTION_D_C
#include <CGAL/Cartesian/redefine_names_d.h>
#include <CGAL/Cartesian/Direction_d.h>
#include <CGAL/Cartesian/predicates_on_directions_d.h>
#include <CGAL/Cartesian/d_utils.h>
@ -56,6 +57,7 @@ bool
DirectionCd<R CGAL_CTAG>::operator==(const DirectionCd<R CGAL_CTAG> &d) const
{
if (dimension() != d.dimension()) return false;
if (ptr() == d.ptr()) return true; // identical
return equal_direction(*this,d);
}

View File

@ -108,6 +108,7 @@ inline
bool
LineC3<R CGAL_CTAG>::operator==(const LineC3<R CGAL_CTAG> &l) const
{
if (ptr() == l.ptr()) return true; // identical
return has_on(l.point()) && (direction() == l.direction());
}

View File

@ -83,6 +83,7 @@ bool
LA_matrixCd<LA>::operator==(const LA_matrixCd<LA> &M) const
{
if (dimension() != M.dimension()) return false;
if (ptr() == M.ptr()) return true; // identical
return std::equal(begin(),end(),M.begin());
}

View File

@ -46,6 +46,7 @@ bool
LA_vectorCd<R CGAL_CTAG>::operator==(const LA_vectorCd<R CGAL_CTAG> &v) const
{
if (dimension() != v.dimension()) return false;
if (ptr() == v.ptr()) return true; // identical
return std::equal(begin(),end(),v.begin());
}

View File

@ -13,6 +13,7 @@
#define typename
#endif
#include <CGAL/Cartesian/Plane_d.h>
#include <CGAL/predicates/kernel_ftCd.h>
#include <CGAL/Cartesian/constructions_on_planes_d.h>
// #include <CGAL/Cartesian/distance_computations_d.h>
@ -20,14 +21,6 @@
CGAL_BEGIN_NAMESPACE
template < class R >
inline
_d_tuple<typename R::FT>*
PlaneCd<R CGAL_CTAG>::ptr() const
{
return (_d_tuple<FT>*)PTR;
}
template < class R >
inline
void
@ -41,23 +34,23 @@ template < class R >
inline
void
PlaneCd<R CGAL_CTAG>::
new_rep(int dim,
typename PlaneCd<R CGAL_CTAG>::const_iterator hb,
new_rep(typename PlaneCd<R CGAL_CTAG>::const_iterator hb,
typename PlaneCd<R CGAL_CTAG>::const_iterator he)
{
int dim = he-hb-1;
new_rep(dim);
std::copy_n(hb,dim+1,ptr->e());
std::copy_n(hb,dim+1,begin());
}
template < class R >
inline
void
PlaneCd<R CGAL_CTAG>::
new_rep(int dim,
typename PlaneCd<R CGAL_CTAG>::const_iterator hb,
new_rep(typename PlaneCd<R CGAL_CTAG>::const_iterator hb,
typename PlaneCd<R CGAL_CTAG>::const_iterator he,
const typename PlaneCd<R CGAL_CTAG>::RT &w)
{
int dim = he-hb-1;
new_rep(dim);
std::copy_n(hb,dim,begin());
*(begin()+dim+1) = w;
@ -85,7 +78,7 @@ PlaneCd(const typename PlaneCd<R CGAL_CTAG>::Point_d &p,
const typename PlaneCd<R CGAL_CTAG>::Direction_d &d)
{
PlaneCd<R CGAL_CTAG> h = plane_from_point_direction(p,d);
new_rep(h.dimension(),h.begin(),h.end());
new_rep(h.begin(),h.end());
}
template < class R >
@ -95,7 +88,7 @@ PlaneCd(const typename PlaneCd<R CGAL_CTAG>::Point_d &p,
const typename PlaneCd<R CGAL_CTAG>::Vector_d &v)
{
PlaneCd<R CGAL_CTAG> h = plane_from_point_direction(p,v.direction());
new_rep(h.dimension(),h.begin(),h.end());
new_rep(h.begin(),h.end());
}
template < class R >
@ -118,7 +111,8 @@ bool PlaneCd<R CGAL_CTAG>::
operator==(const PlaneCd<R CGAL_CTAG> &h) const
{
if (dimension() != h.dimension()) return false;
return is_positively_proportional(begin(),end(),h.begin());
if (ptr() == h.ptr()) return true; // identical
return is_positively_proportionalCd(begin(),end(),h.begin());
}
template < class R >
@ -138,10 +132,18 @@ long PlaneCd<R CGAL_CTAG>::id() const
template < class R >
inline
typename PlaneCd<R CGAL_CTAG>::Point_d
PlaneCd<R CGAL_CTAG>::point(int i) const
typename PlaneCd<R CGAL_CTAG>::RT
PlaneCd<R CGAL_CTAG>::operator[](int i) const
{
return point_on_plane(*this,i);
return *(begin()+i);
}
template < class R >
inline
typename PlaneCd<R CGAL_CTAG>::Point_d
PlaneCd<R CGAL_CTAG>::point() const
{
return point_on_plane(*this);
}
template < class R >
@ -173,8 +175,10 @@ template < class R >
typename PlaneCd<R CGAL_CTAG>::Vector_d
PlaneCd<R CGAL_CTAG>::base(int i) const
{
return Vector_d(); // TODO
}
/*
template < class R >
inline
typename PlaneCd<R CGAL_CTAG>::Line_d
@ -183,6 +187,7 @@ perpendicular_line(const typename PlaneCd<R CGAL_CTAG>::Point_d &p) const
{
return Line_d(p, orthogonal_direction());
}
*/
template < class R >
inline

View File

@ -6,7 +6,11 @@
#define CGAL_CARTESIAN_PLANE_D_H
#include <CGAL/Cartesian/redefine_names_d.h>
#include <CGAL/Cartesian/d_utils.h>
#include <CGAL/d_tuple.h>
#include <algorithm>
#include <functional>
CGAL_BEGIN_NAMESPACE
@ -29,48 +33,51 @@ public:
typedef typename R::Point_d Point_d;
typedef typename R::Vector_d Vector_d;
typedef typename R::Direction_d Direction_d;
typedef typename R::Line_d Line_d;
typedef typename R::Ray_d Ray_d;
typedef typename R::Segment_d Segment_d;
typedef typename R::Aff_transformation_d Aff_transformation_d;
// typedef typename R::Line_d Line_d;
// typedef typename R::Ray_d Ray_d;
// typedef typename R::Segment_d Segment_d;
// typedef typename R::Aff_transformation_d Aff_transformation_d;
#else
typedef PlaneCd<R> Self;
typedef typename R::Point_d_base Point_d;
typedef typename R::Vector_d_base Vector_d;
typedef typename R::Direction_d_base Direction_d;
typedef typename R::Line_d_base Line_d;
typedef typename R::Ray_d_base Ray_d;
typedef typename R::Segment_d_base Segment_d;
typedef typename R::Aff_transformation_d_base Aff_transformation_d;
// typedef typename R::Line_d_base Line_d;
// typedef typename R::Ray_d_base Ray_d;
// typedef typename R::Segment_d_base Segment_d;
// typedef typename R::Aff_transformation_d_base Aff_transformation_d;
#endif
PlaneCd(int d = 0);
PlaneCd(const Self &p);
PlaneCd(const Point_d &p, const Direction_d &d);
PlaneCd(const Point_d &p, const Vector_d &d);
template < class InputIterator >
PlaneCd(const int d,
const InputIterator &first, const InputIterator &last)
{
new_rep(d,first,last);
CGAL_kernel_assertion( last-first == d+1);
new_rep(first,last);
}
template < class InputIterator >
PlaneCd(const int d,
const InputIterator &first, const InputIterator &last, const RT &w)
{
new_rep(d,first,last,w);
CGAL_kernel_assertion( last-first == d);
new_rep(first,last,w);
}
template < class InputIterator >
PlaneCd(const InputIterator &first, const InputIterator &last)
{
Self h = plane_from_points(first->dimension(),first,last);
new_rep(h.dimension(),h.begin(),h.end());
Self h = plane_from_points(first->dimension(),first,last,R());
new_rep(h.begin(),h.end());
}
template < class InputIterator >
PlaneCd(const InputIterator &begin, const InputIterator &end,
const Self &o, Oriented_side side = POSITIVE)
{
Self h = plane_from_points(first->dimension(),first,last,o,side);
new_rep(h.dimension(),h.begin(),h.end());
new_rep(h.begin(),h.end());
}
~PlaneCd();
@ -86,7 +93,7 @@ public:
Vector_d orthogonal_vector() const;
Direction_d orthogonal_direction() const;
Vector_d base(const int i) const;
Line_d perpendicular_line(const Point_d &p) const;
// Line_d perpendicular_line(const Point_d &p) const;
Self opposite() const;
Point_d to_plane_basis(const Point_d &p) const;
@ -101,7 +108,7 @@ public:
bool is_degenerate() const;
int dimension() const { return ptr->d; }
int dimension() const { return ptr()->d; }
const_iterator begin() const { return ptr()->e; }
const_iterator end() const { return ptr()->e+dimension(); }
@ -111,10 +118,10 @@ protected:
private:
const _d_tuple<RT>* ptr() const { return (const _d_tuple<RT>*)PTR; }
_d_tuple<RT>* ptr() { return (_d_tuple<RT>*)PTR; }
_d_tuple<RT>* ptr() { return (_d_tuple<RT>*)PTR; }
void new_rep(int d);
void new_rep(int d, const_iterator hb, const_iterator he);
void new_rep(int d, const_iterator hb, const_iterator he, const RT &w);
void new_rep(const_iterator hb, const_iterator he);
void new_rep(const_iterator hb, const_iterator he, const RT &w);
};
CGAL_END_NAMESPACE

View File

@ -69,6 +69,7 @@ bool
PointCd<R CGAL_CTAG>::operator==(const PointCd<R CGAL_CTAG>& p) const
{
if (dimension() != p.dimension()) return false;
if (ptr() == p.ptr()) return true; // identical
return std::equal(begin(),end(),p.begin());
}

View File

@ -68,6 +68,7 @@ RayC3<R CGAL_CTAG>::operator=(const RayC3<R CGAL_CTAG> &r)
template < class R >
inline bool RayC3<R CGAL_CTAG>::operator==(const RayC3<R CGAL_CTAG> &r) const
{
if (ptr() == r.ptr()) return true; // identical
return (source() == r.source()) && (direction() == r.direction());
}

View File

@ -63,6 +63,7 @@ inline
bool
SegmentC3<R CGAL_CTAG>::operator==(const SegmentC3<R CGAL_CTAG> &s) const
{
if (ptr() == s.ptr()) return true; // identical
return (source() == s.source()) && (target() == s.target());
}

View File

@ -135,9 +135,10 @@ CGAL_KERNEL_INLINE
bool SphereC3<R CGAL_CTAG>::
operator==(const SphereC3<R CGAL_CTAG> &t) const
{
return (center() == t.center()) &&
(squared_radius() == t.squared_radius() &&
orientation() == t.orientation());
if (ptr() == t.ptr()) return true; // identical
return center() == t.center() &&
squared_radius() == t.squared_radius() &&
orientation() == t.orientation();
}
template < class R >

View File

@ -60,10 +60,10 @@ bool
TriangleC3<R CGAL_CTAG>::operator==(const TriangleC3<R CGAL_CTAG> &t) const
{
int i;
if (ptr() == t.ptr()) return true; // identical
for(i=0; i<3; i++)
if ( vertex(0) == t.vertex(i) )
break;
return (i<3) && vertex(1) == t.vertex(i+1) && vertex(2) == t.vertex(i+2);
}

View File

@ -76,6 +76,7 @@ bool
VectorCd<R CGAL_CTAG>::operator==(const VectorCd<R CGAL_CTAG> &v) const
{
if (dimension() != v.dimension()) return false;
if (ptr() == v.ptr()) return true; // identical
return std::equal(begin(),end(),v.begin());
}

View File

@ -16,13 +16,14 @@ template < class R, class InputIterator >
CGAL_KERNEL_LARGE_INLINE
PlaneCd<R CGAL_CTAG>
plane_from_points(int dim,
const InputIterator &first, const InputIterator &last)
const InputIterator &first, const InputIterator &last,
const R &)
{
CGAL_kernel_precondition(last-first == dim);
typename R::FT *h = new typename R::FT[dim+1];
const typename R::FT **p;
const typename R::FT **q = p = new (const typename R::FT*)[dim];
PointCd<R CGAL_CTAG> *i;
const PointCd<R CGAL_CTAG> *i;
for (i=first; i!=last; ++i,++q) {
CGAL_kernel_precondition( i->dimension() == dim );
*q = i->begin();
@ -38,20 +39,20 @@ plane_from_point_direction(const PointCd<R CGAL_CTAG>& p,
const DirectionCd<R CGAL_CTAG>& d)
{
CGAL_kernel_precondition( p.dimension() == d.dimension() );
typename R::FT e = new typename R::FT[p.dimension()+1];
typename R::FT *e = new typename R::FT[p.dimension()+1];
plane_from_point_directionCd(p.dimension(), p.begin(), p.end(),
d.begin(), d.end(), e);
return PlaneCd<R CGAL_CTAG>(dim, e, e+p.dimension()+1);
return PlaneCd<R CGAL_CTAG>(p.dimension(), e+0, e+p.dimension()+1);
}
template <class R>
CGAL_KERNEL_LARGE_INLINE
PointCd<R CGAL_CTAG>
point_on_plane(const PlaneCd<R CGAL_CTAG>& h, int i)
point_on_plane(const PlaneCd<R CGAL_CTAG>& h, int i = 0)
{
typename R::FT e = new typename R::FT[h.dimension()];
typename R::FT *e = new typename R::FT[h.dimension()];
point_on_planeCd(h.dimension(), h.begin(), h.end(), i, e);
return PointCd<R CGAL_CTAG>(h.dimension(), e, e+h.dimension());
return PointCd<R CGAL_CTAG>(h.dimension(), e+0, e+h.dimension());
}
template <class R>
@ -61,10 +62,10 @@ projection_plane(const PointCd<R CGAL_CTAG>& p,
const PlaneCd<R CGAL_CTAG>& h)
{
CGAL_kernel_precondition( p.dimension() == h.dimension() );
typename R::FT e = new typename R::FT[dim];
typename R::FT *e = new typename R::FT[h.dimension()];
projection_planeCd(h.dimension(), h.begin(), h.end(),
p.begin(), p.end(), e);
return PointCd<R CGAL_CTAG>(h.dimension(), e, e+h.dimension());
return PointCd<R CGAL_CTAG>(h.dimension(), e+0, e+h.dimension());
}
CGAL_END_NAMESPACE

View File

@ -11,7 +11,8 @@ bool
equal_direction(const DirectionCd<R CGAL_CTAG>& d1,
const DirectionCd<R CGAL_CTAG>& d2)
{
return equal_directionCd(d1.begin(),d1.end(),d2.begin(),d2.end());
if (d1.dimension() != d2.dimension()) return false;
return equal_directionCd(d1.begin(),d1.end(),d2.begin());
}
CGAL_END_NAMESPACE

View File

@ -0,0 +1,47 @@
#ifndef CGAL_CONSTRUCTIONS_KERNEL_FTCD_H
#define CGAL_CONSTRUCTIONS_KERNEL_FTCD_H
#include <CGAL/number_utils.h>
#include <CGAL/determinant.h>
#include <CGAL/constructions/kernel_ftCd.h>
#include <algorithm>
CGAL_BEGIN_NAMESPACE
template < class InputIterator, class OutputIterator >
void
plane_from_pointsCd(int dim,
const InputIterator &db, const InputIterator &de,
OutputIterator result)
{
}
template < class InputIterator, class OutputIterator >
void
plane_from_point_directionCd(int dim,
const InputIterator &db1, const InputIterator &de1,
const InputIterator &db2, const InputIterator &de2,
OutputIterator result)
{
}
template < class InputIterator, class OutputIterator >
void
point_on_planeCd(int dim,
const InputIterator &db, const InputIterator &de,
int i, OutputIterator result)
{
}
template < class InputIterator, class OutputIterator >
void
projection_planeCd(int dim,
const InputIterator &hf, const InputIterator &hl,
const InputIterator &pf, const InputIterator &pl,
OutputIterator result)
{
}
CGAL_END_NAMESPACE
#endif // CGAL_CONSTRUCTIONS_KERNEL_FTCD_H

View File

@ -21,10 +21,9 @@ CGAL_KERNEL_LARGE_INLINE
bool
is_positively_proportionalCd(
const InputIterator &db1, const InputIterator &de1,
const InputIterator &db2, const InputIterator &de2)
const InputIterator &db2)
{
typedef typename iterator_traits<InputIterator>::value_type FT;
CGAL_kernel_assertion( de1-db1 == de2-db2 );
InputIterator nz1; // first non-zero position in [db1,de1)
nz1 = std::find_if(db1,de1,bind1st(not_equal_to<FT>(),FT(0)));
CGAL_kernel_assertion( nz1 != de1 );
@ -37,16 +36,25 @@ is_positively_proportionalCd(
return false;
// check that all subsequent positions are proportional
return std::mismatch(nz1+1,de1+0,nz2+1,is_proportional<FT>(*nz1,*nz2))
.first == de1;
.first == de1;
}
template < class InputIterator >
inline
bool
equal_directionCd(const InputIterator &db1, const InputIterator &de1,
const InputIterator &db2, const InputIterator &de2)
const InputIterator &db2)
{
return is_positively_proportionalCd(db1,de1,db2,de2);
return is_positively_proportionalCd(db1,de1,db2);
}
template < class InputIterator >
inline
bool
side_of_oriented_planeCd(const InputIterator &db1, const InputIterator &de1,
const InputIterator &db2)
{
return false; // TODO
}
CGAL_END_NAMESPACE

View File

@ -36,7 +36,7 @@ struct Cartesian_base_dynamic_d
typedef PointCd<R> Point_d;
typedef VectorCd<R> Vector_d;
typedef DirectionCd<R> Direction_d;
typedef Plane_d<R> Plane_d;
typedef PlaneCd<R> Plane_d;
#endif // CGAL_CFG_NO_ADVANCED_KERNEL
};
@ -47,6 +47,7 @@ CGAL_END_NAMESPACE
#include <CGAL/Cartesian/Point_d.h>
#include <CGAL/Cartesian/Vector_d.h>
#include <CGAL/Cartesian/Direction_d.h>
#include <CGAL/Cartesian/Plane_d.h>
#include <CGAL/Cartesian/global_operators_d.h>
#include <CGAL/Cartesian/constructions_on_planes_d.h>
@ -59,6 +60,7 @@ CGAL_END_NAMESPACE
#include <CGAL/Cartesian/Point_d.C>
#include <CGAL/Cartesian/Vector_d.C>
#include <CGAL/Cartesian/Direction_d.C>
#include <CGAL/Cartesian/Plane_d.C>
CGAL_BEGIN_NAMESPACE
@ -86,6 +88,7 @@ struct Cartesian_dynamic_d
typedef typename Kernel_base::Point_d Point_d;
typedef typename Kernel_base::Vector_d Vector_d;
typedef typename Kernel_base::Direction_d Direction_d;
typedef typename Kernel_base::Plane_d Plane_d;
#else
// Now CGAL::Point_d<R> is only a wrapper around CGAL::PointCd<R>
@ -98,6 +101,7 @@ struct Cartesian_dynamic_d
typedef typename Kernel_base::Point_d Point_d_base;
typedef typename Kernel_base::Vector_d Vector_d_base;
typedef typename Kernel_base::Direction_d Direction_d_base;
typedef typename Kernel_base::Plane_d Plane_d_base;
// Note: necessary to qualify Point_d by ::CGAL:: to disambiguate between
// Point_d in the current namespace (nested within CGAL) and
@ -106,6 +110,7 @@ struct Cartesian_dynamic_d
typedef Point_d<Self> Point_d;
typedef Vector_d<Self> Vector_d;
typedef Direction_d<Self> Direction_d;
typedef Plane_d<Self> Plane_d;
// TODO: cleanup
static FT make_FT(const RT & num, const RT& denom) { return num/denom;}

View File

@ -106,6 +106,16 @@ template < class R > class Aff_transformationC3;
template < class R > class PointCd;
template < class R > class VectorCd;
template < class R > class DirectionCd;
template < class R > class PlaneCd;
template < class R > class LineCd;
template < class R > class RayCd;
template < class R > class SegmentCd;
template < class R > class TriangleCd;
template < class R > class TetrahedronCd;
template < class R > class SphereCd;
template < class R > class SimplexCd;
template < class R > class Iso_rectangleCd;
template < class R > class Aff_transformationCd;
CGAL_END_NAMESPACE