7fd59977 |
1 | // Copyright: Matra-Datavision 1991 |
2 | // File: Expr_Sine.cxx |
3 | // Created: Tue May 28 13:00:09 1991 |
4 | // Author: Arnaud BOUZY |
5 | // <adn> |
6 | |
7 | #include <Expr_Sine.ixx> |
8 | #include <Expr_NumericValue.hxx> |
9 | #include <Expr_ArcSine.hxx> |
10 | #include <Expr_Cosine.hxx> |
11 | #include <Expr_Product.hxx> |
12 | #include <Expr_Operators.hxx> |
13 | #include <Expr.hxx> |
14 | |
15 | Expr_Sine::Expr_Sine(const Handle(Expr_GeneralExpression)& exp) |
16 | { |
17 | CreateOperand(exp); |
18 | } |
19 | |
20 | Handle(Expr_GeneralExpression) Expr_Sine::ShallowSimplified () const |
21 | { |
22 | Handle(Expr_GeneralExpression) myexp = Operand(); |
23 | if (myexp->IsKind(STANDARD_TYPE(Expr_NumericValue))) { |
24 | Handle(Expr_NumericValue) myNVexp = Handle(Expr_NumericValue)::DownCast(myexp); |
25 | return new Expr_NumericValue(Sin(myNVexp->GetValue())); |
26 | } |
27 | if (myexp->IsKind(STANDARD_TYPE(Expr_ArcSine))) { |
28 | return myexp->SubExpression(1); |
29 | } |
30 | Handle(Expr_Sine) me = this; |
31 | return me; |
32 | } |
33 | |
34 | Handle(Expr_GeneralExpression) Expr_Sine::Copy () const |
35 | { |
36 | return new Expr_Sine(Expr::CopyShare(Operand())); |
37 | } |
38 | |
39 | Standard_Boolean Expr_Sine::IsIdentical (const Handle(Expr_GeneralExpression)& Other) const |
40 | { |
41 | if (Other->IsKind(STANDARD_TYPE(Expr_Sine))) { |
42 | Handle(Expr_GeneralExpression) myexp = Operand(); |
43 | return myexp->IsIdentical(Other->SubExpression(1)); |
44 | } |
45 | return Standard_False; |
46 | } |
47 | |
48 | Standard_Boolean Expr_Sine::IsLinear () const |
49 | { |
50 | return !ContainsUnknowns(); |
51 | } |
52 | |
53 | Handle(Expr_GeneralExpression) Expr_Sine::Derivative (const Handle(Expr_NamedUnknown)& X) const |
54 | { |
55 | if (!Contains(X)) { |
56 | return new Expr_NumericValue(0.0); |
57 | } |
58 | Handle(Expr_GeneralExpression) myexp = Operand(); |
59 | Handle(Expr_GeneralExpression) myder = myexp->Derivative(X); |
60 | Handle(Expr_Cosine) firstder = new Expr_Cosine(Expr::CopyShare(myexp)); |
61 | Handle(Expr_Product) resu = firstder->ShallowSimplified() * myder; |
62 | return resu->ShallowSimplified(); |
63 | } |
64 | |
65 | Standard_Real Expr_Sine::Evaluate(const Expr_Array1OfNamedUnknown& vars, const TColStd_Array1OfReal& vals) const |
66 | { |
67 | return ::Sin(Operand()->Evaluate(vars,vals)); |
68 | } |
69 | |
70 | TCollection_AsciiString Expr_Sine::String() const |
71 | { |
72 | TCollection_AsciiString str("Sin("); |
73 | str += Operand()->String(); |
74 | str += ")"; |
75 | return str; |
76 | } |