0022048: Visualization, AIS_InteractiveContext - single object selection should alway...
[occt.git] / src / CSLib / CSLib_NormalPolyDef.cxx
CommitLineData
b311480e 1// Created on: 1996-08-23
2// Created by: Benoit TANNIOU
3// Copyright (c) 1996-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
42cf5bc1 17
18#include <CSLib_NormalPolyDef.hxx>
7fd59977 19#include <PLib.hxx>
20
21//=============================================================================
22CSLib_NormalPolyDef::CSLib_NormalPolyDef(const Standard_Integer k0,
23 const TColStd_Array1OfReal& li)
24//=============================================================================
25 :myTABli(0,k0)
26{
27 myK0=k0;
28 for(Standard_Integer i=0;i<=k0;i++)
29 myTABli(i)=li(i);
30}
31
32//=============================================================================
33Standard_Boolean CSLib_NormalPolyDef::Value(const Standard_Real X,
34 Standard_Real& F)
35//=============================================================================
36{
37 F=0.0;
38 Standard_Real co,si;
39 co=cos(X);
40 si=sin(X);
7fd59977 41
f4dee9bb 42 if(Abs(co) <= RealSmall() || Abs(si) <= RealSmall())
43 {
44 F = 0.;
45 return Standard_True;
46 }
7fd59977 47 for(Standard_Integer i=0;i<=myK0;i++){
48 F=F+PLib::Bin(myK0,i)*pow(co,i)*pow(si,(myK0-i))*myTABli(i);
49 }
50 return Standard_True;
51}
52
53//=============================================================================
54Standard_Boolean CSLib_NormalPolyDef::Derivative(const Standard_Real X,
55 Standard_Real& D)
56//=============================================================================
57{
58 D=0.0;
59 Standard_Real co,si;
60 co=cos(X);
61 si=sin(X);
f4dee9bb 62 if(Abs(co) <= RealSmall() || Abs(si) <= RealSmall())
63 {
64 D = 0.;
65 return Standard_True;
66 }
7fd59977 67 for(Standard_Integer i=0;i<=myK0;i++){
68 D=D+PLib::Bin(myK0,i)*pow(co,(i-1))*pow(si,(myK0-i-1))*(myK0*co*co-i);
69 }
70 return Standard_True;
71}
72
73//=============================================================================
74Standard_Boolean CSLib_NormalPolyDef::Values(const Standard_Real X,
75 Standard_Real& F,
76 Standard_Real& D)
77//=============================================================================
78{
79 F=0;
80 D=0;
81 Standard_Real co,si;
82 co=cos(X);
83 si=sin(X);
f4dee9bb 84 if(Abs(co) <= RealSmall() || Abs(si) <= RealSmall())
85 {
86 F = 0.;
87 D = 0.;
88 return Standard_True;
89 }
7fd59977 90 for(Standard_Integer i=0;i<=myK0;i++){
91 F=F+PLib::Bin(myK0,i)*pow(co,i)*pow(si,(myK0-i))*myTABli(i);
92 D=D+PLib::Bin(myK0,i)*pow(co,(i-1))*
93 pow(si,(myK0-i-1))*(myK0*co*co-i)*myTABli(i);
94 }
95 return Standard_True;
96}
97
98
99
100
101