1 // Created on: 1991-09-03
2 // Created by: Laurent PAINNOT
3 // Copyright (c) 1991-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16 
17 #ifndef _math_TrigonometricFunctionRoots_HeaderFile
18 #define _math_TrigonometricFunctionRoots_HeaderFile
19 
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23 
24 #include <Standard_Integer.hxx>
25 #include <TColStd_Array1OfReal.hxx>
26 #include <Standard_Boolean.hxx>
27 #include <Standard_Real.hxx>
28 #include <Standard_OStream.hxx>
29 class StdFail_NotDone;
30 class Standard_OutOfRange;
31 class Standard_RangeError;
32 
33 
34 //! This class implements the solutions of the equation
35 //! a*Cos(x)*Cos(x) + 2*b*Cos(x)*Sin(x) + c*Cos(x) + d*Sin(x) + e
36 //! The degree of this equation can be 4, 3 or 2.
37 class math_TrigonometricFunctionRoots
38 {
39 public:
40 
41   DEFINE_STANDARD_ALLOC
42 
43 
44   //! Given coefficients a, b, c, d , e, this constructor
45   //! performs the resolution of the equation above.
46   //! The solutions must be contained in [InfBound, SupBound].
47   //! InfBound and SupBound can be set by default to 0 and 2*PI.
48   Standard_EXPORT math_TrigonometricFunctionRoots(const Standard_Real A, const Standard_Real B, const Standard_Real C, const Standard_Real D, const Standard_Real E, const Standard_Real InfBound, const Standard_Real SupBound);
49 
50   //! Given the two coefficients d and e, it performs
51   //! the resolution of d*sin(x) + e = 0.
52   //! The solutions must be contained in [InfBound, SupBound].
53   //! InfBound and SupBound can be set by default to 0 and 2*PI.
54   Standard_EXPORT math_TrigonometricFunctionRoots(const Standard_Real D, const Standard_Real E, const Standard_Real InfBound, const Standard_Real SupBound);
55 
56   //! Given the three coefficients c, d and e, it performs
57   //! the resolution of c*Cos(x) + d*sin(x) + e = 0.
58   //! The solutions must be contained in [InfBound, SupBound].
59   //! InfBound and SupBound can be set by default to 0 and 2*PI.
60   Standard_EXPORT math_TrigonometricFunctionRoots(const Standard_Real C, const Standard_Real D, const Standard_Real E, const Standard_Real InfBound, const Standard_Real SupBound);
61 
62   //! Returns true if the computations are successful, otherwise returns false.
63     Standard_Boolean IsDone() const;
64 
65   //! Returns true if there is an infinity of roots, otherwise returns false.
66     Standard_Boolean InfiniteRoots() const;
67 
68   //! Returns the solution of range Index.
69   //! An exception is raised if NotDone.
70   //! An exception is raised if Index>NbSolutions.
71   //! An exception is raised if there is an infinity of solutions.
72     Standard_Real Value (const Standard_Integer Index) const;
73 
74   //! Returns the number of solutions found.
75   //! An exception is raised if NotDone.
76   //! An exception is raised if there is an infinity of solutions.
77     Standard_Integer NbSolutions() const;
78 
79   //! Prints information on the current state of the object.
80   Standard_EXPORT void Dump (Standard_OStream& o) const;
81 
82 
83 
84 
85 protected:
86 
87 
88   //! is used by the constructors above.
89   Standard_EXPORT void Perform (const Standard_Real A, const Standard_Real B, const Standard_Real C, const Standard_Real D, const Standard_Real E, const Standard_Real InfBound, const Standard_Real SupBound);
90 
91 
92 
93 
94 private:
95 
96 
97 
98   Standard_Integer NbSol;
99   TColStd_Array1OfReal Sol;
100   Standard_Boolean InfiniteStatus;
101   Standard_Boolean Done;
102 
103 
104 };
105 
106 
107 #include <math_TrigonometricFunctionRoots.lxx>
108 
109 
110 
111 
112 
113 #endif // _math_TrigonometricFunctionRoots_HeaderFile
114