PixelTiempo Splines::alentarPixel(const PixelTiempo &P, int c0, int c1) const { int q = (c1 - 1) / (c0 - 1); PixelTiempo r(c1); bool finish = false; for (int f = 0; f <= (c0 - 1) / reset && !finish; f++) { int first = f * reset; int last = std::min(reset * (f + 1), (int) P.size() - 1); if (std::min(reset * (f + 2), (int) P.size() - 1) - last < 2) { last = P.size() - 1; finish = true; } std::vector <Polynomial> z = buildSpline(Vector(P.begin() + (f * reset), P.begin() + last), q); for (int i = 0; i < last - (f * reset); i++) { for (int j = 0; j < q; j++) { double x = ((f * reset + i) * q) + j; r[x] = toPixel(z[i].a + z[i].b * j + z[i].c * std::pow(j, 2) + z[i].d * std::pow(j, 3)); } } } r[c1 - 1] = P[c0 - 1]; return r ; }
InsetStackItem RasterLayerProperties::getConfig() const { InsetStackItem cfg; // in the InsetStackItem: // 'maxlevel' is the level to use for the blend (not the inset's max) // 'override' max is the level we want to use regardless of the // inset's max level // GetInsetLevels() extracts the inset's min/max level from the inset cfg.dataAsset = assetNameLabel->text().latin1(); uint insetmin = 0; uint insetmax = 0; GetMinMaxLevels(cfg.dataAsset, insetmin, insetmax); cfg.overridemax = toPixel( overrideMaxSpin->value() ); if ( cfg.overridemax == insetmax ) cfg.overridemax = 0; //cfg.peergroup = peerGroupSpin->value(); cfg.maxlevel = cfg.overridemax; if (!cfg.maxlevel) { cfg.maxlevel = insetmax; } else if (cfg.maxlevel > insetmax) { cfg.maxlevel = insetmax; } else if (cfg.maxlevel < insetmin) { cfg.maxlevel = insetmin; } return cfg; }
void MarginValueWidget::slotValueChanged(double v) { if(!m_block) { m_margin = toPixel(v, m_mode); emit marginChanged(margin()); } }
// Uses image plane coordinates to construct rays from lens Colour Camera::sampleLens(double x, double y) const { x = (x * focalDistance_) / factor_; y = (y * focalDistance_) / factor_; Colour col; // sample aperture disk for DOF, if not pinhole camera if ( apertureRadius_ > std::numeric_limits<double>::epsilon() && apertureSampler_.n() > 1) { for (auto const& sample : apertureSampler_) { // respect the jacobian when sampling disk double r = sqrt(sample[0])*apertureRadius_; double theta = 2*M_PI*sample[1]; // find the aperture point that acts as the origin of the ray Point3D aperturePoint(r*cos(theta), r*sin(theta), 0); // get direction to focus point Vector3D toPixel(Point3D(x, y, -focalDistance_) - aperturePoint); // construct ray Ray3D ray(viewToWorld_.transformPoint(aperturePoint.v), viewToWorld_.transformVector(toPixel.v)); // sample scene with ray col += sceneSamplingFunc_(ray); } // divide by number of samples taken by the sampler col /= apertureSampler_.n() ; } // otherwise it's a pinhole camera else { // shoot a single ray directly through center of aperture Ray3D ray(eye_, viewToWorld_.transformVector(Eigen::Vector3d(x, y, -focalDistance_))); col += sceneSamplingFunc_(ray); } return col; }
float MarginValueWidget::margin() { // Force synchronization m_margin = toPixel(value(), m_mode); return m_margin; }