-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSmoothShapingCurve.cc
46 lines (39 loc) · 1.06 KB
/
SmoothShapingCurve.cc
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
#include "SmoothShapingCurve.hh"
#include <math.h>
#include <TMath.h>
SmoothShapingCurve::SmoothShapingCurve(double sTime) : ShapingCurve(sTime)
{
ShapingCurve *templateCurve = new ShapingCurve(sTime);
double x[100], y[100];
int i;
for (i=0;i<100;i++)
{
x[i] = 0.1*sTime*(i-20);
y[i] = templateCurve->getHeight(0.1*sTime*(i-20));
}
theSpline = new TSpline3("curve",x,y,100,"");
}
SmoothShapingCurve::SmoothShapingCurve(int ni, double *ti, double *yi) : ShapingCurve(ti[TMath::LocMax(ni, yi)])
{
theSpline = new TSpline3("curve", ti, yi, ni, "b1e1", 0.0, 0.0);
}
SmoothShapingCurve::~SmoothShapingCurve()
{
}
double SmoothShapingCurve::getHeight(double time)
{
return theSpline->Eval(time);
/*
if (time<0) return 0;
else return (time/shapingTime)*exp(1.0-time/shapingTime);
*/
}
double SmoothShapingCurve::getSlope(double time)
{
return theSpline->Derivative(time);
/*
if (time<-0.2*shapingTime) return 0;
else if (time<0) return (1.0+time/(0.2*shapingTime))*exp(1.0)/shapingTime;
else return (1.0-time/shapingTime)*exp(1.0-time/shapingTime)/shapingTime;
*/
}