mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
*ScatterDraw: Fixed Spline.
git-svn-id: svn://ultimatepp.org/upp/trunk@10777 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
a24b30a914
commit
1f54e4594e
6 changed files with 42 additions and 14 deletions
|
|
@ -311,6 +311,7 @@ bool DataSource::SinEstim_FreqPhase(double &frequency, double &phase, double avg
|
|||
phase = -frequency*firstZero;
|
||||
if (!firstIsToPositive)
|
||||
phase += M_PI;
|
||||
phase = phase - 2*M_PI*int(phase/(2*M_PI));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -357,13 +358,25 @@ Vector<Pointf> DataSource::FFT(Getdatafun getdata, double tSample, bool frequenc
|
|||
} catch(...) {
|
||||
return res;
|
||||
}
|
||||
double threshold = 0;
|
||||
if (type == T_PHASE) {
|
||||
for (int i = 0; i < int(freqbuf.size()); ++i) {
|
||||
if (threshold < std::abs(freqbuf[i]))
|
||||
threshold = std::abs(freqbuf[i]);
|
||||
}
|
||||
}
|
||||
threshold /= 10000.;
|
||||
if (frequency) {
|
||||
for (int i = 0; i < int(freqbuf.size()); ++i) {
|
||||
double xdata = i/(tSample*numData);
|
||||
|
||||
switch (type) {
|
||||
case T_PHASE: res << Pointf(xdata, std::arg(freqbuf[i])); break;
|
||||
case T_FFT: res << Pointf(xdata, 2*std::abs(freqbuf[i])/windowSum); break;
|
||||
case T_PHASE: if (std::abs(freqbuf[i]) > threshold)
|
||||
res << Pointf(xdata, std::arg(freqbuf[i]));
|
||||
else
|
||||
res << Pointf(xdata, 0);
|
||||
break;
|
||||
case T_FFT: res << Pointf(xdata, 2*std::abs(freqbuf[i])/windowSum); break;
|
||||
case T_PSD: res << Pointf(xdata, 2*sqr(std::abs(freqbuf[i]))/(windowSum/tSample));
|
||||
}
|
||||
}
|
||||
|
|
@ -372,8 +385,12 @@ Vector<Pointf> DataSource::FFT(Getdatafun getdata, double tSample, bool frequenc
|
|||
double xdata = (tSample*numData)/i;
|
||||
|
||||
switch (type) {
|
||||
case T_PHASE: res << Pointf(xdata, std::arg(freqbuf[i])); break;
|
||||
case T_FFT: res << Pointf(xdata, 2*std::abs(freqbuf[i])/windowSum); break;
|
||||
case T_PHASE: if (std::abs(freqbuf[i]) > threshold)
|
||||
res << Pointf(xdata, std::arg(freqbuf[i]));
|
||||
else
|
||||
res << Pointf(xdata, 0);
|
||||
break;
|
||||
case T_FFT: res << Pointf(xdata, 2*std::abs(freqbuf[i])/windowSum); break;
|
||||
case T_PSD: res << Pointf(xdata, 2*sqr(std::abs(freqbuf[i]))/(windowSum/tSample));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ public:
|
|||
|
||||
class CArray : public DataSource {
|
||||
private:
|
||||
double *xData, *yData, *zData;
|
||||
double *yData, *xData, *zData;
|
||||
int64 numData;
|
||||
double x0, deltaX;
|
||||
|
||||
|
|
|
|||
|
|
@ -347,17 +347,21 @@ ExplicitEquation::FitError SplineEquation::Fit(DataSource &data, double &r2)
|
|||
}
|
||||
|
||||
if(seriesRaw.IsEmpty())
|
||||
return InadequateDataSource;
|
||||
return SmallDataSource;
|
||||
|
||||
PointfLess less;
|
||||
Sort(seriesRaw, less); // Sort
|
||||
|
||||
Vector<Pointf> series;
|
||||
series << seriesRaw[0];
|
||||
for (int i = 1; i < seriesRaw.GetCount(); ++i) { // Remove points with duplicate x
|
||||
if (seriesRaw[i].x != seriesRaw[i - 1].x)
|
||||
series << seriesRaw[i];
|
||||
}
|
||||
|
||||
|
||||
if (series.GetCount() < 2)
|
||||
return SmallDataSource;
|
||||
|
||||
r2 = 0;
|
||||
|
||||
int n = int(series.GetCount()) - 1;
|
||||
|
|
@ -368,7 +372,7 @@ ExplicitEquation::FitError SplineEquation::Fit(DataSource &data, double &r2)
|
|||
|
||||
Buffer<double> alpha(n);
|
||||
for(int i = 1; i < n; ++i)
|
||||
alpha[i] = (3.*(series[i+1].y - series[i].y)/h[i] - 3*(series[i].y - series[i-1].y)/h[i-1]);
|
||||
alpha[i] = 3*(series[i+1].y - series[i].y)/h[i] - 3*(series[i].y - series[i-1].y)/h[i-1];
|
||||
|
||||
Buffer<double> c(n+1), l(n+1), mu(n+1), z(n+1);
|
||||
l[0] = 1;
|
||||
|
|
@ -381,7 +385,7 @@ ExplicitEquation::FitError SplineEquation::Fit(DataSource &data, double &r2)
|
|||
z[i] = (alpha[i] - h[i-1]*z[i-1])/l[i];
|
||||
}
|
||||
|
||||
l[n] = 1.;
|
||||
l[n] = 1;
|
||||
z[n] = 0;
|
||||
c[n] = 0;
|
||||
|
||||
|
|
@ -410,7 +414,7 @@ double SplineEquation::f(double x)
|
|||
for (j = 0; j < ncoeff; j++) {
|
||||
if(coeff[j].x > x) {
|
||||
if(j == 0)
|
||||
j++;
|
||||
j = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ public:
|
|||
template<class T>
|
||||
static void Register(const String& name)
|
||||
{
|
||||
classMap().FindAdd(name, __Create<T>);
|
||||
typeMap().FindAdd(typeid(T).name(), name);
|
||||
T dummy;
|
||||
typeNumber().Add(dummy.GetTypeCount());
|
||||
|
|
|
|||
|
|
@ -1312,10 +1312,10 @@ void ScatterDraw::DoZoom(double scale, bool mouseX, bool mouseY) {
|
|||
}
|
||||
}
|
||||
}
|
||||
double plotW = scale*(GetSize().cx - (hPlotLeft + hPlotRight));
|
||||
double plotH = scale*(GetSize().cy - (vPlotTop + vPlotBottom)) - titleHeight;
|
||||
double dw = plotW*xMajorUnit/double(xRange);
|
||||
double dh = plotH*yMajorUnit/double(yRange);
|
||||
//double plotW = scale*(GetSize().cx - (hPlotLeft + hPlotRight));
|
||||
//double plotH = scale*(GetSize().cy - (vPlotTop + vPlotBottom)) - titleHeight;
|
||||
//double dw = plotW*xMajorUnit/double(xRange);
|
||||
//double dh = plotH*yMajorUnit/double(yRange);
|
||||
|
||||
bool can = true;//min<double>(dw, dh) > 20 || scale < 1;
|
||||
if (mouseX && can) {
|
||||
|
|
|
|||
|
|
@ -63,6 +63,12 @@ esES("Exponencial")
|
|||
euES("")
|
||||
frFR("")
|
||||
|
||||
T_("RealExponent")
|
||||
caES("")
|
||||
esES("")
|
||||
euES("")
|
||||
frFR("")
|
||||
|
||||
T_("Rational_1")
|
||||
caES("Racional_1")
|
||||
esES("Racional_1")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue