Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:15

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 
0035   math_TrigonometricEquationFunction(const Standard_Real A,
0036     const Standard_Real B,
0037     const Standard_Real C,
0038     const Standard_Real D,
0039     const Standard_Real E)
0040     : myAA(A), myBB(B), myCC(C), myDD(D), myEE(E)
0041   {
0042   }
0043 
0044   Standard_Boolean Value(const Standard_Real X, Standard_Real& F) {
0045     Standard_Real CN = cos(X), SN = sin(X);
0046     //-- F= AA*CN*CN+2*BB*CN*SN+CC*CN+DD*SN+EE;
0047     F = CN*(myAA*CN + (myBB + myBB)*SN + myCC) + myDD*SN + myEE;
0048     return Standard_True;
0049   }
0050 
0051   Standard_Boolean Derivative(const Standard_Real X, Standard_Real& D) {
0052     Standard_Real CN = Cos(X), SN = Sin(X);
0053     //-- D = -2*AA*CN*SN+2*BB*(CN*CN-SN*SN)-CC*SN+DD*CN;
0054     D = -myAA*CN*SN + myBB*(CN*CN - SN*SN);
0055     D += D;
0056     D += -myCC*SN + myDD*CN;
0057     return Standard_True;
0058   }
0059 
0060   Standard_Boolean Values(const Standard_Real X, Standard_Real& F, Standard_Real& D) {
0061     Standard_Real CN = Cos(X), SN = Sin(X);
0062     //-- F= AA*CN*CN+2*BB*CN*SN+CC*CN+DD*SN+EE;
0063     //-- D = -2*AA*CN*SN+2*BB*(CN*CN-SN*SN)-CC*SN+DD*CN;
0064     Standard_Real AACN = myAA*CN;
0065     Standard_Real BBSN = myBB*SN;
0066 
0067     F = AACN*CN + BBSN*(CN + CN) + myCC*CN + myDD*SN + myEE;
0068     D = -AACN*SN + myBB*(CN*CN - SN*SN);
0069     D += D;
0070     D += -myCC*SN + myDD*CN;
0071     return Standard_True;
0072   }
0073 };
0074 
0075 #endif // _math_TrigonometricEquationFunction_HeaderFile