Example #1
0
int getLookYaw(GEOLOCATE_REC *g,double range,double dop,  /*  Inputs.*/
               double *out_look,double *out_yaw)/* Outputs, in radians.*/
{
	int iterations=0,err=0,max_iter=10000;
	double yaw=0,deltaAz;
	double look=0;
	double dopGuess,dopDotGuess,deltaDop,prevDeltaDop=-9999999;
	vector target,vRel;

        while (1)
	{
		double relativeVelocity;
                //if (iterations>10) printf("GetLoc: Iteration %i, doppler=%f, yaw=%20.18f, look=%20.18f.\n",iterations,dopGuess,yaw*180/M_PI,look*180/M_PI);
		err=getLook(g,range,yaw,&look);
                if (err) break;
		getDoppler(g,look,yaw,&dopGuess,&dopDotGuess,&target,&vRel);
		deltaDop=dop-dopGuess;
		relativeVelocity=vecMagnitude(vRel);
		deltaAz=deltaDop*(g->lambda/(2*relativeVelocity));
                // handle the zero doppler case -- without this, we will
                // sometimes flip back&forth accross zero doppler, until max_iter
                if (fabs(deltaDop+prevDeltaDop)<.000001) deltaAz/=2.;
		if (fabs(deltaAz*range)<0.1)/*Require decimeter convergence*/
			break;
		yaw+=deltaAz;
                if (++iterations>max_iter) { /* Failed to converge */
                    err=1; break;
                }
                prevDeltaDop=deltaDop;
	}
	*out_look=look;
	*out_yaw=yaw;
        return err;
}
Example #2
0
/* Provide a wrapper with the old interface */
double getLook_abort(GEOLOCATE_REC *g,double range,double yaw)
{
    double look;
    int err;
    err = getLook(g,range,yaw,&look);
    if (err)
        bail("getLook(): Aborting...\n");
    return look;
}
Example #3
0
    float PerspectiveCamera::pdfDirection(const Vector3& p,
        const Vector3& wo) const {
        // this method doesn't check whether p is projected to film plane
        // based on the assumption that caller already cull out the
        // position that is out of camera frustum

        // pdfW = pdfA / G = 1 / filmArea * r * r / cosTheta
        // wehre cosTheta = dot(wo, n) and r = focalDistance / cosTheta
        // pdfW = focalDistance^2 / (filmArea * cosTheata^3)
        float cosTheta = dot(getLook(),wo);
        float pdfW = mFocalDistance * mFocalDistance /
            (mFilmArea * cosTheta * cosTheta * cosTheta);
        return pdfW;
    }
Example #4
0
 Vector3 OrthographicCamera::samplePosition(const Sample& sample,
     Vector3* surfaceNormal, float* pdfArea) const {
     float invXRes = mFilm->getInvXResolution();
     float invYRes = mFilm->getInvYResolution();
     float xNDC = +2.0f * sample.imageX * invXRes - 1.0f;
     float yNDC = -2.0f * sample.imageY * invYRes + 1.0f;
     // from NDC space to view space
     float xView = 0.5f * mFilmWidth * xNDC;
     float yView = 0.5f * mFilmHeight * yNDC;
     if (pdfArea) {
         *pdfArea = 1.0f / mFilmArea;
     }
     *surfaceNormal = getLook();
     return mOrientation * Vector3(xView, yView, 0.0f) + mPosition;
 }
Example #5
0
 Vector3 PerspectiveCamera::samplePosition(const Sample& sample,
     Vector3* surfaceNormal, float* pdfArea) const {
     Vector3 pCamera;
     if (mLensRadius > 0.0f) {
         Vector2 lensSample = mLensRadius *
             uniformSampleDisk(sample.lensU1, sample.lensU2);
         Vector3 viewOrigin(lensSample.x, lensSample.y, 0.0f);
         pCamera = mOrientation * viewOrigin + mPosition;
     } else {
         pCamera = mPosition;
     }
     if (pdfArea) {
         *pdfArea = mLensRadius > 0.0f ?
             1.0f / (mLensRadius * mLensRadius * PI) : 1.0f;
     }
     *surfaceNormal = getLook();
     return pCamera;
 }
