diff --git a/Packages/H2/changes.txt b/Packages/H2/changes.txt index fd71d60df9c..145a539058c 100644 --- a/Packages/H2/changes.txt +++ b/Packages/H2/changes.txt @@ -1,3 +1,15 @@ +2.86 (11 May 2003) +- In order to get rid of Direction_2 at some point, I have added : + - Line_2(Point_2, Vector_2) ConstructLine_2 + - Ray_2(Point_2, Vector_2) ConstructRay_2 + - Ray_2(Point_2, Line_2) ConstructRay_2 + - Vector_2(Line_2) ConstructVector_2 + - Vector_2(Ray_2) ConstructVector_2 + - Vector_2(Segment_2) ConstructVector_2 + - Vector_2 Line_2.to_vector() + - Vector_2 Ray_2.to_vector() + - Vector_2 Segment_2.to_vector() + 2.85 (9 May 2003) [mh] - Introduce homogeneous kernel functors in their own namespace - Remove some global function calls from the functors diff --git a/Packages/H2/include/CGAL/Homogeneous/LineH2.h b/Packages/H2/include/CGAL/Homogeneous/LineH2.h index 8776b29b420..76c7201cfae 100644 --- a/Packages/H2/include/CGAL/Homogeneous/LineH2.h +++ b/Packages/H2/include/CGAL/Homogeneous/LineH2.h @@ -54,6 +54,7 @@ public: LineH2(const Segment_2& s); LineH2(const Ray_2& r); LineH2(const Point_2& p, const Direction_2& d); + LineH2(const Point_2& p, const Vector_2& v); bool operator==(const LineH2& l) const ; bool operator!=(const LineH2& l) const ; @@ -71,6 +72,7 @@ public: Point_2 point(int i) const; Point_2 projection(const Point_2& p) const; Direction_2 direction() const; + Vector_2 to_vector() const; Oriented_side oriented_side( const Point_2& p ) const; bool has_on( const Point_2& p ) const; bool has_on_boundary( const Point_2& p ) const; @@ -134,6 +136,18 @@ LineH2::LineH2(const typename LineH2::Ray_2& r) p.hx()*q.hy() - p.hy()*q.hx() ) ); } +template < class R > +CGAL_KERNEL_INLINE +LineH2::LineH2(const typename LineH2::Point_2& p, + const typename LineH2::Vector_2& v) +{ + Point_2 q = p + v; + initialize_with( rep ( + p.hy()*q.hw() - p.hw()*q.hy(), + p.hw()*q.hx() - p.hx()*q.hw(), + p.hx()*q.hy() - p.hy()*q.hx() ) ); +} + template < class R > CGAL_KERNEL_INLINE LineH2::LineH2(const typename LineH2::Point_2& p, @@ -199,7 +213,7 @@ template < class R > CGAL_KERNEL_INLINE typename LineH2::Point_2 LineH2::point(int i) const -{ return point() + RT(i) * (direction().to_vector()); } +{ return point() + RT(i) * to_vector(); } template < class R > CGAL_KERNEL_INLINE @@ -213,6 +227,15 @@ LineH2::projection(const typename LineH2::Point_2& p) const a()*l.b() - l.a()*b() ); } +template < class R > +CGAL_KERNEL_INLINE +typename LineH2::Vector_2 +LineH2::to_vector() const +{ + CGAL_kernel_precondition( !is_degenerate() ); + return Vector_2( b(), -a() ); +} + template < class R > CGAL_KERNEL_INLINE typename LineH2::Direction_2 @@ -228,7 +251,7 @@ LineH2 LineH2::transform(const typename LineH2::Aff_transformation_2& t) const { CGAL_kernel_precondition( !is_degenerate() ); - Point_2 p = point() + direction().to_vector(); + Point_2 p = point() + to_vector(); return LineH2( t.transform(point() ), t.transform(p) ); } diff --git a/Packages/H2/include/CGAL/Homogeneous/RayH2.h b/Packages/H2/include/CGAL/Homogeneous/RayH2.h index 5383233af8e..8529bb34d1c 100644 --- a/Packages/H2/include/CGAL/Homogeneous/RayH2.h +++ b/Packages/H2/include/CGAL/Homogeneous/RayH2.h @@ -49,11 +49,19 @@ public: RayH2() : base(rep()) {} + RayH2( const Point_2& sp, const Point_2& secondp) : base(rep(sp, secondp)) {} + RayH2( const Point_2& sp, const Direction_2& d) : base(rep(sp, sp + d.to_vector())) {} + RayH2( const Point_2& sp, const Vector_2& v) + : base(rep(sp, sp + v)) {} + + RayH2( const Point_2& sp, const Line_2& l) + : base(rep(sp, sp + l.to_vector())) {} + bool operator==(const RayH2& r) const; bool operator!=(const RayH2& r) const; @@ -62,6 +70,7 @@ public: const Point_2 & second_point() const; Point_2 point(int i) const; Direction_2 direction() const; + Vector_2 to_vector() const; Line_2 supporting_line() const; RayH2 opposite() const; @@ -87,6 +96,15 @@ const typename RayH2::Point_2 & RayH2::start() const { return source(); } +template < class R > +CGAL_KERNEL_INLINE +typename RayH2::Vector_2 +RayH2::to_vector() const +{ + CGAL_kernel_precondition( !is_degenerate() ); + return second_point() - start(); +} + template < class R > CGAL_KERNEL_INLINE typename RayH2::Direction_2 @@ -95,6 +113,7 @@ RayH2::direction() const CGAL_kernel_precondition( !is_degenerate() ); return Direction_2( second_point() - start() ); } + template < class R > inline const typename RayH2::Point_2 & diff --git a/Packages/H2/include/CGAL/Homogeneous/SegmentH2.h b/Packages/H2/include/CGAL/Homogeneous/SegmentH2.h index 16746832a4a..bb4e9e307f9 100644 --- a/Packages/H2/include/CGAL/Homogeneous/SegmentH2.h +++ b/Packages/H2/include/CGAL/Homogeneous/SegmentH2.h @@ -37,6 +37,7 @@ CGAL_VC7_BUG_PROTECTED typedef typename R_::Point_2 Point_2; typedef typename R_::Line_2 Line_2; typedef typename R_::Direction_2 Direction_2; + typedef typename R_::Vector_2 Vector_2; typedef typename R_::Aff_transformation_2 Aff_transformation_2; typedef Twotuple rep; @@ -81,6 +82,7 @@ public: FT squared_length() const; Direction_2 direction() const; + Vector_2 to_vector() const; Line_2 supporting_line() const; SegmentH2 opposite() const; Bbox_2 bbox() const; @@ -165,6 +167,15 @@ typename SegmentH2::FT SegmentH2::squared_length() const { return (end() - start()) * (end() - start()); } +template < class R > +CGAL_KERNEL_INLINE +typename SegmentH2::Vector_2 +SegmentH2::to_vector() const +{ + CGAL_kernel_precondition( !is_degenerate() ); + return end() - start(); +} + template < class R > CGAL_KERNEL_INLINE typename SegmentH2::Direction_2 diff --git a/Packages/H2/include/CGAL/Homogeneous/VectorH2.h b/Packages/H2/include/CGAL/Homogeneous/VectorH2.h index 1ee0f4f4045..4cce0d95ca4 100644 --- a/Packages/H2/include/CGAL/Homogeneous/VectorH2.h +++ b/Packages/H2/include/CGAL/Homogeneous/VectorH2.h @@ -37,6 +37,9 @@ CGAL_VC7_BUG_PROTECTED typedef typename R_::FT FT; typedef typename R_::RT RT; typedef typename R_::Point_2 Point_2; + typedef typename R_::Segment_2 Segment_2; + typedef typename R_::Ray_2 Ray_2; + typedef typename R_::Line_2 Line_2; typedef typename R_::Direction_2 Direction_2; typedef typename R_::Vector_2 Vector_2; typedef typename R_::Aff_transformation_2 Aff_transformation_2; @@ -53,6 +56,15 @@ public: VectorH2(const Point_2& a, const Point_2& b) : base (b-a) {} + VectorH2(const Segment_2& s) + : base (s.to_vector()) {} + + VectorH2(const Ray_2& r) + : base (r.to_vector()) {} + + VectorH2(const Line_2& l) + : base (l.to_vector()) {} + VectorH2(const Null_vector &) : base ( rep(RT(0), RT(0), RT(1) )) {} diff --git a/Packages/H2/include/CGAL/Homogeneous/function_objects.h b/Packages/H2/include/CGAL/Homogeneous/function_objects.h index 6c0a635104d..ea5729640d2 100644 --- a/Packages/H2/include/CGAL/Homogeneous/function_objects.h +++ b/Packages/H2/include/CGAL/Homogeneous/function_objects.h @@ -1537,6 +1537,7 @@ namespace HomogeneousKernelFunctors { typedef typename K::RT RT; typedef typename K::FT FT; typedef typename K::Point_2 Point_2; + typedef typename K::Vector_2 Vector_2; typedef typename K::Direction_2 Direction_2; typedef typename K::Segment_2 Segment_2; typedef typename K::Ray_2 Ray_2; @@ -1574,6 +1575,15 @@ namespace HomogeneousKernelFunctors { p.hx()*q.hy() - p.hy()*q.hx() ); } + Line_2 + operator()(const Point_2& p, const Vector_2& v) const + { + Point_2 q = p + v; + return Line_2( p.hy()*q.hw() - p.hw()*q.hy(), + p.hw()*q.hx() - p.hx()*q.hw(), + p.hx()*q.hy() - p.hy()*q.hx() ); + } + Line_2 operator()(const Point_2& p, const Direction_2& d) const { @@ -1782,6 +1792,9 @@ namespace HomogeneousKernelFunctors { { typedef typename K::RT RT; typedef typename K::FT FT; + typedef typename K::Segment_2 Segment_2; + typedef typename K::Ray_2 Ray_2; + typedef typename K::Line_2 Line_2; typedef typename K::Vector_2 Vector_2; typedef typename K::Point_2 Point_2; public: @@ -1800,6 +1813,18 @@ namespace HomogeneousKernelFunctors { p.hw()*q.hw() ); } + Vector_2 + operator()( const Segment_2& s) const + { return Vector_2(s); } + + Vector_2 + operator()( const Ray_2& r) const + { return Vector_2(r); } + + Vector_2 + operator()( const Line_2& l) const + { return Vector_2(l); } + Vector_2 operator()( Null_vector) const { return Vector_2(RT(0), RT(0), RT(1)); } @@ -1820,6 +1845,9 @@ namespace HomogeneousKernelFunctors { { typedef typename K::RT RT; typedef typename K::FT FT; + typedef typename K::Segment_3 Segment_3; + typedef typename K::Ray_3 Ray_3; + typedef typename K::Line_3 Line_3; typedef typename K::Vector_3 Vector_3; typedef typename K::Point_3 Point_3; public: @@ -1839,6 +1867,18 @@ namespace HomogeneousKernelFunctors { p.hw()*q.hw() ); } + Vector_3 + operator()( const Segment_3& s) const + { return Vector_3(s); } + + Vector_3 + operator()( const Ray_3& r) const + { return Vector_3(r); } + + Vector_3 + operator()( const Line_3& l) const + { return Vector_3(l); } + Vector_3 operator()( const Null_vector&) const { return Vector_3(RT(0), RT(0), RT(0), RT(1)); }