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/Polynomials_1_3.h $ 00021 // $Id: 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 // Julien Hazebrouck 00027 // Damien Leroy 00028 00029 #ifndef CGAL_ALGEBRAIC_KERNEL_POLYNOMIALS_1_3_H 00030 #define CGAL_ALGEBRAIC_KERNEL_POLYNOMIALS_1_3_H 00031 00032 #include <CGAL/enum.h> 00033 00034 CGAL_BEGIN_NAMESPACE 00035 00036 // polynomials of the form aX + +bY + cZ + d 00037 template < typename FT_ > 00038 class Polynomial_1_3 00039 { 00040 FT_ rep[4]; // stores a, b, c, d 00041 00042 public: 00043 00044 typedef FT_ FT; 00045 00046 Polynomial_1_3(){} 00047 00048 Polynomial_1_3(const FT & a, const FT & b, const FT & c, const FT & d) 00049 { 00050 rep[0]=a; 00051 rep[1]=b; 00052 rep[2]=c; 00053 rep[3]=d; 00054 } 00055 00056 const FT & a() const 00057 { return rep[0]; } 00058 00059 const FT & b() const 00060 { return rep[1]; } 00061 00062 const FT & c() const 00063 { return rep[2]; } 00064 00065 const FT & d() const 00066 { return rep[3]; } 00067 00068 bool undefined() const { 00069 return is_zero(a()) && 00070 is_zero(b()) && 00071 is_zero(c()) && 00072 is_zero(d()); 00073 } 00074 00075 bool empty_space() const { 00076 return is_zero(a()) && 00077 is_zero(b()) && 00078 is_zero(c()) && 00079 (!is_zero(d())); 00080 } 00081 }; 00082 00083 template < typename FT > 00084 inline 00085 bool 00086 operator == ( const Polynomial_1_3<FT> & p1, 00087 const Polynomial_1_3<FT> & p2 ) 00088 { 00089 return( (p1.a() == p2.a()) && 00090 (p1.b() == p2.b()) && 00091 (p1.c() == p2.c()) && 00092 (p1.d() == p2.d()) ); 00093 } 00094 00095 template < typename FT > 00096 inline 00097 bool 00098 same_solutions ( const Polynomial_1_3<FT> & p1, 00099 const Polynomial_1_3<FT> & p2 ) 00100 { 00101 if(p1.undefined()) return p2.undefined(); 00102 if(p1.empty_space()) return p2.empty_space(); 00103 if(p2.undefined()) return false; 00104 if(p2.empty_space()) return false; 00105 if(is_zero(p1.a())) { 00106 if(!is_zero(p2.a())) return false; 00107 if(is_zero(p1.b())) { 00108 if(!is_zero(p2.b())) return false; 00109 return p1.c() * p2.d() == p1.d() * p2.c(); 00110 } 00111 return (p2.c() * p1.b() == p1.c() * p2.b()) && 00112 (p2.d() * p1.b() == p1.d() * p2.b()); 00113 } 00114 return (p2.b() * p1.a() == p1.b() * p2.a()) && 00115 (p2.c() * p1.a() == p1.c() * p2.a()) && 00116 (p2.d() * p1.a() == p1.d() * p2.a()); 00117 } 00118 00119 CGAL_END_NAMESPACE 00120 00121 #endif //CGAL_ALGEBRAIC_KERNEL_POLYNOMIALS_1_3_H