uchar* map(float dstx, float dsty) { float sx = dstx*e1x + dsty*e1y; float sy = dstx*e2x + dsty*e2y; float dy = floor( sy / h + 0.5 ); sy -= h*dy; sx += (L-offset)*dy; sx = sx / h * aspect * 2.0; sy = sy / h * aspect * 2.0; sx -= floor( sx/2.0 + 0.5 )*2.0; return child->map( sx, sy ); }
uchar* map(float dstx, float dsty) { if ( dsty > 0.5 || dsty < -0.5 ){ return 0; } //map coordinate to equirectangular coordinate float phi = dstx * M_PI; float theta = dsty * M_PI; float x,y,z; spherical2cartesian(phi, theta, x,y,z ); //swap float t; for(int i=0; i<nswap; i++){ t = z; z = -y; y = x; x = -t; } //recover angles cartesian2spherical(x,y,z, phi, theta); return child->map( phi / M_PI, theta / M_PI ); }
uchar* map(float dstx, float dsty) { float tx = dstx; float ty = 2.0*atan(exp(dsty*M_PI))/M_PI - 0.5; return child->map(tx,ty); }
uchar* map(float dstx, float dsty) { // in image coord (2(a+b) x 2(a+b)) dstx *= (boxx+boxy); dsty *= (boxx+boxy); //dsty = dsty + (eye - 0.5) * boxz; float h,v;//angles //angles for the center of each face float h0 = atan( boxx*eyex/(boxy*eyey) ) - M_PI; float h1 = h0 + M_PI/2; float h2 = h1 + M_PI/2; float h3 = h2 + M_PI/2; if ( ( -boxz / 2 <= dsty ) && ( dsty <= boxz / 2 ) ){ //in the horizontal belt if ( dstx < -boxy ){ dsty = dsty + (eyez - 0.5) * boxz; //panel 0 // x offset from the center of panel dstx += boxy + boxx*(1.0-eyex); h = atan( dstx / (boxy*eyey) ); v = atan( dsty / sqrt( (boxy*eyey)*(boxy*eyey) + dstx*dstx ) ); h += h0; dstx = h / M_PI; dsty = v / M_PI; } else if ( dstx < 0 ){ dsty = dsty + (eyez - 0.5) * boxz; //panel 1 dstx += boxy*(1.0-eyey); h = atan( dstx / (boxx*(1-eyex)) ); v = atan( dsty / sqrt( (boxx*(1-eyex))*(boxx*(1-eyex)) + dstx*dstx ) ); h += h1; dstx = h / M_PI; dsty = v / M_PI; } else if ( dstx < boxx ){ dsty = dsty + (eyez - 0.5) * boxz; //panel 2 dstx -= boxx*(1-eyex); h = atan( dstx / (boxy*(1-eyey)) ); v = atan( dsty / sqrt( (boxy*(1-eyey))*(boxy*(1-eyey)) + dstx*dstx ) ); h += h2; dstx = h / M_PI; dsty = v / M_PI; } else{ dsty = dsty + (eyez - 0.5) * boxz; //panel 3 dstx -= (boxy*(1-eyey) + boxx); h = atan( dstx / (boxx*eyex) ); v = atan( dsty / sqrt( (boxx*eyex)*(boxx*eyex) + dstx*dstx ) ); h += h3; dstx = h / M_PI; dsty = v / M_PI; } } else if ( ( boxz/2 < dsty ) && ( dsty < boxz/2+boxx ) && ( -boxy < dstx ) && (dstx < 0) ){ //dsty = dsty + (eye - 0.5) * c; //panel 4 nadir dstx += boxy*(1-eyey); dsty -= (boxz/2+boxx*(1-eyex)); h = atan(dsty / dstx); if (dstx < 0 ){ h += M_PI; } float r = sqrt( dstx*dstx + dsty*dsty ); v = atan( eyez*boxz / r ); h += h2; dstx = h / M_PI; dsty = v / M_PI; } else if ( ( -boxz/2 - boxx < dsty ) && ( dsty < -boxz/2 ) && ( -boxy < dstx ) && (dstx < 0) ){ //dsty = dsty + (eye - 0.5) * boxz; //panel 5 zenith dstx += boxy*(1-eyey); dsty += boxz/2+boxx*(1-eyex); h = atan(dsty / dstx); if (dstx < 0 ){ h += M_PI; } float r = sqrt( dstx*dstx + dsty*dsty ); v = -atan( (boxz-eyez*boxz) / r ); h = h2 - h; dstx = h / M_PI; dsty = v / M_PI; } else{ //return child->map( 0,0 ); return 0; } return child->map( dstx, dsty ); }
uchar* map(float dstx, float dsty) { dsty += 1.0; int dan = (int)floor( dsty / bw); float loopwidth = bw * M_PI / 2.0; float danwidth = 2.0 - bw + loopwidth; float sx,sy; float h = bw / 2.0; if ( dan % 2 == 0 ){ //even line sx = dan * danwidth + dstx; sy = dsty - dan*bw - h; //right end if ( dstx > 1.0 - h ){ float delta = dstx - 1.0 + h; float a0 = asin( delta / h); float a1 = M_PI - a0; float c0 = cos(a0); float c1 = cos(a1); float y = sy + 0.5*bw; float b0 = y - h*c0; float b1 = y - h*c1; a0 = a0 * h; if ( b1 < h ){ return 0; } else { sx = sx - delta + a0; sy -= h*(1.0-c0); } } //left end if ( dstx < -1.0 + h ){ float delta = -(dstx + 1.0 - h);//width on the screen float a0 = asin( delta / h); float a1 = M_PI - a0; // width along the ribbon float c0 = cos(a0); float c1 = cos(a1); float y = sy + h; float b0 = y - h*c0; float b1 = y - h*c1; //cout << delta << endl; a0 = a0 * h; a1 = a1 * h; if ( b0 > h ){ return 0; } else if ( b1 < h ){ //left; lower; turn sx = sx + delta - a1; sy += h*(1.0-c1); } else{ //left; lower sx = sx + delta - a0; sy += h*(1.0-c0); } } } else{ //odd line sx = dan * danwidth - dstx; sy = dsty - dan * bw - 0.5*bw; //right end if ( dstx > 1.0 - h ){ float delta = dstx - 1.0 + h; float a0 = asin( delta / h); float a1 = M_PI - a0; float c0 = cos(a0); float c1 = cos(a1); float y = sy + 0.5*bw; float b0 = y - h*c0; float b1 = y - h*c1; a0 = a0 * h; a1 = a1 * h; if ( b0 > h ){ return 0; } else if ( b1 < h ){ //right; lower; turn sx = sx + delta - a1; sy += h*(1.0-c1); } else { //right; lower end sx = sx + delta - a0; sy += h*(1.0-c0); } } //left end if ( dstx < -1.0 + h ){ float delta = (dstx + 1.0 - h); float a0 = asin( delta / h); float a1 = M_PI - a0; float c0 = cos(a0); float c1 = cos(a1); float y = sy + 0.5*bw; float b0 = y - h*c0; float b1 = y - h*c1; a0 = a0 * h; if ( b1 < h ){ return 0; } else { //left; upper end sx = sx + delta - a0; sy -= h*(1.0-c0); } } } float stripw = bw / aspect; sx = sx - stripw / 2; sx += (danwidth - loopwidth)/2; if ( repeat==0 && ( sx < -stripw*0.5 || sx > stripw*0.5 ) ) return 0; sx -= floor( sx / stripw + 0.5)*stripw; sx = sx*2.0 / stripw; sy = sy*2.0 / stripw; return child->map( sx, sy ); }
uchar* map(float dstx, float dsty) { return child->map(dstx+x,dsty+y); }