BWAPI
|
00001 // Copyright (c) 2005-2006 INRIA Sophia-Antipolis (France). 00002 // All rights reserved. 00003 // 00004 // This file is part of CGAL (www.cgal.org); you may redistribute it under 00005 // the terms of the Q Public License version 1.0. 00006 // See the file LICENSE.QPL distributed with CGAL. 00007 // 00008 // Licensees holding a valid commercial license may use this file in 00009 // accordance with the commercial license agreement provided with the software. 00010 // 00011 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00012 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00013 // 00014 // Partially supported by the IST Programme of the EU as a Shared-cost 00015 // RTD (FET Open) Project under Contract No IST-2000-26473 00016 // (ECG - Effective Computational Geometry for Curves and Surfaces) 00017 // and a STREP (FET Open) Project under Contract No IST-006413 00018 // (ACS -- Algorithms for Complex Shapes) 00019 // 00020 // $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.5-branch/Algebraic_kernel_for_spheres/include/CGAL/Algebraic_kernel_for_spheres/internal_functions_on_roots_and_polynomials_1_3.h $ 00021 // $Id: internal_functions_on_roots_and_polynomials_1_3.h 46224 2008-10-13 11:22:46Z pmachado $ 00022 // 00023 // Author(s) : Monique Teillaud <Monique.Teillaud@sophia.inria.fr> 00024 // Sylvain Pion 00025 // Pedro Machado 00026 00027 #ifndef CGAL_ALGEBRAIC_KERNEL_FUNCTIONS_ON_ROOTS_AND_POLYNOMIALS_1_3_H 00028 #define CGAL_ALGEBRAIC_KERNEL_FUNCTIONS_ON_ROOTS_AND_POLYNOMIALS_1_3_H 00029 00030 namespace CGAL { 00031 namespace AlgebraicSphereFunctors { 00032 00033 template < class AK, class OutputIterator > 00034 inline 00035 OutputIterator 00036 solve( const typename AK::Polynomial_1_3 & e1, 00037 const typename AK::Polynomial_1_3 & e2, 00038 const typename AK::Polynomial_1_3 & e3, 00039 OutputIterator res ) 00040 { 00041 typedef typename AK::RT RT; 00042 typedef typename AK::FT FT; 00043 typedef typename AK::Root_for_spheres_2_3 Root_for_spheres_2_3; 00044 CGAL_kernel_precondition(!(same_solutions<FT>(e1,e2) || same_solutions<FT>(e1,e3) || 00045 same_solutions<FT>(e2,e3))); 00046 const FT &a1 = e1.a(); 00047 const FT &a2 = e2.a(); 00048 const FT &a3 = e3.a(); 00049 const FT &b1 = e1.b(); 00050 const FT &b2 = e2.b(); 00051 const FT &b3 = e3.b(); 00052 const FT &c1 = e1.c(); 00053 const FT &c2 = e2.c(); 00054 const FT &c3 = e3.c(); 00055 const FT &d1 = e1.d(); 00056 const FT &d2 = e2.d(); 00057 const FT &d3 = e3.d(); 00058 FT denominateur = (a1*b2*c3-a1*b3*c2-a2*b1*c3+a2*b3*c1-a3*b2*c1+a3*b1*c2); 00059 //if denominateur == 0 it's because the planes are parallel 00060 if (denominateur == 0) return res; 00061 FT z = -(a2*b3*d1-a1*b3*d2+a1*b2*d3-a3*b2*d1-a2*b1*d3+a3*b1*d2)/denominateur; 00062 FT y = (-a1*d2*c3+a1*c2*d3-a2*c1*d3-a3*c2*d1+a3*c1*d2+a2*c3*d1)/denominateur; 00063 FT x = -(-b1*d2*c3+b1*c2*d3+b3*c1*d2-b2*c1*d3+b2*d1*c3-b3*c2*d1)/denominateur; 00064 *res++ = std::make_pair(Root_for_spheres_2_3(x,y,z), 00065 static_cast<unsigned>(1)); 00066 return res; 00067 } 00068 00069 } 00070 } 00071 00072 #endif //CGAL_ALGEBRAIC_KERNEL_FUNCTIONS_ON_ROOTS_AND_POLYNOMIALS_1_3_H