Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-09 09:16:06

0001 // Created on: 1991-05-13
0002 // Created by: Laurent Painnot
0003 // Copyright (c) 1991-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _math_TrigonometricEquationFunction_HeaderFile
0018 #define _math_TrigonometricEquationFunction_HeaderFile
0019 
0020 #include <math_FunctionWithDerivative.hxx>
0021 
0022 //! This is function, which corresponds trigonometric equation
0023 //! a*Cos(x)*Cos(x) + 2*b*Cos(x)*Sin(x) + c*Cos(x) + d*Sin(x) + e = 0
0024 //! See class math_TrigonometricFunctionRoots
0025 class math_TrigonometricEquationFunction : public math_FunctionWithDerivative
0026 {
0027   Standard_Real myAA;
0028   Standard_Real myBB;
0029   Standard_Real myCC;
0030   Standard_Real myDD;
0031   Standard_Real myEE;
0032 
0033 public:
0034   math_TrigonometricEquationFunction(const Standard_Real A,
0035                                      const Standard_Real B,
0036                                      const Standard_Real C,
0037                                      const Standard_Real D,
0038                                      const Standard_Real E)
0039       : myAA(A),
0040         myBB(B),
0041         myCC(C),
0042         myDD(D),
0043         myEE(E)
0044   {
0045   }
0046 
0047   Standard_Boolean Value(const Standard_Real X, Standard_Real& F)
0048   {
0049     Standard_Real CN = cos(X), SN = sin(X);
0050     //-- F= AA*CN*CN+2*BB*CN*SN+CC*CN+DD*SN+EE;
0051     F = CN * (myAA * CN + (myBB + myBB) * SN + myCC) + myDD * SN + myEE;
0052     return Standard_True;
0053   }
0054 
0055   Standard_Boolean Derivative(const Standard_Real X, Standard_Real& D)
0056   {
0057     Standard_Real CN = Cos(X), SN = Sin(X);
0058     //-- D = -2*AA*CN*SN+2*BB*(CN*CN-SN*SN)-CC*SN+DD*CN;
0059     D = -myAA * CN * SN + myBB * (CN * CN - SN * SN);
0060     D += D;
0061     D += -myCC * SN + myDD * CN;
0062     return Standard_True;
0063   }
0064 
0065   Standard_Boolean Values(const Standard_Real X, Standard_Real& F, Standard_Real& D)
0066   {
0067     Standard_Real CN = Cos(X), SN = Sin(X);
0068     //-- F= AA*CN*CN+2*BB*CN*SN+CC*CN+DD*SN+EE;
0069     //-- D = -2*AA*CN*SN+2*BB*(CN*CN-SN*SN)-CC*SN+DD*CN;
0070     Standard_Real AACN = myAA * CN;
0071     Standard_Real BBSN = myBB * SN;
0072 
0073     F = AACN * CN + BBSN * (CN + CN) + myCC * CN + myDD * SN + myEE;
0074     D = -AACN * SN + myBB * (CN * CN - SN * SN);
0075     D += D;
0076     D += -myCC * SN + myDD * CN;
0077     return Standard_True;
0078   }
0079 };
0080 
0081 #endif // _math_TrigonometricEquationFunction_HeaderFile