Example #6
0
void Camera::rotateAroundAtPoint(int axis, double angle, double focusDist) {
	Matrix4 matRot;
    if ( axis == 0 ) matRot = Matrix4::xrotation(angle);
    if ( axis == 1 ) matRot = Matrix4::yrotation(angle);
    if ( axis == 2 ) matRot = Matrix4::zrotation(angle);

    const Point3 ptFocus = getEye() + getLook() * focusDist;
	
    const Matrix4 matRotCameraInv = getRotationFromXYZ();
    const Matrix4 matAll = matRotCameraInv * matRot * matRotCameraInv.transpose();

    const double dScl = focusDist * tan( getZoom() / 2.0 );
    const double dXOff = 1.0 / arScale * ptCOP[0] * dScl - skew * ptCOP[1];
    const double dYOff = ptCOP[1] * dScl;

    // Undo center of projection pan to find true at point
    const Vector3 vecUndoCOPPan = dXOff * getRight() +
                                  dYOff * getUp();

	// Should keep unit and ortho, but reset just to make sure
	const Vector3 vecFrom = matAll * (getEye() - ptFocus);
	const Vector3 vecUp = unit( matAll * getUp() );
	const Vector3 vecRight = unit( matAll * getRight() );

    // Undo center of projection pan to find true at point

    const Vector3 vecRedoCOPPan = dXOff * vecRight +
                                  dYOff * vecUp;

    // Find from point if we rotated around the correct at point, then fixed the pan
    const Point3 ptFrom = (ptFocus + vecUndoCOPPan) + vecFrom - vecRedoCOPPan;

    // Correct the at point for the COP pan, then add in the new COP pan
    const Point3 ptAt = (ptFocus + vecUndoCOPPan) - vecRedoCOPPan;

    setFrom( ptFrom );
    setAt( ptAt );
    setUp( vecUp );
}
Example #7
0
void prep_specan_file(int nLooks,int quality,double aspect,
    struct ARDOP_PARAMS *g,meta_parameters *meta)
{
    getRec *inFile;
    FILE *outFile;
    int outLines,outSamples/*,x*/;
    /*char command[1024];*/
    int i;

    specan_struct rng={1.0/RFS,
        RSLOPE,
        RCEN,
        RBW,
        RLEN_INIT};

    specan_struct az={1.0/AFS,
        ASLOPE,
        ACEN,
        ABW,
        ALEN_INIT};

/*Set quality: longer FFT's -> bigger
image, better quality.*/
    for (i=0;i<quality;i++)
    {
        rng.fftLen*=2;
        az.fftLen*=2;
    }
    rng.fftLen=(int)(rng.fftLen*aspect);

/*Open files.*/
    if (!quietflag) printf("Opening input files...\n");
    inFile=fillOutGetRec(g->in1);
    outFile=fopenImage(g->out,"wb");

/*Init. Range Variables*/
    if (!quietflag) printf("Init SPECAN\n");
    rng.iSamp=1.0/g->fs;/*Sample size, range (s)= 1.0/sample freqency (Hz)*/
    rng.chirpSlope=g->slope;/*Range chirp slope (Hz/Sec)*/
    specan_init(&rng);

/*Init. Azimuth Variables*/
    if (!quietflag) printf("Estimate Doppler\n");
    az.iSamp=1.0/g->prf;/*Sample size, azimuth (s)=1.0/sample freqency (Hz)*/

    if (meta->stVec==NULL) {
        fprintf(stderr, "Can only quicklook scenes with state vectors!\n");
        exit(1);}
    else {  /*Find doppler rate (Hz/sec) <=> azimuth chirp slope*/
        double dopRate,yaw=0.0;
        GEOLOCATE_REC *g=init_geolocate_meta(&meta->stVec->vecs[0].vec,meta);
        double look;
                int ret;
                ret=getLook(g,meta->geo->slantFirst,yaw,&look);
                assert(ret==0);
        getDoppler(g,look,yaw,NULL,&dopRate,NULL,NULL);
        az.chirpSlope=dopRate;
        free_geolocate(g);
    }

    az.chirpCenter=g->fd*(1.0/az.iSamp);/*Convert doppler central freqency to Hz*/
    /*For de-scalloping, compute the most powerful doppler freqency.*/
    az.powerCenter=(1.0/az.iSamp)*
        fftEstDop(inFile,inFile->nLines/2,1,az.fftLen);

    if (!quietflag) printf("Doppler centroid at %.0f Hz, %.0f Hz/sec\n",az.chirpCenter,az.chirpSlope);
    specan_init(&az);

    if (!quietflag) printf("Efficiency: Range(%d): %.0f%%   Azimuth(%d): %.0f%%\n",
                           rng.fftLen,100.0*rng.oNum/rng.fftLen,
                           az.fftLen,100.0*az.oNum/az.fftLen);

/*Process image.*/
    specan_file(inFile,nLooks,outFile,&rng,&az,&outLines,&outSamples);
    FCLOSE(outFile);
    freeGetRec(inFile);

/*Create DDR for output file.*/
    {
        struct DDR ddr;/*Output DDR*/
        c_intddr(&ddr);
        ddr.dtype=DTYPE_FLOAT;
        ddr.nbands=1;
        ddr.nl=outLines;
        ddr.ns=outSamples;
        ddr.sample_inc=rng.oSamp/rng.iSamp;
        ddr.line_inc=az.oSamp/az.iSamp;
        c_putddr(g->out,&ddr);
    }
/*Copy over metadata*/
    if (meta->info)
        sprintf(meta->info->processor,"ASF/QUICKLOOK/%.2f",VERSION);
    meta_write(meta,g->out);
}