summaryrefslogtreecommitdiff
path: root/src/GeomLib/GeomLib_PolyFunc.cxx
blob: 9ee8fd550c535ce2347fa417e17f7b167eca5797 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// File:	GeomLib_PolyFunc.cxx
// Created:	Tue Sep 22 16:37:48 1998
// Author:	Philippe MANGIN
//		<pmn@sgi29>


#include <GeomLib_PolyFunc.ixx>
#include <PLib.hxx>
#include <math_Vector.hxx>

GeomLib_PolyFunc::GeomLib_PolyFunc(const math_Vector& Coeffs) 
                                  :myCoeffs(1, Coeffs.Length()-1)
{ // On construit le polynome derive
  for (Standard_Integer ii=1; ii<=myCoeffs.Length(); ii++)
    myCoeffs(ii) = ii*Coeffs(ii+1);
}

 Standard_Boolean GeomLib_PolyFunc::Value(const Standard_Real X,
					  Standard_Real& F) 
{
  Standard_Real * coeff = &myCoeffs(1);
  Standard_Real * ff = &F;
  PLib::EvalPolynomial(X, 0, myCoeffs.Length()-1, 1,  coeff[0], ff[0]);
  return Standard_True;
}

 Standard_Boolean GeomLib_PolyFunc::Derivative(const Standard_Real X,
					       Standard_Real& D) 
{
  Standard_Real * coeff = &myCoeffs(1);
  math_Vector Aux(1, 2);
  Standard_Real * ff = &Aux(1);  
  PLib::EvalPolynomial(X, 1, myCoeffs.Length()-1, 1,  coeff[0], ff[0]);
  D = Aux(2);
  return Standard_True;
}

 Standard_Boolean GeomLib_PolyFunc::Values(const Standard_Real X,
					   Standard_Real& F,
					   Standard_Real& D) 
{
 Standard_Real * coeff = &myCoeffs(1);
 math_Vector Aux(1, 2);
 Standard_Real * ff = &Aux(1);  
 PLib::EvalPolynomial(X, 1, myCoeffs.Length()-1, 1,  coeff[0], ff[0]);
 F = Aux(1);
 D = Aux(2);
 return Standard_True;
}