diff --git a/Packages/H3/changes.txt b/Packages/H3/changes.txt index 1d99092c5aa..e5f2620a682 100644 --- a/Packages/H3/changes.txt +++ b/Packages/H3/changes.txt @@ -1,3 +1,16 @@ +2.59 (11 May 2003) +- Add missing functor for Plane_3(Point_3, Vector_3). +- In order to get rid of Direction_3 at some point, I have added : + - Line_3(Point_3, Vector_3) ConstructLine_3 + - Ray_3(Point_3, Vector_3) ConstructRay_3 + - Ray_3(Point_3, Line_3) ConstructRay_3 + - Vector_3(Line_3) ConstructVector_3 + - Vector_3(Ray_3) ConstructVector_3 + - Vector_3(Segment_3) ConstructVector_3 + - Vector_3 Line_3.to_vector() + - Vector_3 Ray_3.to_vector() + - Vector_3 Segment_3.to_vector() + 2.58 (11 April 2003) [af] - bug fix in Iso_cuboid_3 diff --git a/Packages/H3/include/CGAL/Homogeneous/LineH3.h b/Packages/H3/include/CGAL/Homogeneous/LineH3.h index 11f7190a90d..a010f83c088 100644 --- a/Packages/H3/include/CGAL/Homogeneous/LineH3.h +++ b/Packages/H3/include/CGAL/Homogeneous/LineH3.h @@ -30,7 +30,7 @@ CGAL_BEGIN_NAMESPACE template < class R_ > class LineH3 : public R_::template Handle >::type + typename R_::Vector_3> >::type { CGAL_VC7_BUG_PROTECTED typedef typename R_::RT RT; @@ -43,7 +43,7 @@ CGAL_VC7_BUG_PROTECTED typedef typename R_::Vector_3 Vector_3; typedef typename R_::Aff_transformation_3 Aff_transformation_3; - typedef std::pair rep; + typedef std::pair rep; typedef typename R_::template Handle::type base; public: @@ -53,16 +53,19 @@ public: : base(rep()) {} LineH3(const Point_3& p, const Point_3& q) - : base(rep(p, (q - p).direction())) {} + : base(rep(p, q - p)) {} LineH3(const Segment_3& s) - : base(rep(s.start(), s.direction())) {} + : base(rep(s.start(), s.to_vector())) {} LineH3(const Ray_3& r) - : base(rep(r.start(), r.direction())) {} + : base(rep(r.start(), r.to_vector())) {} LineH3(const Point_3& p, const Direction_3& d) - : base(rep(p, d)) {} + : base(rep(p, d.to_vector())) {} + + LineH3(const Point_3& p, const Vector_3& v) + : base(rep(p, v)) {} Plane_3 perpendicular_plane(const Point_3& p) const; LineH3 opposite() const; @@ -70,7 +73,8 @@ public: Point_3 point(int i) const; Point_3 projection(const Point_3& p) const; - const Direction_3 & direction() const; + Direction_3 direction() const; + const Vector_3 & to_vector() const; bool has_on( const Point_3& p ) const; bool is_degenerate() const; @@ -97,11 +101,17 @@ template < class R > CGAL_KERNEL_INLINE typename LineH3::Point_3 LineH3::point(int i) const -{ return point() + RT(i)*direction().to_vector() ; } +{ return point() + RT(i)*to_vector() ; } template < class R > inline -const typename LineH3::Direction_3 & +const typename LineH3::Vector_3 & +LineH3::to_vector() const +{ return Ptr()->second; } + +template < class R > +inline +typename LineH3::Direction_3 LineH3::direction() const { return Ptr()->second; } @@ -109,13 +119,13 @@ template < class R > CGAL_KERNEL_INLINE typename LineH3::Plane_3 LineH3::perpendicular_plane(const typename LineH3::Point_3& p ) const -{ return Plane_3( p, direction() ); } +{ return Plane_3( p, to_vector() ); } template < class R > CGAL_KERNEL_INLINE LineH3 LineH3::opposite() const -{ return LineH3( point(), -direction() ); } +{ return LineH3( point(), -to_vector() ); } template < class R > CGAL_KERNEL_LARGE_INLINE @@ -131,7 +141,7 @@ LineH3::projection(const typename LineH3::Point_3& p) const const RT vy = v.hy(); const RT vz = v.hz(); const RT vw = v.hw(); - Vector_3 dir = direction().to_vector(); + Vector_3 dir = to_vector(); const RT dx = dir.hx(); const RT dy = dir.hy(); const RT dz = dir.hz(); @@ -147,7 +157,7 @@ template < class R > CGAL_KERNEL_INLINE LineH3 LineH3::transform(const typename LineH3::Aff_transformation_3& t) const -{ return LineH3(t.transform(point() ), t.transform(direction() )); } +{ return LineH3(t.transform(point() ), t.transform(to_vector() )); } #ifndef CGAL_NO_OSTREAM_INSERT_LINEH3 @@ -157,11 +167,11 @@ std::ostream &operator<<(std::ostream &os, const LineH3 &l) switch(os.iword(IO::mode)) { case IO::ASCII : - return os << l.point() << ' ' << l.direction(); + return os << l.point() << ' ' << l.to_vector(); case IO::BINARY : - return os << l.point() << l.direction(); + return os << l.point() << l.to_vector(); default: - return os << "LineH3(" << l.point() << ", " << l.direction() << ")"; + return os << "LineH3(" << l.point() << ", " << l.to_vector() << ")"; } } #endif // CGAL_NO_OSTREAM_INSERT_LINEH3 @@ -171,9 +181,9 @@ template < class R > std::istream &operator>>(std::istream &is, LineH3 &l) { typename R::Point_3 p; - typename R::Direction_3 d; - is >> p >> d; - l = LineH3(p, d); + typename R::Vector_3 v; + is >> p >> v; + l = LineH3(p, v); return is; } #endif // CGAL_NO_ISTREAM_EXTRACT_LINEH3 @@ -182,20 +192,20 @@ template < class R > CGAL_KERNEL_INLINE bool LineH3::has_on( const typename LineH3::Point_3& p ) const -{ return collinear(point(), point()+direction().to_vector(), p); } +{ return collinear(point(), point()+to_vector(), p); } template < class R > CGAL_KERNEL_INLINE bool LineH3::is_degenerate() const -{ return direction().is_degenerate(); } +{ return to_vector() == NULL_VECTOR; } template < class R > CGAL_KERNEL_INLINE bool LineH3::operator==(const LineH3& l) const { - return l.direction() == direction() && l.has_on( point() ); + return l.to_vector() == to_vector() && l.has_on( point() ); } CGAL_END_NAMESPACE diff --git a/Packages/H3/include/CGAL/Homogeneous/RayH3.h b/Packages/H3/include/CGAL/Homogeneous/RayH3.h index bc83c09764d..8eddda4acf9 100644 --- a/Packages/H3/include/CGAL/Homogeneous/RayH3.h +++ b/Packages/H3/include/CGAL/Homogeneous/RayH3.h @@ -30,7 +30,7 @@ CGAL_BEGIN_NAMESPACE template < class R_ > class RayH3 : public R_::template Handle >::type + typename R_::Vector_3> >::type { CGAL_VC7_BUG_PROTECTED typedef typename R_::RT RT; @@ -38,9 +38,10 @@ CGAL_VC7_BUG_PROTECTED typedef typename R_::Point_3 Point_3; typedef typename R_::Line_3 Line_3; typedef typename R_::Direction_3 Direction_3; + typedef typename R_::Vector_3 Vector_3; typedef typename R_::Aff_transformation_3 Aff_transformation_3; - typedef std::pair rep; + typedef std::pair rep; typedef typename R_::template Handle::type base; public: @@ -50,16 +51,23 @@ public: : base(rep()) {} RayH3( const Point_3& sp, const Point_3& secondp) - : base(rep(sp, (secondp-sp).direction())) {} + : base(rep(sp, secondp-sp)) {} + + RayH3( const Point_3& sp, const Vector_3& v) + : base(rep(sp, v)) {} RayH3( const Point_3& sp, const Direction_3& d) - : base(rep(sp, d)) {} + : base(rep(sp, d.to_vector())) {} + + RayH3( const Point_3& sp, const Line_3& l) + : base(rep(sp, l.to_vector())) {} const Point_3 & start() const; const Point_3 & source() const; Point_3 second_point() const; Point_3 point(int i) const; - const Direction_3 & direction() const; + Direction_3 direction() const; + const Vector_3 & to_vector() const; Line_3 supporting_line() const; RayH3 opposite() const; RayH3 transform( const Aff_transformation_3 & t) const; @@ -85,18 +93,26 @@ RayH3::start() const template < class R > inline -const typename RayH3::Direction_3 & -RayH3::direction() const +const typename RayH3::Vector_3 & +RayH3::to_vector() const { CGAL_kernel_precondition( !is_degenerate() ); return Ptr()->second; } +template < class R > +inline +typename RayH3::Direction_3 +RayH3::direction() const +{ + return to_vector().direction(); +} + template < class R > CGAL_KERNEL_INLINE typename RayH3::Point_3 RayH3::second_point() const -{ return start() + direction().to_vector(); } +{ return start() + to_vector(); } template < class R > CGAL_KERNEL_INLINE @@ -104,7 +120,7 @@ typename RayH3::Point_3 RayH3::point(int i) const { CGAL_kernel_precondition( i >= 0 ); - return start() + RT(i)*(direction().to_vector() ) ; + return start() + RT(i)*to_vector(); } template < class R > @@ -176,7 +192,7 @@ template < class R > inline bool RayH3::is_degenerate() const -{ return (Ptr()->second).is_degenerate() ; } +{ return to_vector() == NULL_VECTOR; } template < class R > CGAL_KERNEL_INLINE diff --git a/Packages/H3/include/CGAL/Homogeneous/SegmentH3.h b/Packages/H3/include/CGAL/Homogeneous/SegmentH3.h index bb2e8edda30..5610cd98c15 100644 --- a/Packages/H3/include/CGAL/Homogeneous/SegmentH3.h +++ b/Packages/H3/include/CGAL/Homogeneous/SegmentH3.h @@ -36,6 +36,7 @@ CGAL_VC7_BUG_PROTECTED typedef typename R_::FT FT; typedef typename R_::Point_3 Point_3; typedef typename R_::Direction_3 Direction_3; + typedef typename R_::Vector_3 Vector_3; typedef typename R_::Line_3 Line_3; typedef typename R_::Aff_transformation_3 Aff_transformation_3; @@ -63,10 +64,11 @@ public: const Point_3 & operator[](int i) const; FT squared_length() const; - Direction_3 direction() const; - Line_3 supporting_line() const; - SegmentH3 opposite() const; - SegmentH3 transform( const Aff_transformation_3& t) const; + Direction_3 direction() const; + Vector_3 to_vector() const; + Line_3 supporting_line() const; + SegmentH3 opposite() const; + SegmentH3 transform( const Aff_transformation_3& t) const; Bbox_3 bbox() const; bool has_on(const Point_3& p) const; bool collinear_has_on(const Point_3& p) const; @@ -147,6 +149,12 @@ SegmentH3::squared_length() const (end() - start()) ; } +template < class R > +CGAL_KERNEL_INLINE +typename SegmentH3::Vector_3 +SegmentH3::to_vector() const +{ return end() - start(); } + template < class R > CGAL_KERNEL_INLINE typename SegmentH3::Direction_3