From 5fa8a239b044f69bd0c4f9cf6b39f5b319d7ea1f Mon Sep 17 00:00:00 2001 From: Susan Hert Date: Tue, 19 Jun 2001 14:31:24 +0000 Subject: [PATCH] added centroid and Construct_centroid_[23] --- Old_Packages/Doc23/changes.txt | 5 ++- .../Doc23/doc_tex/kernel/Ref/Kernel.tex | 8 +++++ .../Ref/Kernel_Construct_centroid_2.tex | 17 ++++++++++ .../Ref/Kernel_Construct_centroid_3.tex | 17 ++++++++++ .../Doc23/doc_tex/kernel/Ref/centroid.tex | 32 +++++++++++++++++++ Old_Packages/Doc23/doc_tex/kernel/main.tex | 6 ++++ Old_Packages/Kernel_basic/changes.txt | 5 ++- .../include/CGAL/Kernel/function_objects.h | 16 ++++++++++ .../include/CGAL/Kernel_traits_common.h | 4 +++ Old_Packages/Kernel_test/changes.txt | 5 ++- .../include/CGAL/_test_fct_constructions_2.C | 5 +++ .../include/CGAL/_test_fct_constructions_3.C | 5 +++ .../test/Kernel/include/CGAL/_test_new_2.h | 5 +++ .../test/Kernel/include/CGAL/_test_new_3.h | 5 +++ .../_2/include/CGAL/basic_constructions_2.h | 28 ++++++++++++++++ .../_3/include/CGAL/basic_constructions_3.h | 28 ++++++++++++++++ Packages/Cartesian_kernel/changes.txt | 3 ++ .../CGAL/Cartesian/point_constructions_2.h | 25 +++++++++++++++ .../CGAL/Cartesian/point_constructions_3.h | 30 +++++++++++++++++ .../include/CGAL/constructions/kernel_ftC2.h | 25 +++++++++++++++ .../include/CGAL/constructions/kernel_ftC3.h | 25 +++++++++++++++ Packages/H2/changes.txt | 3 ++ .../H2/include/CGAL/basic_constructionsH2.h | 24 ++++++++++++++ Packages/H3/changes.txt | 3 ++ .../H3/include/CGAL/basic_constructionsH3.h | 27 ++++++++++++++++ .../Kernel_23/doc_tex/kernel/Ref/Kernel.tex | 8 +++++ .../Kernel_23/doc_tex/kernel/Ref/centroid.tex | 32 +++++++++++++++++++ Packages/Kernel_23/doc_tex/kernel/main.tex | 6 ++++ .../include/CGAL/Kernel/function_objects.h | 16 ++++++++++ .../include/CGAL/basic_constructions_2.h | 28 ++++++++++++++++ .../include/CGAL/basic_constructions_3.h | 28 ++++++++++++++++ .../test/Kernel/include/CGAL/_test_new_2.h | 5 +++ .../test/Kernel/include/CGAL/_test_new_3.h | 5 +++ 33 files changed, 481 insertions(+), 3 deletions(-) create mode 100644 Old_Packages/Doc23/doc_tex/kernel/Ref/Kernel_Construct_centroid_2.tex create mode 100644 Old_Packages/Doc23/doc_tex/kernel/Ref/Kernel_Construct_centroid_3.tex create mode 100644 Old_Packages/Doc23/doc_tex/kernel/Ref/centroid.tex create mode 100644 Packages/Kernel_23/doc_tex/kernel/Ref/centroid.tex diff --git a/Old_Packages/Doc23/changes.txt b/Old_Packages/Doc23/changes.txt index 44dad3665f3..74a2c442f2a 100644 --- a/Old_Packages/Doc23/changes.txt +++ b/Old_Packages/Doc23/changes.txt @@ -1,4 +1,7 @@ -2.25 (18 June 2001) +2.26 (19 June 2001) +- added centroid and Construct_centroid_[23] + +2.25 (19 June 2001) - Added Bounded_side_2, Bounded_side_3 2.24 (18 June 2001) diff --git a/Old_Packages/Doc23/doc_tex/kernel/Ref/Kernel.tex b/Old_Packages/Doc23/doc_tex/kernel/Ref/Kernel.tex index 57753951850..471ecc6d7cd 100644 --- a/Old_Packages/Doc23/doc_tex/kernel/Ref/Kernel.tex +++ b/Old_Packages/Doc23/doc_tex/kernel/Ref/Kernel.tex @@ -99,6 +99,8 @@ for equality testing. \ccGlue \ccNestedType{Construct_center_2}{} \ccGlue +\ccNestedType{Construct_centroid_2}{} +\ccGlue \ccNestedType{Construct_circumcenter_2}{} \ccGlue \ccNestedType{Construct_bisector_2}{} @@ -303,6 +305,8 @@ If the result type is a number type, the prefix is \ccc{Compute_}: \ccGlue \ccNestedType{Construct_center_3}{} \ccGlue +\ccNestedType{Construct_centroid_3}{} +\ccGlue \ccNestedType{Construct_circumcenter_3}{} \ccGlue \ccNestedType{Construct_cross_product_vector_3}{} @@ -487,6 +491,8 @@ an \ccc{_object} suffix. \ccGlue \ccMemberFunction{Kernel::Construct_midpoint_2 construct_midpoint_2_object() const ;}{} \ccGlue +\ccMemberFunction{Kernel::Construct_centroid_2 construct_centroid_2_object() const ;}{} +\ccGlue \ccMemberFunction{Kernel::Construct_circumcenter_2 construct_circumcenter_2_object() const ;}{} \ccGlue \ccMemberFunction{Kernel::Construct_bisector_2 construct_bisector_2_object() const ;}{} @@ -653,6 +659,8 @@ an \ccc{_object} suffix. \ccGlue \ccMemberFunction{Kernel::Construct_midpoint_3 construct_midpoint_3_object() const ;}{} \ccGlue +\ccMemberFunction{Kernel::Construct_centroid_3 construct_centroid_3_object() const ;}{} +\ccGlue \ccMemberFunction{Kernel::Construct_circumcenter_3 construct_circumcenter_3_object() const ;}{} \ccGlue \ccMemberFunction{Kernel::Construct_cross_product_vector_3 construct_cross_product_vector_3_object() const ;}{} diff --git a/Old_Packages/Doc23/doc_tex/kernel/Ref/Kernel_Construct_centroid_2.tex b/Old_Packages/Doc23/doc_tex/kernel/Ref/Kernel_Construct_centroid_2.tex new file mode 100644 index 00000000000..08af134e25d --- /dev/null +++ b/Old_Packages/Doc23/doc_tex/kernel/Ref/Kernel_Construct_centroid_2.tex @@ -0,0 +1,17 @@ +\begin{ccRefFunctionObjectConcept}{Kernel::Construct_centroid_2} +A model for this must provide: + +\ccCreationVariable{fo} + +\ccMemberFunction{Kernel::Point_2 operator()(const Kernel::Point_2&p, + const Kernel::Point_2&q, + const Kernel::Point_2&r);} + {compute the centroid of the points $p$, $q$, and $r$.} + +\ccMemberFunction{Kernel::Point_2 operator()(const Kernel::Point_2&p, + const Kernel::Point_2&q, + const Kernel::Point_2&r, + const Kernel::Point_2&r);} + {compute the centroid of the points $p$, $q$, $r$ and $s$.} + +\end{ccRefFunctionObjectConcept} diff --git a/Old_Packages/Doc23/doc_tex/kernel/Ref/Kernel_Construct_centroid_3.tex b/Old_Packages/Doc23/doc_tex/kernel/Ref/Kernel_Construct_centroid_3.tex new file mode 100644 index 00000000000..54017a4f55d --- /dev/null +++ b/Old_Packages/Doc23/doc_tex/kernel/Ref/Kernel_Construct_centroid_3.tex @@ -0,0 +1,17 @@ +\begin{ccRefFunctionObjectConcept}{Kernel::Construct_centroid_3} +A model for this must provide: + +\ccCreationVariable{fo} + +\ccMemberFunction{Kernel::Point_3 operator()(const Kernel::Point_3&p, + const Kernel::Point_3&q, + const Kernel::Point_3&r);} + {compute the centroid of the points $p$, $q$, and $r$.} + +\ccMemberFunction{Kernel::Point_3 operator()(const Kernel::Point_3&p, + const Kernel::Point_3&q, + const Kernel::Point_3&r, + const Kernel::Point_3&r);} + {compute the centroid of the points $p$, $q$, $r$ and $s$.} + +\end{ccRefFunctionObjectConcept} diff --git a/Old_Packages/Doc23/doc_tex/kernel/Ref/centroid.tex b/Old_Packages/Doc23/doc_tex/kernel/Ref/centroid.tex new file mode 100644 index 00000000000..6f448fc52a8 --- /dev/null +++ b/Old_Packages/Doc23/doc_tex/kernel/Ref/centroid.tex @@ -0,0 +1,32 @@ +\begin{ccRefFunction}{centroid} +\ccInclude{CGAL/basic_constructions_2.h} + +\ccFunction{Point_2 +centroid( const Point_2& p, + const Point_2& q, + const Point_2& r);} + {compute the centroid of the points $p$, $q$, and $r$.} + +\ccFunction{Point_2 +centroid( const Point_2& p, + const Point_2& q, + const Point_2& r, + const Point_2& s);} + {compute the centroid of the points $p$, $q$, $r$, and $s$.} + +\ccInclude{CGAL/basic_constructions_3.h} + +\ccFunction{Point_3 +centroid( const Point_3& p, + const Point_3& q, + const Point_3& r);} + {compute the centroid of the points $p$, $q$, and $r$.} + +\ccFunction{Point_3 +centroid( const Point_3& p, + const Point_3& q, + const Point_3& r, + const Point_3& s);} + {compute the centroid of the points $p$, $q$, $r$, and $s$.} +\end{ccRefFunction} + diff --git a/Old_Packages/Doc23/doc_tex/kernel/main.tex b/Old_Packages/Doc23/doc_tex/kernel/main.tex index 5f6db2cb7be..4024c7c03ec 100644 --- a/Old_Packages/Doc23/doc_tex/kernel/main.tex +++ b/Old_Packages/Doc23/doc_tex/kernel/main.tex @@ -37,6 +37,8 @@ \KernelRefLayout \input{Ref/cartesian_to_homogeneous.tex} \KernelRefLayout +\input{Ref/centroid.tex} +\KernelRefLayout \input{Ref/Circle_2.tex} \KernelRefLayout \input{Ref/circumcenter.tex} @@ -229,6 +231,10 @@ \KernelRefLayout \input{Ref/Kernel_Construct_center_3.tex} %ck \KernelRefLayout +\input{Ref/Kernel_Construct_centroid_2.tex} %ck +\KernelRefLayout +\input{Ref/Kernel_Construct_centroid_3.tex} %ck +\KernelRefLayout \input{Ref/Kernel_Construct_circle_2.tex} %ck \KernelRefLayout \input{Ref/Kernel_Construct_circumcenter_2.tex} %ck diff --git a/Old_Packages/Kernel_basic/changes.txt b/Old_Packages/Kernel_basic/changes.txt index 24dbcdcb5eb..9726a50d83f 100644 --- a/Old_Packages/Kernel_basic/changes.txt +++ b/Old_Packages/Kernel_basic/changes.txt @@ -1,4 +1,7 @@ -3.42 (18 June 2001) +3.43 (19 June 2001) +- added Construct_centroid_[23] + +3.42 (19 June 2001) - added Bounded_side_2 and Bounded_side_3 to traits 3.41 (18 June 2001) diff --git a/Old_Packages/Kernel_basic/include/CGAL/Kernel/function_objects.h b/Old_Packages/Kernel_basic/include/CGAL/Kernel/function_objects.h index ee1fca020a3..3171d073d3d 100644 --- a/Old_Packages/Kernel_basic/include/CGAL/Kernel/function_objects.h +++ b/Old_Packages/Kernel_basic/include/CGAL/Kernel/function_objects.h @@ -254,6 +254,22 @@ class p_Circumcenter { return circumcenter(p,q,r,s); } }; +template +class p_Centroid +{ + public: + typedef Point result_type; + + Point + operator()(const Point& p, const Point& q, const Point& r) const + { return centroid(p,q,r); } + + Point + operator()(const Point& p, const Point& q, + const Point& r, const Point& s) const + { return centroid(p,q,r,s); } +}; + template class pl_Bisector { diff --git a/Old_Packages/Kernel_basic/include/CGAL/Kernel_traits_common.h b/Old_Packages/Kernel_basic/include/CGAL/Kernel_traits_common.h index 2411374ebcc..863318043b0 100644 --- a/Old_Packages/Kernel_basic/include/CGAL/Kernel_traits_common.h +++ b/Old_Packages/Kernel_basic/include/CGAL/Kernel_traits_common.h @@ -69,6 +69,7 @@ typedef CGALi::Call_perpendicular_to_get typedef CGALi::p_Midpoint Construct_midpoint_2; typedef CGALi::p_Center Construct_center_2; typedef CGALi::p_Circumcenter Construct_circumcenter_2; +typedef CGALi::p_Centroid Construct_centroid_2; typedef CGALi::pl_Bisector Construct_bisector_2; CGAL_Kernel_obj(Construct_point_on_2, construct_point_on_2_object) @@ -93,6 +94,7 @@ CGAL_Kernel_obj(Construct_perpendicular_line_2, CGAL_Kernel_obj(Construct_midpoint_2, construct_midpoint_2_object) CGAL_Kernel_obj(Construct_center_2, construct_center_2_object) CGAL_Kernel_obj(Construct_circumcenter_2, construct_circumcenter_2_object) +CGAL_Kernel_obj(Construct_centroid_2, construct_centroid_2_object) CGAL_Kernel_obj(Construct_bisector_2, construct_bisector_2_object) @@ -285,6 +287,7 @@ typedef CGALi::Call_perpendicular_line_to_get typedef CGALi::p_Midpoint Construct_midpoint_3; typedef CGALi::p_Center Construct_center_3; typedef CGALi::p_Circumcenter Construct_circumcenter_3; +typedef CGALi::p_Centroid Construct_centroid_3; typedef CGALi::v_Cross_product Construct_cross_product_vector_3; typedef CGALi::Call_opposite_to_get Construct_opposite_segment_3; typedef CGALi::Call_opposite_to_get Construct_opposite_ray_3; @@ -317,6 +320,7 @@ CGAL_Kernel_obj(Construct_perpendicular_line_3, CGAL_Kernel_obj(Construct_midpoint_3, construct_midpoint_3_object) CGAL_Kernel_obj(Construct_center_3, construct_center_3_object) CGAL_Kernel_obj(Construct_circumcenter_3, construct_circumcenter_3_object) +CGAL_Kernel_obj(Construct_centroid_3, construct_centroid_3_object) CGAL_Kernel_obj(Construct_cross_product_vector_3, construct_cross_product_vector_3_object) CGAL_Kernel_obj(Construct_opposite_segment_3, diff --git a/Old_Packages/Kernel_test/changes.txt b/Old_Packages/Kernel_test/changes.txt index 870765b69e4..d7503b86435 100644 --- a/Old_Packages/Kernel_test/changes.txt +++ b/Old_Packages/Kernel_test/changes.txt @@ -1,4 +1,7 @@ -3.25 (18 June 2001) +3.26 (19 June 2001) +- added Construct_centroid_[23] and centroid + +3.25 (19 June 2001) - Add Bounded_side_2 and Bounded_side_3 3.24 (13 June 2001) diff --git a/Old_Packages/Kernel_test/test/Kernel/include/CGAL/_test_fct_constructions_2.C b/Old_Packages/Kernel_test/test/Kernel/include/CGAL/_test_fct_constructions_2.C index 7ee9f239093..c7365b57d10 100644 --- a/Old_Packages/Kernel_test/test/Kernel/include/CGAL/_test_fct_constructions_2.C +++ b/Old_Packages/Kernel_test/test/Kernel/include/CGAL/_test_fct_constructions_2.C @@ -55,6 +55,11 @@ _test_fct_constructions_2(const R&) assert( CGAL::circumcenter( pne, pse, pnw) == p); assert( CGAL::circumcenter( psw, pse, pnw) == p); + // centroid + Point pe = p + Vector(RT1, RT0); + assert( CGAL::centroid( pne, pse, pe) == pe); + assert( CGAL::centroid( pne, psw, pse, pnw) == p); + // general position intersection point return true; diff --git a/Old_Packages/Kernel_test/test/Kernel/include/CGAL/_test_fct_constructions_3.C b/Old_Packages/Kernel_test/test/Kernel/include/CGAL/_test_fct_constructions_3.C index 802523d0264..f68ac9e7033 100644 --- a/Old_Packages/Kernel_test/test/Kernel/include/CGAL/_test_fct_constructions_3.C +++ b/Old_Packages/Kernel_test/test/Kernel/include/CGAL/_test_fct_constructions_3.C @@ -65,6 +65,11 @@ _test_fct_constructions_3(const R&) assert( CGAL::circumcenter( p101, p001, p010, p100) == p); assert( CGAL::circumcenter( p001, p000, p110, p100) == p); + // centroid + Point p_11 = p + Vector(RT0, RT1, RT1); + assert( CGAL::centroid( p111, p010, p101, p000) == p); + assert( CGAL::centroid( p111, p_11, p011 ) == p_11); + // projection onto a plane return true; diff --git a/Old_Packages/Kernel_test/test/Kernel/include/CGAL/_test_new_2.h b/Old_Packages/Kernel_test/test/Kernel/include/CGAL/_test_new_2.h index 3c5365d1748..6b9f9316488 100644 --- a/Old_Packages/Kernel_test/test/Kernel/include/CGAL/_test_new_2.h +++ b/Old_Packages/Kernel_test/test/Kernel/include/CGAL/_test_new_2.h @@ -214,6 +214,11 @@ test_new_2(const R& rep) = rep.construct_circumcenter_2_object(); Point_2 tmp13 = construct_circumcenter(p2,p3,p4); + typename R::Construct_centroid_2 construct_centroid + = rep.construct_centroid_2_object(); + tmp13 = construct_centroid(p2,p3,p4); + tmp13 = construct_centroid(p2,p3,p4,p5); + typename R::Construct_bisector_2 construct_bisector = rep.construct_bisector_2_object(); diff --git a/Old_Packages/Kernel_test/test/Kernel/include/CGAL/_test_new_3.h b/Old_Packages/Kernel_test/test/Kernel/include/CGAL/_test_new_3.h index 79fa55b0a23..5944c422407 100644 --- a/Old_Packages/Kernel_test/test/Kernel/include/CGAL/_test_new_3.h +++ b/Old_Packages/Kernel_test/test/Kernel/include/CGAL/_test_new_3.h @@ -230,6 +230,11 @@ test_new_3(const R& rep) = rep.construct_circumcenter_3_object(); tmp4 = construct_circumcenter(p2,p3,p4,p5); + typename R::Construct_centroid_3 construct_centroid + = rep.construct_centroid_3_object(); + tmp4 = construct_centroid(p2,p3,p4); + tmp4 = construct_centroid(p2,p3,p4,p5); + typename R::Construct_cross_product_vector_3 construct_cross_product = rep.construct_cross_product_vector_3_object(); Vector_3 tmp9 = construct_cross_product(v3,v4); diff --git a/Old_Packages/_2/include/CGAL/basic_constructions_2.h b/Old_Packages/_2/include/CGAL/basic_constructions_2.h index a05c43b0fab..c3caf240bf7 100644 --- a/Old_Packages/_2/include/CGAL/basic_constructions_2.h +++ b/Old_Packages/_2/include/CGAL/basic_constructions_2.h @@ -57,6 +57,34 @@ circumcenter( const Point_2& p, static_cast(q), static_cast(r))); } + +template < class R > +inline +Point_2 +centroid( const Point_2& p, + const Point_2& q, + const Point_2& r) +{ + typedef typename R::Point_2_base RPoint_2; + return( centroid( static_cast(p), + static_cast(q), + static_cast(r))); +} + +template < class R > +inline +Point_2 +centroid( const Point_2& p, + const Point_2& q, + const Point_2& r, + const Point_2& s) +{ + typedef typename R::Point_2_base RPoint_2; + return( centroid( static_cast(p), + static_cast(q), + static_cast(r), + static_cast(s))); +} CGAL_END_NAMESPACE #endif // CGAL_BASIC_CONSTRUCTIONS_2_H diff --git a/Old_Packages/_3/include/CGAL/basic_constructions_3.h b/Old_Packages/_3/include/CGAL/basic_constructions_3.h index 9cf7c852219..9d1c08c1a79 100644 --- a/Old_Packages/_3/include/CGAL/basic_constructions_3.h +++ b/Old_Packages/_3/include/CGAL/basic_constructions_3.h @@ -46,6 +46,34 @@ midpoint( const Point_3& p, static_cast(q))); } +template < class R > +inline +Point_3 +centroid( const Point_3& p, + const Point_3& q, + const Point_3& r, + const Point_3& s) +{ + typedef typename R::Point_3_base RPoint_3; + return( centroid( static_cast(p), + static_cast(q), + static_cast(r), + static_cast(s))); +} + +template < class R > +inline +Point_3 +centroid( const Point_3& p, + const Point_3& q, + const Point_3& r) +{ + typedef typename R::Point_3_base RPoint_3; + return( centroid( static_cast(p), + static_cast(q), + static_cast(r))); +} + template < class R > inline Point_3 diff --git a/Packages/Cartesian_kernel/changes.txt b/Packages/Cartesian_kernel/changes.txt index b4b79d027e1..3083fe087f0 100644 --- a/Packages/Cartesian_kernel/changes.txt +++ b/Packages/Cartesian_kernel/changes.txt @@ -1,3 +1,6 @@ +Version 6.19 (19 June 2001) +- added centroid + Version 6.18 (18 June 2001) - Move definition of CGAL_REP_CLASS_DEFINED. diff --git a/Packages/Cartesian_kernel/include/CGAL/Cartesian/point_constructions_2.h b/Packages/Cartesian_kernel/include/CGAL/Cartesian/point_constructions_2.h index 872ca4b7f47..c0cae42a9aa 100644 --- a/Packages/Cartesian_kernel/include/CGAL/Cartesian/point_constructions_2.h +++ b/Packages/Cartesian_kernel/include/CGAL/Cartesian/point_constructions_2.h @@ -50,6 +50,31 @@ circumcenter(const PointC2 &p, return PointC2(x, y); } +template < class R > +inline +PointC2 +centroid(const PointC2 &p, + const PointC2 &q, + const PointC2 &r) +{ + typename R::FT x, y; + centroidC2(p.x(), p.y(), q.x(), q.y(), r.x(), r.y(), x, y); + return PointC2(x, y); +} + +template < class R > +inline +PointC2 +centroid(const PointC2 &p, + const PointC2 &q, + const PointC2 &r, + const PointC2 &s) +{ + typename R::FT x, y; + centroidC2(p.x(), p.y(), q.x(), q.y(), r.x(), r.y(), s.x(), s.y(), x, y); + return PointC2(x, y); +} + template < class R > inline PointC2 diff --git a/Packages/Cartesian_kernel/include/CGAL/Cartesian/point_constructions_3.h b/Packages/Cartesian_kernel/include/CGAL/Cartesian/point_constructions_3.h index edc5a9a27ff..aa2c8316ea1 100644 --- a/Packages/Cartesian_kernel/include/CGAL/Cartesian/point_constructions_3.h +++ b/Packages/Cartesian_kernel/include/CGAL/Cartesian/point_constructions_3.h @@ -39,6 +39,36 @@ midpoint(const PointC3 &p, return PointC3(x, y, z); } +template < class R > +PointC3 +centroid(const PointC3 &p, + const PointC3 &q, + const PointC3 &r, + const PointC3 &s) +{ + typename R::FT x, y, z; + centroidC3(p.x(), p.y(), p.z(), + q.x(), q.y(), q.z(), + r.x(), r.y(), r.z(), + s.x(), s.y(), s.z(), + x, y, z); + return PointC3(x, y, z); +} + +template < class R > +PointC3 +centroid(const PointC3 &p, + const PointC3 &q, + const PointC3 &r) +{ + typename R::FT x, y, z; + centroidC3(p.x(), p.y(), p.z(), + q.x(), q.y(), q.z(), + r.x(), r.y(), r.z(), + x, y, z); + return PointC3(x, y, z); +} + template < class R > PointC3 circumcenter(const PointC3 &p, diff --git a/Packages/Cartesian_kernel/include/CGAL/constructions/kernel_ftC2.h b/Packages/Cartesian_kernel/include/CGAL/constructions/kernel_ftC2.h index 1cb9266167c..d3f3394d670 100644 --- a/Packages/Cartesian_kernel/include/CGAL/constructions/kernel_ftC2.h +++ b/Packages/Cartesian_kernel/include/CGAL/constructions/kernel_ftC2.h @@ -76,6 +76,31 @@ circumcenterC2( const FT &px, const FT &py, y += py; } +template < class FT > +CGAL_KERNEL_MEDIUM_INLINE +void +centroidC2( const FT &px, const FT &py, + const FT &qx, const FT &qy, + const FT &rx, const FT &ry, + FT &x, FT &y) +{ + x = (px + qx + rx)/FT(3); + y = (py + qy + ry)/FT(3); +} + +template < class FT > +CGAL_KERNEL_MEDIUM_INLINE +void +centroidC2( const FT &px, const FT &py, + const FT &qx, const FT &qy, + const FT &rx, const FT &ry, + const FT &sx, const FT &sy, + FT &x, FT &y) +{ + x = (px + qx + rx + sx)/FT(4); + y = (py + qy + ry + sy)/FT(4); +} + template < class FT > inline void diff --git a/Packages/Cartesian_kernel/include/CGAL/constructions/kernel_ftC3.h b/Packages/Cartesian_kernel/include/CGAL/constructions/kernel_ftC3.h index f51d555f963..5d32202f1e3 100644 --- a/Packages/Cartesian_kernel/include/CGAL/constructions/kernel_ftC3.h +++ b/Packages/Cartesian_kernel/include/CGAL/constructions/kernel_ftC3.h @@ -132,6 +132,31 @@ circumcenterC3( const FT &px, const FT &py, const FT &pz, z = sz + num_z*inv; } +template < class FT > +void +centroidC3( const FT &px, const FT &py, const FT &pz, + const FT &qx, const FT &qy, const FT &qz, + const FT &rx, const FT &ry, const FT &rz, + const FT &sx, const FT &sy, const FT &sz, + FT &x, FT &y, FT &z) +{ + x = (px + qx + rx + sx)/FT(4); + y = (py + qy + ry + sy)/FT(4); + z = (pz + qz + rz + sz)/FT(4); +} + +template < class FT > +void +centroidC3( const FT &px, const FT &py, const FT &pz, + const FT &qx, const FT &qy, const FT &qz, + const FT &rx, const FT &ry, const FT &rz, + FT &x, FT &y, FT &z) +{ + x = (px + qx + rx)/FT(3); + y = (py + qy + ry)/FT(3); + z = (pz + qz + rz)/FT(3); +} + template < class FT > CGAL_KERNEL_MEDIUM_INLINE FT diff --git a/Packages/H2/changes.txt b/Packages/H2/changes.txt index 150e77d8def..f966e116e6c 100644 --- a/Packages/H2/changes.txt +++ b/Packages/H2/changes.txt @@ -1,3 +1,6 @@ +2.30 (19 June 2001) +- added centroid + 2.29 (18 June 2001) - Move definition of CGAL_REP_CLASS_DEFINED. diff --git a/Packages/H2/include/CGAL/basic_constructionsH2.h b/Packages/H2/include/CGAL/basic_constructionsH2.h index 8c97d042823..0f803d44616 100644 --- a/Packages/H2/include/CGAL/basic_constructionsH2.h +++ b/Packages/H2/include/CGAL/basic_constructionsH2.h @@ -111,6 +111,30 @@ midpoint( PointH2 const& p, PointH2 const& q ) return( PointH2( hx, hy, hw)); } +template < class R > +CGAL_KERNEL_MEDIUM_INLINE +PointH2 +centroid( const PointH2& p, + const PointH2& q, + const PointH2& r ) +{ + typedef typename R::RT RT; + return PointH2((p.hx() + q.hx() + r.hx())/RT(4), + (p.hy() + q.hy() + r.hy())/RT(4)); +} + +template < class R > +CGAL_KERNEL_MEDIUM_INLINE +PointH2 +centroid( const PointH2& p, + const PointH2& q, + const PointH2& r, + const PointH2& s ) +{ + typedef typename R::RT RT; + return PointH2((p.hx() + q.hx() + r.hx() + s.hx())/RT(4), + (p.hy() + q.hy() + r.hy() + s.hy())/RT(4)); +} template CGAL_KERNEL_LARGE_INLINE diff --git a/Packages/H3/changes.txt b/Packages/H3/changes.txt index eb2d37ef176..72c6c4de146 100644 --- a/Packages/H3/changes.txt +++ b/Packages/H3/changes.txt @@ -1,3 +1,6 @@ +2.29 (19 June 2001) +- added centroid + 2.28 (2 May 2001) - angle() - Fix operator<<(Iso_cuboid_3). diff --git a/Packages/H3/include/CGAL/basic_constructionsH3.h b/Packages/H3/include/CGAL/basic_constructionsH3.h index bb2fd11ddf7..b912651f194 100644 --- a/Packages/H3/include/CGAL/basic_constructionsH3.h +++ b/Packages/H3/include/CGAL/basic_constructionsH3.h @@ -102,6 +102,33 @@ bisector( PointH3 const& p, PointH3 const& q) { return PlaneH3( midpoint(p,q), q-p); } +template +CGAL_KERNEL_MEDIUM_INLINE +PointH3 +centroid( PointH3 const& p, + PointH3 const& q, + PointH3 const& r, + PointH3 const& s) +{ + typedef typename R::RT RT; + return PointH3((p.hx() + q.hx() + r.hx() + s.hx())/RT(4), + (p.hy() + q.hy() + r.hy() + s.hy())/RT(4), + (p.hz() + q.hz() + r.hz() + s.hz())/RT(4)); +} + +template +CGAL_KERNEL_MEDIUM_INLINE +PointH3 +centroid( PointH3 const& p, + PointH3 const& q, + PointH3 const& r) +{ + typedef typename R::RT RT; + return PointH3((p.hx() + q.hx() + r.hx())/RT(4), + (p.hy() + q.hy() + r.hy())/RT(4), + (p.hz() + q.hz() + r.hz())/RT(4)); +} + template PointH3 circumcenter( PointH3 const& p, diff --git a/Packages/Kernel_23/doc_tex/kernel/Ref/Kernel.tex b/Packages/Kernel_23/doc_tex/kernel/Ref/Kernel.tex index 57753951850..471ecc6d7cd 100644 --- a/Packages/Kernel_23/doc_tex/kernel/Ref/Kernel.tex +++ b/Packages/Kernel_23/doc_tex/kernel/Ref/Kernel.tex @@ -99,6 +99,8 @@ for equality testing. \ccGlue \ccNestedType{Construct_center_2}{} \ccGlue +\ccNestedType{Construct_centroid_2}{} +\ccGlue \ccNestedType{Construct_circumcenter_2}{} \ccGlue \ccNestedType{Construct_bisector_2}{} @@ -303,6 +305,8 @@ If the result type is a number type, the prefix is \ccc{Compute_}: \ccGlue \ccNestedType{Construct_center_3}{} \ccGlue +\ccNestedType{Construct_centroid_3}{} +\ccGlue \ccNestedType{Construct_circumcenter_3}{} \ccGlue \ccNestedType{Construct_cross_product_vector_3}{} @@ -487,6 +491,8 @@ an \ccc{_object} suffix. \ccGlue \ccMemberFunction{Kernel::Construct_midpoint_2 construct_midpoint_2_object() const ;}{} \ccGlue +\ccMemberFunction{Kernel::Construct_centroid_2 construct_centroid_2_object() const ;}{} +\ccGlue \ccMemberFunction{Kernel::Construct_circumcenter_2 construct_circumcenter_2_object() const ;}{} \ccGlue \ccMemberFunction{Kernel::Construct_bisector_2 construct_bisector_2_object() const ;}{} @@ -653,6 +659,8 @@ an \ccc{_object} suffix. \ccGlue \ccMemberFunction{Kernel::Construct_midpoint_3 construct_midpoint_3_object() const ;}{} \ccGlue +\ccMemberFunction{Kernel::Construct_centroid_3 construct_centroid_3_object() const ;}{} +\ccGlue \ccMemberFunction{Kernel::Construct_circumcenter_3 construct_circumcenter_3_object() const ;}{} \ccGlue \ccMemberFunction{Kernel::Construct_cross_product_vector_3 construct_cross_product_vector_3_object() const ;}{} diff --git a/Packages/Kernel_23/doc_tex/kernel/Ref/centroid.tex b/Packages/Kernel_23/doc_tex/kernel/Ref/centroid.tex new file mode 100644 index 00000000000..6f448fc52a8 --- /dev/null +++ b/Packages/Kernel_23/doc_tex/kernel/Ref/centroid.tex @@ -0,0 +1,32 @@ +\begin{ccRefFunction}{centroid} +\ccInclude{CGAL/basic_constructions_2.h} + +\ccFunction{Point_2 +centroid( const Point_2& p, + const Point_2& q, + const Point_2& r);} + {compute the centroid of the points $p$, $q$, and $r$.} + +\ccFunction{Point_2 +centroid( const Point_2& p, + const Point_2& q, + const Point_2& r, + const Point_2& s);} + {compute the centroid of the points $p$, $q$, $r$, and $s$.} + +\ccInclude{CGAL/basic_constructions_3.h} + +\ccFunction{Point_3 +centroid( const Point_3& p, + const Point_3& q, + const Point_3& r);} + {compute the centroid of the points $p$, $q$, and $r$.} + +\ccFunction{Point_3 +centroid( const Point_3& p, + const Point_3& q, + const Point_3& r, + const Point_3& s);} + {compute the centroid of the points $p$, $q$, $r$, and $s$.} +\end{ccRefFunction} + diff --git a/Packages/Kernel_23/doc_tex/kernel/main.tex b/Packages/Kernel_23/doc_tex/kernel/main.tex index 5f6db2cb7be..4024c7c03ec 100644 --- a/Packages/Kernel_23/doc_tex/kernel/main.tex +++ b/Packages/Kernel_23/doc_tex/kernel/main.tex @@ -37,6 +37,8 @@ \KernelRefLayout \input{Ref/cartesian_to_homogeneous.tex} \KernelRefLayout +\input{Ref/centroid.tex} +\KernelRefLayout \input{Ref/Circle_2.tex} \KernelRefLayout \input{Ref/circumcenter.tex} @@ -229,6 +231,10 @@ \KernelRefLayout \input{Ref/Kernel_Construct_center_3.tex} %ck \KernelRefLayout +\input{Ref/Kernel_Construct_centroid_2.tex} %ck +\KernelRefLayout +\input{Ref/Kernel_Construct_centroid_3.tex} %ck +\KernelRefLayout \input{Ref/Kernel_Construct_circle_2.tex} %ck \KernelRefLayout \input{Ref/Kernel_Construct_circumcenter_2.tex} %ck diff --git a/Packages/Kernel_23/include/CGAL/Kernel/function_objects.h b/Packages/Kernel_23/include/CGAL/Kernel/function_objects.h index ee1fca020a3..3171d073d3d 100644 --- a/Packages/Kernel_23/include/CGAL/Kernel/function_objects.h +++ b/Packages/Kernel_23/include/CGAL/Kernel/function_objects.h @@ -254,6 +254,22 @@ class p_Circumcenter { return circumcenter(p,q,r,s); } }; +template +class p_Centroid +{ + public: + typedef Point result_type; + + Point + operator()(const Point& p, const Point& q, const Point& r) const + { return centroid(p,q,r); } + + Point + operator()(const Point& p, const Point& q, + const Point& r, const Point& s) const + { return centroid(p,q,r,s); } +}; + template class pl_Bisector { diff --git a/Packages/Kernel_23/include/CGAL/basic_constructions_2.h b/Packages/Kernel_23/include/CGAL/basic_constructions_2.h index a05c43b0fab..c3caf240bf7 100644 --- a/Packages/Kernel_23/include/CGAL/basic_constructions_2.h +++ b/Packages/Kernel_23/include/CGAL/basic_constructions_2.h @@ -57,6 +57,34 @@ circumcenter( const Point_2& p, static_cast(q), static_cast(r))); } + +template < class R > +inline +Point_2 +centroid( const Point_2& p, + const Point_2& q, + const Point_2& r) +{ + typedef typename R::Point_2_base RPoint_2; + return( centroid( static_cast(p), + static_cast(q), + static_cast(r))); +} + +template < class R > +inline +Point_2 +centroid( const Point_2& p, + const Point_2& q, + const Point_2& r, + const Point_2& s) +{ + typedef typename R::Point_2_base RPoint_2; + return( centroid( static_cast(p), + static_cast(q), + static_cast(r), + static_cast(s))); +} CGAL_END_NAMESPACE #endif // CGAL_BASIC_CONSTRUCTIONS_2_H diff --git a/Packages/Kernel_23/include/CGAL/basic_constructions_3.h b/Packages/Kernel_23/include/CGAL/basic_constructions_3.h index 9cf7c852219..9d1c08c1a79 100644 --- a/Packages/Kernel_23/include/CGAL/basic_constructions_3.h +++ b/Packages/Kernel_23/include/CGAL/basic_constructions_3.h @@ -46,6 +46,34 @@ midpoint( const Point_3& p, static_cast(q))); } +template < class R > +inline +Point_3 +centroid( const Point_3& p, + const Point_3& q, + const Point_3& r, + const Point_3& s) +{ + typedef typename R::Point_3_base RPoint_3; + return( centroid( static_cast(p), + static_cast(q), + static_cast(r), + static_cast(s))); +} + +template < class R > +inline +Point_3 +centroid( const Point_3& p, + const Point_3& q, + const Point_3& r) +{ + typedef typename R::Point_3_base RPoint_3; + return( centroid( static_cast(p), + static_cast(q), + static_cast(r))); +} + template < class R > inline Point_3 diff --git a/Packages/Kernel_23/test/Kernel/include/CGAL/_test_new_2.h b/Packages/Kernel_23/test/Kernel/include/CGAL/_test_new_2.h index 3c5365d1748..6b9f9316488 100644 --- a/Packages/Kernel_23/test/Kernel/include/CGAL/_test_new_2.h +++ b/Packages/Kernel_23/test/Kernel/include/CGAL/_test_new_2.h @@ -214,6 +214,11 @@ test_new_2(const R& rep) = rep.construct_circumcenter_2_object(); Point_2 tmp13 = construct_circumcenter(p2,p3,p4); + typename R::Construct_centroid_2 construct_centroid + = rep.construct_centroid_2_object(); + tmp13 = construct_centroid(p2,p3,p4); + tmp13 = construct_centroid(p2,p3,p4,p5); + typename R::Construct_bisector_2 construct_bisector = rep.construct_bisector_2_object(); diff --git a/Packages/Kernel_23/test/Kernel/include/CGAL/_test_new_3.h b/Packages/Kernel_23/test/Kernel/include/CGAL/_test_new_3.h index 79fa55b0a23..5944c422407 100644 --- a/Packages/Kernel_23/test/Kernel/include/CGAL/_test_new_3.h +++ b/Packages/Kernel_23/test/Kernel/include/CGAL/_test_new_3.h @@ -230,6 +230,11 @@ test_new_3(const R& rep) = rep.construct_circumcenter_3_object(); tmp4 = construct_circumcenter(p2,p3,p4,p5); + typename R::Construct_centroid_3 construct_centroid + = rep.construct_centroid_3_object(); + tmp4 = construct_centroid(p2,p3,p4); + tmp4 = construct_centroid(p2,p3,p4,p5); + typename R::Construct_cross_product_vector_3 construct_cross_product = rep.construct_cross_product_vector_3_object(); Vector_3 tmp9 = construct_cross_product(v3,v4);