1 // Created on: 1991-05-27
2 // Created by: Arnaud BOUZY
3 // Copyright (c) 1991-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
23 #include <Expr_ArcCosine.ixx>
24 #include <Expr_NumericValue.hxx>
25 #include <Expr_Cosine.hxx>
26 #include <Expr_Division.hxx>
27 #include <Expr_Square.hxx>
28 #include <Expr_Difference.hxx>
29 #include <Expr_SquareRoot.hxx>
30 #include <Expr_UnaryMinus.hxx>
31 #include <Expr_Product.hxx>
32 #include <Expr_Operators.hxx>
35 Expr_ArcCosine::Expr_ArcCosine (const Handle(Expr_GeneralExpression)& exp)
40 Handle(Expr_GeneralExpression) Expr_ArcCosine::ShallowSimplified () const
42 Handle(Expr_GeneralExpression) op = Operand();
43 if (op->IsKind(STANDARD_TYPE(Expr_NumericValue))) {
44 Handle(Expr_NumericValue) valop = Handle(Expr_NumericValue)::DownCast(op);
45 return new Expr_NumericValue(ACos(valop->GetValue()));
47 if (op->IsKind(STANDARD_TYPE(Expr_Cosine))) {
48 return op->SubExpression(1);
50 Handle(Expr_ArcCosine) me = this;
54 Handle(Expr_GeneralExpression) Expr_ArcCosine::Copy () const
56 return new Expr_ArcCosine(Expr::CopyShare(Operand()));
59 Standard_Boolean Expr_ArcCosine::IsIdentical (const Handle(Expr_GeneralExpression)& Other) const
61 if (!Other->IsKind(STANDARD_TYPE(Expr_ArcCosine))) {
62 return Standard_False;
64 Handle(Expr_GeneralExpression) op = Operand();
65 return op->IsIdentical(Other->SubExpression(1));
68 Standard_Boolean Expr_ArcCosine::IsLinear () const
70 if (ContainsUnknowns()) {
71 return Standard_False;
76 Handle(Expr_GeneralExpression) Expr_ArcCosine::Derivative (const Handle(Expr_NamedUnknown)& X) const
79 return new Expr_NumericValue(0.0);
81 Handle(Expr_GeneralExpression) op = Operand();
82 Handle(Expr_GeneralExpression) derop = op->Derivative(X);
84 Handle(Expr_Square) sq = new Expr_Square(Expr::CopyShare(op));
86 Handle(Expr_Difference) thedif = 1.0 - sq->ShallowSimplified();
88 Handle(Expr_SquareRoot) theroot = new Expr_SquareRoot(thedif->ShallowSimplified());
90 Handle(Expr_UnaryMinus) theder = - (1.0 / theroot->ShallowSimplified());
92 // ArcCosine'(F(X)) = -1/sqrt(1-F(X)2) * F'(X)
94 Handle(Expr_Product) result = theder->ShallowSimplified() * derop;
96 return result->ShallowSimplified();
99 Standard_Real Expr_ArcCosine::Evaluate(const Expr_Array1OfNamedUnknown& vars, const TColStd_Array1OfReal& vals) const
101 return ::ACos(Operand()->Evaluate(vars,vals));
104 TCollection_AsciiString Expr_ArcCosine::String() const
106 TCollection_AsciiString str("ACos(");
107 str += Operand()->String();