From 9023aaa54241a11175e4d51ede93cfdaaf1876bf Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 7 Apr 2022 10:39:01 +0100 Subject: [PATCH] More code for ORIGIN --- .../CGAL/Cartesian/plane_constructions_3.h | 19 +++++++++++- .../include/CGAL/constructions/kernel_ftC3.h | 16 ++++++++++ .../include/CGAL/Homogeneous/PlaneH3.h | 29 +++++++++++++------ .../include/CGAL/Kernel/function_objects.h | 4 +++ Kernel_23/include/CGAL/Plane_3.h | 3 ++ Nef_S2/include/CGAL/Nef_S2/Sphere_circle.h | 6 ++-- Nef_S2/include/CGAL/Nef_S2/Sphere_direction.h | 4 +-- 7 files changed, 66 insertions(+), 15 deletions(-) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/plane_constructions_3.h b/Cartesian_kernel/include/CGAL/Cartesian/plane_constructions_3.h index ac4ef1519c7..fe9d91a491d 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/plane_constructions_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/plane_constructions_3.h @@ -41,6 +41,23 @@ plane_from_points(const typename R::Point_3 &p, return PlaneC3(a, b, c, d); } + +template +CGAL_KERNEL_LARGE_INLINE +PlaneC3 +plane_from_points(Origin, + const typename R::Point_3 &q, + const typename R::Point_3 &r) +{ + typename R::FT a, b, c, d(0); + plane_from_pointsC3( /* origin, */ + q.x(), q.y(), q.z(), + r.x(), r.y(), r.z(), + a, b, c); + return PlaneC3(a, b, c, d); +} + + template CGAL_KERNEL_LARGE_INLINE PlaneC3 @@ -53,7 +70,7 @@ plane_from_point_direction(const typename R::Point_3 &p, return PlaneC3(A, B, C, D); } - template +template CGAL_KERNEL_LARGE_INLINE PlaneC3 plane_from_point_direction(Origin, diff --git a/Cartesian_kernel/include/CGAL/constructions/kernel_ftC3.h b/Cartesian_kernel/include/CGAL/constructions/kernel_ftC3.h index ac1dced802c..5559de1f5b1 100644 --- a/Cartesian_kernel/include/CGAL/constructions/kernel_ftC3.h +++ b/Cartesian_kernel/include/CGAL/constructions/kernel_ftC3.h @@ -238,6 +238,22 @@ plane_from_pointsC3(const FT &px, const FT &py, const FT &pz, pd = - pa*rx - pb*ry - pc*rz; } + +template +CGAL_KERNEL_MEDIUM_INLINE +void +plane_from_pointsC3( /* origin */ + const FT &qx, const FT &qy, const FT &qz, + const FT &rx, const FT &ry, const FT &rz, + FT &pa, FT &pb, FT &pc /* , zero */ ) +{ + pa = qy*rz - ry*qz; + pb = qz*rx - rz*qx; + pc = qx*ry - rx*qy; +} + + + template CGAL_KERNEL_MEDIUM_INLINE void diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/PlaneH3.h b/Homogeneous_kernel/include/CGAL/Homogeneous/PlaneH3.h index a3f5e33858f..6b05951a064 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/PlaneH3.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/PlaneH3.h @@ -48,6 +48,7 @@ public: PlaneH3() {} PlaneH3(const Point_3&, const Point_3&, const Point_3& ); + PlaneH3(Origin, const Point_3&, const Point_3& ); PlaneH3(const RT& a, const RT& b, const RT& c, const RT& d ); PlaneH3(const Point_3&, const Ray_3& ); @@ -175,6 +176,16 @@ PlaneH3::PlaneH3(const typename PlaneH3::Point_3& p, const typename PlaneH3::Point_3& r) { new_rep(p,q,r); } +template < class R > +CGAL_KERNEL_INLINE +PlaneH3::PlaneH3(Origin, + const typename PlaneH3::Point_3& q, + const typename PlaneH3::Point_3& r) +{ + typename PlaneH3::Point_3 p(0,0,0); + new_rep(p,q,r); +} + template < class R > CGAL_KERNEL_INLINE PlaneH3::PlaneH3(const RT& a, const RT& b, @@ -190,37 +201,37 @@ PlaneH3::PlaneH3(const typename PlaneH3::Point_3& p , template < class R > CGAL_KERNEL_INLINE PlaneH3::PlaneH3(const typename PlaneH3::Point_3& p, - const typename PlaneH3::Segment_3& s) + const typename PlaneH3::Segment_3& s) { new_rep(p, s.source(), s.target() ); } template < class R > CGAL_KERNEL_INLINE PlaneH3::PlaneH3(const typename PlaneH3::Point_3& p , - const typename PlaneH3::Ray_3& r) + const typename PlaneH3::Ray_3& r) { new_rep(p, r.start(), r.start() + r.direction().to_vector() ); } template < class R > CGAL_KERNEL_INLINE PlaneH3::PlaneH3(const typename PlaneH3::Line_3& l , - const typename PlaneH3::Point_3& p) + const typename PlaneH3::Point_3& p) { new_rep(l.point(0), p, l.point(1) ); } template < class R > CGAL_KERNEL_INLINE PlaneH3::PlaneH3(const typename PlaneH3::Segment_3& s, - const typename PlaneH3::Point_3& p) + const typename PlaneH3::Point_3& p) { new_rep(s.source(), p, s.target() ); } template < class R > CGAL_KERNEL_INLINE PlaneH3::PlaneH3(const typename PlaneH3::Ray_3& r, - const typename PlaneH3::Point_3& p) + const typename PlaneH3::Point_3& p) { new_rep(r.start(), p, r.start() + r.direction().to_vector() ); } template < class R > CGAL_KERNEL_INLINE PlaneH3::PlaneH3(const typename PlaneH3::Point_3& p, - const typename PlaneH3::Direction_3& d) + const typename PlaneH3::Direction_3& d) { Vector_3 ov = d.to_vector(); new_rep( ov.hx()*p.hw(), @@ -232,7 +243,7 @@ PlaneH3::PlaneH3(const typename PlaneH3::Point_3& p, template < class R > CGAL_KERNEL_INLINE PlaneH3::PlaneH3(const typename PlaneH3::Point_3& p, - const typename PlaneH3::Vector_3& ov) + const typename PlaneH3::Vector_3& ov) { new_rep( ov.hx()*p.hw(), ov.hy()*p.hw(), @@ -254,8 +265,8 @@ PlaneH3::PlaneH3(Origin, template < class R > CGAL_KERNEL_INLINE PlaneH3::PlaneH3(const typename PlaneH3::Point_3& p, - const typename PlaneH3::Direction_3& d1, - const typename PlaneH3::Direction_3& d2) + const typename PlaneH3::Direction_3& d1, + const typename PlaneH3::Direction_3& d2) { new_rep( p, p + d1.to_vector(), p + d2.to_vector() ); } template < class R > diff --git a/Kernel_23/include/CGAL/Kernel/function_objects.h b/Kernel_23/include/CGAL/Kernel/function_objects.h index acbebba26d5..82242ca5e53 100644 --- a/Kernel_23/include/CGAL/Kernel/function_objects.h +++ b/Kernel_23/include/CGAL/Kernel/function_objects.h @@ -2039,6 +2039,10 @@ namespace CommonKernelFunctors { operator()(Return_base_tag, const Point_3& p, const Point_3& q, const Point_3& r) const { return Rep(p, q, r); } + Rep // Plane_3 + operator()(Return_base_tag, Origin o, const Point_3& q, const Point_3& r) const + { return Rep(o, q, r); } + Rep // Plane_3 operator()(Return_base_tag, const Point_3& p, const Direction_3& d) const { return Rep(p, d); } diff --git a/Kernel_23/include/CGAL/Plane_3.h b/Kernel_23/include/CGAL/Plane_3.h index 9da820ba47f..cc83bd9d13f 100644 --- a/Kernel_23/include/CGAL/Plane_3.h +++ b/Kernel_23/include/CGAL/Plane_3.h @@ -72,6 +72,9 @@ public: Plane_3(const Point_3& p, const Point_3& q, const Point_3& r) : Rep(typename R::Construct_plane_3()(Return_base_tag(), p, q, r)) {} + Plane_3(Origin o, const Point_3& q, const Point_3& r) + : Rep(typename R::Construct_plane_3()(Return_base_tag(), o, q, r)) {} + Plane_3(const Point_3& p, const Direction_3& d) : Rep(typename R::Construct_plane_3()(Return_base_tag(), p, d)) {} diff --git a/Nef_S2/include/CGAL/Nef_S2/Sphere_circle.h b/Nef_S2/include/CGAL/Nef_S2/Sphere_circle.h index c146b3b6e73..df74309f58a 100644 --- a/Nef_S2/include/CGAL/Nef_S2/Sphere_circle.h +++ b/Nef_S2/include/CGAL/Nef_S2/Sphere_circle.h @@ -57,7 +57,7 @@ Sphere_circle() : Base() {} /*{\Mcreate creates some great circle.}*/ Sphere_circle(const Sphere_point& p, const Sphere_point&q) - : Base(Point_3(0,0,0),p,q) + : Base(CGAL::ORIGIN,p,q) /*{\Mcreate creates a great circle through $p$ and $q$. If $p$ and $q$ are not antipodal on $S_2$, then this circle is unique and oriented such that a walk along |\Mvar| meets $p$ just before the shorter segment @@ -104,9 +104,9 @@ Sphere_circle(Sphere_circle c, const Sphere_point& p) { CGAL_assertion(!c.has_on(p)); if ( c.has_on_negative_side(p) ) c=c.opposite(); if ( p == c.orthogonal_pole() ) - *this = Sphere_circle(Base(Point_3(0,0,0),p,CGAL::ORIGIN+c.base1())); + *this = Sphere_circle(Base(CGAL::ORIGIN,p,CGAL::ORIGIN+c.base1())); else - *this = Sphere_circle(Base(Point_3(0,0,0),p,c.orthogonal_pole())); + *this = Sphere_circle(Base(CGAL::ORIGIN,p,c.orthogonal_pole())); } /*{\Moperations 4 2}*/ diff --git a/Nef_S2/include/CGAL/Nef_S2/Sphere_direction.h b/Nef_S2/include/CGAL/Nef_S2/Sphere_direction.h index d6bb4d88b4d..04a44207747 100644 --- a/Nef_S2/include/CGAL/Nef_S2/Sphere_direction.h +++ b/Nef_S2/include/CGAL/Nef_S2/Sphere_direction.h @@ -51,14 +51,14 @@ Sphere_direction(const Sphere_circle& c) : Base(c) {} Sphere_direction(const Sphere_point& p, const Sphere_point&q) - : Base(Point_3(0,0,0),p,q) + : Base(CGAL::ORIGIN,p,q) /*{\Mcreate creates a direction that describes the orientation of the great circle through $p$ and $q$ (oriented such that the segment $pq$ is the shorter one of the two possible ones. \precond $p$ and $q$ are not opposite on $S_2$.}*/ { CGAL_assertion(p!=q.opposite()); Point_3 p4 = CGAL::ORIGIN + ((Base*) this)->orthogonal_vector(); - if ( CGAL::orientation(CGAL::ORIGIN,p,q,p4) != CGAL::POSITIVE ) + if ( R().orientation_3_object()(CGAL::ORIGIN,p,q,p4) != CGAL::POSITIVE ) *this = Sphere_direction(opposite()); }