diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Sphere_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Sphere_3.h index 824893c0cc3..4ba4266e1ff 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Sphere_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Sphere_3.h @@ -122,7 +122,7 @@ public: Sphere_3 orthogonal_transform(const Aff_transformation_3 &t) const { // FIXME: precond: t.is_orthogonal() (*UNDEFINED*) - Vector_3 vec(FT(1), FT(0)); // unit vector + Vector_3 vec(FT(1), FT(0), FT(0)); // unit vector vec = vec.transform(t); // transformed FT sq_scale = vec.squared_length(); // squared scaling factor diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/SphereH3.h b/Homogeneous_kernel/include/CGAL/Homogeneous/SphereH3.h index 18390528295..497e10b695b 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/SphereH3.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/SphereH3.h @@ -254,6 +254,30 @@ SphereH3::bbox() const maxx.sup(), maxy.sup(), maxz.sup()); } +template +SphereH3 +SphereH3:: +orthogonal_transform(const typename SphereH3::Aff_transformation_3& t) const +{ + typename R::Vector_3 vec( RT(1), RT(0), RT(0) ); // unit vector + vec = vec.transform(t); // transformed + FT sq_scale = FT( vec*vec ); // squared scaling factor + + if ( t.is_even() ) + { + return SphereH3(t.transform(center() ), + sq_scale * squared_radius(), + orientation() ); + } + else + { + return SphereH3(t.transform(center() ), + sq_scale * squared_radius(), + CGAL::opposite( orientation()) ); + } +} + + #ifndef CGAL_NO_OSTREAM_INSERT_SPHEREH3 template < class R > CGAL_KERNEL_INLINE diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_3.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_3.h index c0d05587236..7d7b0a38202 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_3.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_aff_transformation_3.h @@ -85,6 +85,7 @@ _test_cls_aff_transformation_3(const R& ) CGAL::Triangle_3 ttri; CGAL::Tetrahedron_3 tet(p1, p2, p3, p4); CGAL::Tetrahedron_3 ttet; + CGAL::Sphere_3 unit_sphere(CGAL::ORIGIN, 1); CGAL::Aff_transformation_3 ident( CGAL::IDENTITY ); @@ -536,6 +537,10 @@ _test_cls_aff_transformation_3(const R& ) assert( scale11.homogeneous(0,0) == scale11.hm(0,0) ); assert( translate.homogeneous(1,2) == translate.hm(1,2) ); + // orthogonal_transform + assert (unit_sphere.orthogonal_transform(ident) == unit_sphere); + assert (unit_sphere.orthogonal_transform(translate).center() == pnt); + std::cout << "done" << std::endl; return true; }