0022904: Clean up sccsid variables
[occt.git] / src / Expr / Expr_ArcCosine.cxx
CommitLineData
7fd59977 1// Copyright: Matra-Datavision 1991
2// File: Expr_ArcCosine.cxx
3// Created: Mon May 27 10:39:35 1991
4// Author: Arnaud BOUZY
5// <adn>
6
7
8#include <Expr_ArcCosine.ixx>
9#include <Expr_NumericValue.hxx>
10#include <Expr_Cosine.hxx>
11#include <Expr_Division.hxx>
12#include <Expr_Square.hxx>
13#include <Expr_Difference.hxx>
14#include <Expr_SquareRoot.hxx>
15#include <Expr_UnaryMinus.hxx>
16#include <Expr_Product.hxx>
17#include <Expr_Operators.hxx>
18#include <Expr.hxx>
19
20Expr_ArcCosine::Expr_ArcCosine (const Handle(Expr_GeneralExpression)& exp)
21{
22 CreateOperand(exp);
23}
24
25Handle(Expr_GeneralExpression) Expr_ArcCosine::ShallowSimplified () const
26{
27 Handle(Expr_GeneralExpression) op = Operand();
28 if (op->IsKind(STANDARD_TYPE(Expr_NumericValue))) {
29 Handle(Expr_NumericValue) valop = Handle(Expr_NumericValue)::DownCast(op);
30 return new Expr_NumericValue(ACos(valop->GetValue()));
31 }
32 if (op->IsKind(STANDARD_TYPE(Expr_Cosine))) {
33 return op->SubExpression(1);
34 }
35 Handle(Expr_ArcCosine) me = this;
36 return me;
37}
38
39Handle(Expr_GeneralExpression) Expr_ArcCosine::Copy () const
40{
41 return new Expr_ArcCosine(Expr::CopyShare(Operand()));
42}
43
44Standard_Boolean Expr_ArcCosine::IsIdentical (const Handle(Expr_GeneralExpression)& Other) const
45{
46 if (!Other->IsKind(STANDARD_TYPE(Expr_ArcCosine))) {
47 return Standard_False;
48 }
49 Handle(Expr_GeneralExpression) op = Operand();
50 return op->IsIdentical(Other->SubExpression(1));
51}
52
53Standard_Boolean Expr_ArcCosine::IsLinear () const
54{
55 if (ContainsUnknowns()) {
56 return Standard_False;
57 }
58 return Standard_True;
59}
60
61Handle(Expr_GeneralExpression) Expr_ArcCosine::Derivative (const Handle(Expr_NamedUnknown)& X) const
62{
63 if (!Contains(X)) {
64 return new Expr_NumericValue(0.0);
65 }
66 Handle(Expr_GeneralExpression) op = Operand();
67 Handle(Expr_GeneralExpression) derop = op->Derivative(X);
68
69 Handle(Expr_Square) sq = new Expr_Square(Expr::CopyShare(op));
70 // 1 - X2
71 Handle(Expr_Difference) thedif = 1.0 - sq->ShallowSimplified();
72
73 Handle(Expr_SquareRoot) theroot = new Expr_SquareRoot(thedif->ShallowSimplified());
74 // 1/ sqrt(1-X2)
75 Handle(Expr_UnaryMinus) theder = - (1.0 / theroot->ShallowSimplified());
76
77 // ArcCosine'(F(X)) = -1/sqrt(1-F(X)2) * F'(X)
78
79 Handle(Expr_Product) result = theder->ShallowSimplified() * derop;
80
81 return result->ShallowSimplified();
82}
83
84Standard_Real Expr_ArcCosine::Evaluate(const Expr_Array1OfNamedUnknown& vars, const TColStd_Array1OfReal& vals) const
85{
86 return ::ACos(Operand()->Evaluate(vars,vals));
87}
88
89TCollection_AsciiString Expr_ArcCosine::String() const
90{
91 TCollection_AsciiString str("ACos(");
92 str += Operand()->String();
93 str += ")";
94 return str;
95}