1 // Created on: 1991-05-13
2 // Created by: Laurent Painnot
3 // Copyright (c) 1991-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _math_TrigonometricEquationFunction_HeaderFile
18 #define _math_TrigonometricEquationFunction_HeaderFile
20 #include <math_FunctionWithDerivative.hxx>
22 //! This is function, which corresponds trigonometric equation
23 //! a*Cos(x)*Cos(x) + 2*b*Cos(x)*Sin(x) + c*Cos(x) + d*Sin(x) + e = 0
24 //! See class math_TrigonometricFunctionRoots
25 class math_TrigonometricEquationFunction : public math_FunctionWithDerivative
35 math_TrigonometricEquationFunction(const Standard_Real A,
36 const Standard_Real B,
37 const Standard_Real C,
38 const Standard_Real D,
39 const Standard_Real E)
40 : myAA(A), myBB(B), myCC(C), myDD(D), myEE(E)
44 Standard_Boolean Value(const Standard_Real X, Standard_Real& F) {
45 Standard_Real CN = cos(X), SN = sin(X);
46 //-- F= AA*CN*CN+2*BB*CN*SN+CC*CN+DD*SN+EE;
47 F = CN*(myAA*CN + (myBB + myBB)*SN + myCC) + myDD*SN + myEE;
51 Standard_Boolean Derivative(const Standard_Real X, Standard_Real& D) {
52 Standard_Real CN = Cos(X), SN = Sin(X);
53 //-- D = -2*AA*CN*SN+2*BB*(CN*CN-SN*SN)-CC*SN+DD*CN;
54 D = -myAA*CN*SN + myBB*(CN*CN - SN*SN);
56 D += -myCC*SN + myDD*CN;
60 Standard_Boolean Values(const Standard_Real X, Standard_Real& F, Standard_Real& D) {
61 Standard_Real CN = Cos(X), SN = Sin(X);
62 //-- F= AA*CN*CN+2*BB*CN*SN+CC*CN+DD*SN+EE;
63 //-- D = -2*AA*CN*SN+2*BB*(CN*CN-SN*SN)-CC*SN+DD*CN;
64 Standard_Real AACN = myAA*CN;
65 Standard_Real BBSN = myBB*SN;
67 F = AACN*CN + BBSN*(CN + CN) + myCC*CN + myDD*SN + myEE;
68 D = -AACN*SN + myBB*(CN*CN - SN*SN);
70 D += -myCC*SN + myDD*CN;
75 #endif // _math_TrigonometricEquationFunction_HeaderFile