Exemplo n.º 1
0
static void RDFtoRP(const Curve &rdf, int npoints, Curve *rp) {
    const float wstep = 1.f / sqrtf(npoints);
    Curve tmp(rdf);
    for (int i = 0; i < rp->size(); ++i) {
        const float u0 = rp->ToX(i);
        const float u = TWOPI * u0;
        const float wndsize = rdf.x1 * std::min(0.5f, std::max(0.2f, 4.f * u0 * wstep));
        for (int j = 0; j < tmp.size(); ++j) {
            float x = rdf.ToX(j);
            float wnd = BlackmanWindow(x, wndsize);
            tmp[j] = (rdf[j] - 1) * j0f(u*x) * x * wnd;
        }
        (*rp)[i] = fabsf(1.f + TWOPI * Integrate(tmp) * npoints);
    }
}
Exemplo n.º 2
0
static float OscillationsMetric(const Curve &rp, int npoints) {
    // nuosci: lowest frequency v for which P(v) ~ 1
    float nuosci = 0.0, maxp = 0.0;
    for (int i = 0; i < rp.size() && maxp < 0.98; ++i) {
        float p = rp[i];
        if (p > maxp) {
            maxp = p;
            nuosci = rp.ToX(i);
        }
    }
    
    float npeaks = 10.f;
    float maxfreq = sqrtf(npoints) / 2;
    float x0 = nuosci;
    float x1 = std::min(x0 + npeaks * maxfreq, rp.x1);
    
    Curve osci(rp);
    for (int i = 0; i < osci.size(); ++i) {
        float nu = osci.ToX(i);
        osci[i] = nu < x0 ? 0.f : (osci[i] - 1.f) * (osci[i] - 1.f) * nu;
    }
    
    return 10.f * sqrtf(TWOPI * Integrate(osci, x0, x1) / RingArea(x0, x1));
}