⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uncertain_functions_on_signs.h

📁 很多二维 三维几何计算算法 C++ 类库
💻 H
字号:
// Copyright (c) 2003  INRIA Sophia-Antipolis (France).// All rights reserved.//// This file is part of CGAL (www.cgal.org); you may redistribute it under// the terms of the Q Public License version 1.0.// See the file LICENSE.QPL distributed with CGAL.//// Licensees holding a valid commercial license may use this file in// accordance with the commercial license agreement provided with the software.//// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.//// $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.3-branch/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/uncertain/uncertain_functions_on_signs.h $// $Id: uncertain_functions_on_signs.h 32596 2006-07-18 14:11:07Z mkaravel $// //// Author(s)     : Menelaos Karavelas <mkaravel@cse.nd.edu>#ifndef CGAL_UNCERTAIN_FUNCTIONS_ON_SIGNS_H#define CGAL_UNCERTAIN_FUNCTIONS_ON_SIGNS_H#include <CGAL/enum.h>#include <CGAL/Uncertain.h>CGAL_BEGIN_NAMESPACE#if 0inlineSignoperator*(const Sign &s1, const Sign &s2){  if ( s1 == ZERO || s2 == ZERO )  return ZERO;  if ( s1 == s2 )  return POSITIVE;  return NEGATIVE;}#endiftemplate < class RT >Uncertain<Sign>uncertain_sign_a_plus_b_x_sqrt_c(const RT &a, const RT &b, const RT &c){  // computes the sign of quantity: a + b * sqrt(c)  CGAL_assertion( !(CGAL::is_negative(c)) );  Uncertain<Sign> sa = CGAL::sign(a);  if ( is_indeterminate(sa) ) {    return Uncertain<Sign>::indeterminate();  }  Uncertain<Sign> sc = CGAL::sign(c);  if ( is_indeterminate(sc) ) {    return Uncertain<Sign>::indeterminate();  }  if ( sc == ZERO )  return sa;  Uncertain<Sign> sb = CGAL::sign(b);  if ( is_indeterminate(sb) ) {    return Uncertain<Sign>::indeterminate();  }  if ( sa == sb )  return sa;  if ( sa == ZERO )  return sb;  Uncertain<Comparison_result> cr =    CGAL::compare( CGAL::square(a), c * CGAL::square(b) );  if ( is_indeterminate(cr) ) {    return Uncertain<Sign>::indeterminate();  }  // these casts are ugly; they should go away  return Sign(Sign(sa) * Comparison_result(cr));}#if 0template < class RT >Signsign_a_x_sqrt_c_plus_b_x_sqrt_d(const RT &a, const RT &b,				const RT &c, const RT &d){  // computes the sign of quantity: a * sqrt(c) + b * sqrt(d)  CGAL_assertion( !(CGAL::is_negative(c)) );  CGAL_assertion( !(CGAL::is_negative(d)) );  Sign sb = CGAL::sign(b);  if ( CGAL::sign(d) == ZERO )  return CGAL::sign(a * c);  if ( CGAL::sign(c) == ZERO )  return sb;  Sign sa = CGAL::sign(a);  if ( sa == sb )  return sa;  if ( sa == ZERO )  return sb;  return Sign( sa * CGAL::compare( CGAL::square(a) * c,				   CGAL::square(b) * d )	       );}template < class RT >Signsign_a_plus_b_x_sqrt_e_plus_c_x_sqrt_f(const RT &a, const RT &b,				       const RT &c, const RT &e,				       const RT &f){  // computes the sign of quantity: a + b * sqrt(e) + c * sqrt(f)    CGAL_assertion( !(CGAL::is_negative(e)) );  CGAL_assertion( !(CGAL::is_negative(f)) );  Sign s_a_plus_b_x_sqrt_e = sign_a_plus_b_x_sqrt_c(a, b, e);  if ( CGAL::sign(f) == ZERO )  return s_a_plus_b_x_sqrt_e;  Sign sc = CGAL::sign(c);  if ( s_a_plus_b_x_sqrt_e == sc )  return sc;  if ( s_a_plus_b_x_sqrt_e == ZERO )  return sc;  return s_a_plus_b_x_sqrt_e *     sign_a_plus_b_x_sqrt_c(CGAL::square(a) + CGAL::square(b) * e			   - CGAL::square(c) * f,			   RT(2) * a * b, e);}template < class RT >Signsign_a_plus_b_x_sqrt_e_plus_c_x_sqrt_f_plus_d_sqrt_e_x_f(const RT &a,							 const RT &b,							 const RT &c,							 const RT &d,							 const RT &e,							 const RT &f){  // computes the sign of quantity:  //           a + b * sqrt(e) + c * sqrt(f) + d * sqrt(e * f)    CGAL_assertion( !(CGAL::is_negative(e)) );  CGAL_assertion( !(CGAL::is_negative(f)) );  Sign s_a_plus_b_sqrt_e = sign_a_plus_b_x_sqrt_c(a, b, e);  Sign s_c_plus_d_sqrt_e = sign_a_plus_b_x_sqrt_c(c, d, e);  if ( s_a_plus_b_sqrt_e == s_c_plus_d_sqrt_e )    return s_a_plus_b_sqrt_e;  if ( s_a_plus_b_sqrt_e == ZERO )    return s_a_plus_b_sqrt_e;  return s_a_plus_b_sqrt_e *    sign_a_plus_b_x_sqrt_c(CGAL::square(a) + CGAL::square(b) * e			   - CGAL::square(c) * f			   - CGAL::square(d) * e * f,			   RT(2) * (a * b - c * d * f),			   e);}#endifCGAL_END_NAMESPACE#endif // CGAL_UNCERTAIN_FUNCTIONS_ON_SIGNS_H

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -