Class::Class() { toXYZ(40*M_PI/180, -74*M_PI/180, 0); x1 = x; y1 = y; z1 = z; cout <<x1<<" "<< y1<<" "<< z1; toXYZ(55 *M_PI/180, 37*M_PI/180, 0); x2 = x; y2 = y; z2 = z; calculation_ncos_V(20); }
void Spectrum::toLinearRGB(Float &r, Float &g, Float &b) const { Float x, y, z; toXYZ(x, y, z); /* Convert XYZ to linear RGB according to ITU-R Rec. BT.709 */ r = std::max((Float) 0.0f, m_invNormalization * (3.240479f*x -1.537150f*y - 0.498535f*z)); g = std::max((Float) 0.0f, m_invNormalization * (-0.969256f*x + 1.875991f*y + 0.041556f*z)); b = std::max((Float) 0.0f, m_invNormalization * (0.055648f*x - 0.204043f*y + 1.057311f*z)); }
void NoDynSpectrum::toRGB(float& r, float& g, float& b, float K)const{ //First, convert to XYZ float X,Y,Z; X=Y=Z = 0.0f; toXYZ(X,Y,Z, K); //Now to RGB ColorUtils::XYZToRGB_sRGB(X,Y,Z, r,g,b); }
ScLab ScSpectralValuesConvertor::toLab(const QMap<int, double>& spectrum) const { ScXYZ cieXYZ = toXYZ(spectrum); cmsCIEXYZ cmsXYZ = { cieXYZ.X, cieXYZ.Y, cieXYZ.Z }; cmsCIEXYZ cmsWhite = { m_illuminantWhite.X, m_illuminantWhite.Y, m_illuminantWhite.Z }; cmsCIELab cmsLab = { 0.0, 0.0, 0.0 }; cmsXYZ2Lab(&cmsWhite, &cmsLab, &cmsXYZ); ScLab cieLab = { cmsLab.L, cmsLab.a, cmsLab.b }; return cieLab; }
ScLab ScSpectralValuesConvertor::toLab(const QVector<int>& wavelengths, const QVector<double>& reflectances) const { ScXYZ cieXYZ = toXYZ(wavelengths, reflectances); cmsCIEXYZ cmsXYZ = { cieXYZ.X, cieXYZ.Y, cieXYZ.Z }; cmsCIEXYZ cmsWhite = { m_illuminantWhite.X, m_illuminantWhite.Y, m_illuminantWhite.Z }; cmsCIELab cmsLab = { 0.0, 0.0, 0.0 }; cmsXYZ2Lab(&cmsWhite, &cmsLab, &cmsXYZ); ScLab cieLab = { cmsLab.L, cmsLab.a, cmsLab.b }; return cieLab; }
sk_sp<SkColorSpace> SkColorSpace::Deserialize(const void* data, size_t length) { if (length < sizeof(ColorSpaceHeader)) { return nullptr; } ColorSpaceHeader header = *((const ColorSpaceHeader*) data); data = SkTAddOffset<const void>(data, sizeof(ColorSpaceHeader)); length -= sizeof(ColorSpaceHeader); switch ((Named) header.fNamed) { case kSRGB_Named: case kAdobeRGB_Named: return NewNamed((Named) header.fNamed); default: break; } switch ((GammaNamed) header.fGammaNamed) { case kSRGB_GammaNamed: case k2Dot2Curve_GammaNamed: case kLinear_GammaNamed: { if (ColorSpaceHeader::kMatrix_Flag != header.fFlags || length < 12 * sizeof(float)) { return nullptr; } SkMatrix44 toXYZ(SkMatrix44::kUninitialized_Constructor); toXYZ.set4x3ColMajorf((const float*) data); return NewRGB((GammaNamed) header.fGammaNamed, toXYZ); } default: break; } if (ColorSpaceHeader::kICC_Flag != header.fFlags || length < sizeof(uint32_t)) { return nullptr; } uint32_t profileSize = *((uint32_t*) data); data = SkTAddOffset<const void>(data, sizeof(uint32_t)); length -= sizeof(uint32_t); if (length < profileSize) { return nullptr; } return NewICC(data, profileSize); }
Vector2f Projector::clipLineVec( SkyPoint *p1, SkyPoint *p2 ) const { /* ASSUMES p1 was not clipped but p2 was. * Return the QPoint that barely clips in the line twixt p1 and p2. */ //TODO: iteration = ceil( 0.5*log2( w^2 + h^2) )?? // also possibly rewrite this // --hdevalence int iteration = 15; // For "perfect" clipping: // 2^interations should be >= max pixels/line bool isVisible = true; // so we start at midpoint SkyPoint mid; Vector2f oMid; double x, y, z, dx, dy, dz, ra, dec; int newx, newy, oldx, oldy; oldx = oldy = -10000; // any old value that is not the first omid toXYZ( p1, &x, &y, &z ); // -jbb printf("\np1: %6.4f %6.4f %6.4f\n", x, y, z); toXYZ( p2, &dx, &dy, &dz ); // -jbb printf("p2: %6.4f %6.4f %6.4f\n", dx, dy, dz); dx -= x; dy -= y; dz -= z; // Successive approximation to point on line that just clips. while(iteration-- > 0) { dx *= .5; dy *= .5; dz *= .5; if ( ! isVisible ) { // move back toward visible p1 x -= dx; y -= dy; z -= dz; } else { // move out toward clipped p2 x += dx; y += dy; z += dz; } // -jbb printf(" : %6.4f %6.4f %6.4f\n", x, y, z); // [x, y, z] => [ra, dec] ra = atan2( y, x ); dec = asin( z / sqrt(x*x + y*y + z*z) ); mid = SkyPoint( ra * 12. / dms::PI, dec * 180. / dms::PI ); mid.EquatorialToHorizontal( m_data->lst(), m_data->geo()->lat() ); oMid = toScreenVec( &mid, false, &isVisible ); //AND the result with checkVisibility to clip things going below horizon isVisible &= checkVisibility(&mid); newx = (int) oMid.x(); newy = (int) oMid.y(); // -jbb printf("new x/y: %4d %4d", newx, newy); if ( (oldx == newx) && (oldy == newy) ) { break; } oldx = newx; oldy = newy; } return oMid; }
Colour const LabColour::toRGB () const { return toXYZ ().toRGB (); }
// LINE void HTMesh::intersect(double ra1, double dec1, double ra2, double dec2, BufNum bufNum) { double x1, y1, z1, x2, y2, z2; //if (ra1 == 0.0 || ra1 == 180.00) ra1 += 0.1; //if (ra2 == 0.0 || ra2 == 180.00) ra2 -= 0.1; //if (dec1 == 0.0 ) dec1 += 0.1; //if (dec2 == 0.0 ) dec2 -= 0.1; // convert to Cartesian. Ugh. toXYZ( ra1, dec1, &x1, &y1, &z1); toXYZ( ra2, dec2, &x2, &y2, &z2); // Check if points are too close double len; len = fabs(x1 - x2); len += fabs(y1 - y2); len += fabs(z1 - z2); if (htmDebug > 0 ) { printf("htmDebug = %d\n", htmDebug); printf("p1 = (%f, %f, %f)\n", x1, y1, z1); printf("p2 = (%f, %f, %f)\n", x2, y2, z2); printf("edge: %f (radians) %f (degrees)\n", edge, edge / degree2Rad); printf("len : %f (radians) %f (degrees)\n", len, len / degree2Rad); } if ( len < edge10 ) return intersect( ra1, len, bufNum); // Cartesian cross product => perpendicular!. Ugh. double cx = y1 * z2 - z1 * y2; double cy = z1 * x2 - x1 * z2; double cz = x1 * y2 - y1 * x2; if ( htmDebug > 0 ) printf("cp = (%f, %f, %f)\n", cx, cy, cz); double norm = edge10 / ( fabs(cx) + fabs(cy) + fabs(cz) ); // give it length edge/10 cx *= norm; cy *= norm; cz *= norm; if ( htmDebug > 0 ) printf("cpn = (%f, %f, %f)\n", cx, cy, cz); // add it to (ra1, dec1) cx += x1; cy += y1; cz += z1; if ( htmDebug > 0 ) printf("cpf = (%f, %f, %f)\n", cx, cy, cz); // back to spherical norm = sqrt( cx*cx + cy*cy + cz*cz); double ra0 = atan2( cy, cx ) / degree2Rad; double dec0 = asin( cz / norm ) / degree2Rad; if ( htmDebug > 0 ) printf("new ra, dec = (%f, %f)\n", ra0, dec0); SpatialVector p1(ra1, dec1); SpatialVector p0(ra0, dec0); SpatialVector p2(ra2, dec2); RangeConvex convex(&p1, &p0, &p2); if ( ! performIntersection(&convex, bufNum) ) printf("In intersect(%f, %f, %f, %f)\n", ra1, dec1, ra2, dec2); }