예제 #1
0
static void  drawgraph(void)
{
 int         n=101;
 double  f[202]; 
   
  calccoef();
  if(err_code) { messanykey(10,10,"Error in kinematics"); return; }
          
  do
  {  if (correctInt(56,8,"Number of points=",&n,1))
     {
        if (n < 3) messanykey(56,8,"Too few points");
        if (n > 201) messanykey(56,8,"Too many points");
     }
      else return;
  }  while (n < 3 || n > 201 );

           
  if( !fillseq(n,f)) 
  {  messanykey(10,10,"Error in calculation"); 
     return;
  }

  plot_1(cos1,cos2,n,f,NULL,procname,"cos(p1,p3)", "Diff. cross section [pb]");

}
예제 #2
0
GCP_PRIVATE int
gcp_I_compute_georef_equations (struct Control_Points *cp, double E12[],
				double N12[], double E21[], double N21[],
				int order)
{
    double *tempptr;
    int status;

    if (order < 1 || order > MAXORDER)
	return MPARMERR;

    /* CALCULATE THE FORWARD TRANSFORMATION COEFFICIENTS */

    status = calccoef (cp, E12, N12, order);

    if (status != MSUCCESS)
	return status;

    /* SWITCH THE 1 AND 2 EASTING AND NORTHING ARRAYS */

    tempptr = cp->e1;
    cp->e1 = cp->e2;
    cp->e2 = tempptr;
    tempptr = cp->n1;
    cp->n1 = cp->n2;
    cp->n2 = tempptr;

    /* CALCULATE THE BACKWARD TRANSFORMATION COEFFICIENTS */

    status = calccoef (cp, E21, N21, order);

    /* SWITCH THE 1 AND 2 EASTING AND NORTHING ARRAYS BACK */

    tempptr = cp->e1;
    cp->e1 = cp->e2;
    cp->e2 = tempptr;
    tempptr = cp->n1;
    cp->n1 = cp->n2;
    cp->n2 = tempptr;

    return status;
}
예제 #3
0
파일: gdal_crs.c 프로젝트: koordinates/gdal
static int
CRS_compute_georef_equations (GCPTransformInfo *psInfo, struct Control_Points *cp,
                                      double E12[], double N12[],
                                      double E21[], double N21[],
                                      int order)
{
    double *tempptr = NULL;
    int status = 0;

    if(order < 1 || order > MAXORDER)
        return(MPARMERR);

    /* CALCULATE THE FORWARD TRANSFORMATION COEFFICIENTS */

    status = calccoef(cp,psInfo->x1_mean,psInfo->y1_mean,E12,N12,order);
    if(status != MSUCCESS)
        return(status);

    /* SWITCH THE 1 AND 2 EASTING AND NORTHING ARRAYS */

    tempptr = cp->e1;
    cp->e1 = cp->e2;
    cp->e2 = tempptr;
    tempptr = cp->n1;
    cp->n1 = cp->n2;
    cp->n2 = tempptr;

    /* CALCULATE THE BACKWARD TRANSFORMATION COEFFICIENTS */

    status = calccoef(cp,psInfo->x2_mean,psInfo->y2_mean,E21,N21,order);

    /* SWITCH THE 1 AND 2 EASTING AND NORTHING ARRAYS BACK */

    tempptr = cp->e1;
    cp->e1 = cp->e2;
    cp->e2 = tempptr;
    tempptr = cp->n1;
    cp->n1 = cp->n2;
    cp->n2 = tempptr;

    return(status);
}
예제 #4
0
static void  total_cs(void)
{  double  totcs;

   goto_xy(18,6); 
   scrcolor(FGmain,BGmain);
   print("?                            "); 
   goto_xy(18,6);
   refresh_scr();
   calccoef(); 
   if (err_code ) print("incorrect"); else 
   {
      totcs= gauss345(cross_section, cos1,cos2,eps); 
      if (err_code<=0 ) { print("%-G [pb]",totcs);} 
      if(err_code==1)  print("?");
   }
}
예제 #5
0
int CRS_compute_georef_equations_or(struct Control_Points_3D *cp,
                                    double OR12[], double OR21[])
{
    double *tempptr, *OR;
    int status, i, numactive;
    struct Control_Points_3D cpc,     /* center points */
			     cpr;     /* reduced to center */

    cpc.count = 1;
    cpc.e1 = (double *)G_calloc(cpc.count, sizeof(double));
    cpc.e2 = (double *)G_calloc(cpc.count, sizeof(double));
    cpc.n1 = (double *)G_calloc(cpc.count, sizeof(double));
    cpc.n2 = (double *)G_calloc(cpc.count, sizeof(double));
    cpc.z1 = (double *)G_calloc(cpc.count, sizeof(double));
    cpc.z2 = (double *)G_calloc(cpc.count, sizeof(double));
    cpc.status = (int *)G_calloc(cpc.count, sizeof(int));

    cpc.e1[0] = 0.0;
    cpc.e2[0] = 0.0;
    cpc.n1[0] = 0.0;
    cpc.n2[0] = 0.0;
    cpc.z1[0] = 0.0;
    cpc.z2[0] = 0.0;
    cpc.status[0] = 1;

    /* center points */
    for (i = numactive = 0; i < cp->count; i++) {
	if (cp->status[i] > 0) {
	    numactive++;
	    cpc.e1[0] += cp->e1[i];
	    cpc.e2[0] += cp->e2[i];
	    cpc.n1[0] += cp->n1[i];
	    cpc.n2[0] += cp->n2[i];
	    cpc.z1[0] += cp->z1[i];
	    cpc.z2[0] += cp->z2[i];
	}
    }

    /* this version of 3D transformation needs 3 control points */
    if (numactive < 3)
	return MNPTERR;

    cpc.e1[0] /= numactive;
    cpc.e2[0] /= numactive;
    cpc.n1[0] /= numactive;
    cpc.n2[0] /= numactive;
    cpc.z1[0] /= numactive;
    cpc.z2[0] /= numactive;

    /* shift to center points */
    cpr.count = numactive;
    cpr.e1 = (double *)G_calloc(cpr.count, sizeof(double));
    cpr.e2 = (double *)G_calloc(cpr.count, sizeof(double));
    cpr.n1 = (double *)G_calloc(cpr.count, sizeof(double));
    cpr.n2 = (double *)G_calloc(cpr.count, sizeof(double));
    cpr.z1 = (double *)G_calloc(cpr.count, sizeof(double));
    cpr.z2 = (double *)G_calloc(cpr.count, sizeof(double));
    cpr.status = (int *)G_calloc(cpr.count, sizeof(int));

    for (i = numactive = 0; i < cp->count; i++) {
	if (cp->status[i] > 0) {
	    cpr.e1[numactive] = cp->e1[i] - cpc.e1[0];
	    cpr.e2[numactive] = cp->e2[i] - cpc.e2[0];
	    cpr.n1[numactive] = cp->n1[i] - cpc.n1[0];
	    cpr.n2[numactive] = cp->n2[i] - cpc.n2[0];
	    cpr.z1[numactive] = cp->z1[i] - cpc.z1[0];
	    cpr.z2[numactive] = cp->z2[i] - cpc.z2[0];
	    cpr.status[numactive] = 1;
	    numactive++;
	}
    }
    
    /* CALCULATE THE FORWARD TRANSFORMATION COEFFICIENTS */

    OR = OR12;
    status = calccoef(&cpr, OR, 3);

    calcscale(&cpr, OR);

    /* CALCULATE FORWARD SHIFTS */

    OR[9] = OR[10] = OR[11] = 0.0;
    
    for (i = numactive = 0; i < cp->count; i++) {
	if (cp->status[i] > 0) {
	    OR[9]  += cp->e2[i] - OR[12] *
	              (OR[0] * cp->e1[i] +
		       OR[1] * cp->n1[i] + 
		       OR[2] * cp->z1[i]);
	    OR[10] += cp->n2[i] - OR[13] *
	              (OR[3] * cp->e1[i] +
		       OR[4] * cp->n1[i] +
		       OR[5] * cp->z1[i]);
	    OR[11] += cp->z2[i] - OR[14] *
	              (OR[6] * cp->e1[i] +
		       OR[7] * cp->n1[i] +
		       OR[8] * cp->z1[i]);
	    
	    numactive++;
	}
    }
    OR[9] /= numactive;
    OR[10] /= numactive;
    OR[11] /= numactive;
    
    /* SWITCH THE 1 AND 2 EASTING, NORTHING, AND HEIGHT ARRAYS */

    tempptr = cpr.e1;
    cpr.e1 = cpr.e2;
    cpr.e2 = tempptr;
    tempptr = cpr.n1;
    cpr.n1 = cpr.n2;
    cpr.n2 = tempptr;
    tempptr = cpr.z1;
    cpr.z1 = cpr.z2;
    cpr.z2 = tempptr;

    /* CALCULATE THE BACKWARD TRANSFORMATION COEFFICIENTS */

    OR = OR21;
    status = calccoef(&cpr, OR, 3);

    if (status != MSUCCESS)
	return status;

    calcscale(&cpr, OR);

    /* SWITCH THE 1 AND 2 EASTING, NORTHING, AND HEIGHT ARRAYS BACK */

    tempptr = cpr.e1;
    cpr.e1 = cpr.e2;
    cpr.e2 = tempptr;
    tempptr = cpr.n1;
    cpr.n1 = cpr.n2;
    cpr.n2 = tempptr;
    tempptr = cpr.z1;
    cpr.z1 = cpr.z2;
    cpr.z2 = tempptr;

    /* CALCULATE BACKWARD SHIFTS */

    OR[9] = OR[10] = OR[11] = 0.0;
    
    for (i = numactive = 0; i < cp->count; i++) {
	if (cp->status[i] > 0) {
	    OR[9]  += cp->e1[i] - OR[12] *
	              (OR[0] * cp->e2[i] +
		       OR[1] * cp->n2[i] +
		       OR[2] * cp->z2[i]);
	    OR[10] += cp->n1[i] - OR[13] *
	              (OR[3] * cp->e2[i] +
		       OR[4] * cp->n2[i] +
		       OR[5] * cp->z2[i]);
	    OR[11] += cp->z1[i] - OR[14] *
	              (OR[6] * cp->e2[i] +
		       OR[7] * cp->n2[i] +
		       OR[8] * cp->z2[i]);
	    numactive++;
	}
    }
    OR[9] /= numactive;
    OR[10] /= numactive;
    OR[11] /= numactive;
    
    OR = OR12;
    G_debug(1, "********************************");
    G_debug(1, "Forward transformation:");
    G_debug(1, "Orthogonal rotation matrix:");
    G_debug(1, "%.4f %.4f %.4f", OR[0], OR[1], OR[2]);
    G_debug(1, "%.4f %.4f %.4f", OR[3], OR[4], OR[5]);
    G_debug(1, "%.4f %.4f %.4f", OR[6], OR[7], OR[8]);
    G_debug(1, "x, y, z shift: %.4f %.4f %.4f", OR[9], OR[10], OR[11]);
    G_debug(1, "x, y, z scale: %.4f %.4f %.4f", OR[12], OR[13], OR[14]);

    OR = OR21;
    G_debug(1, "********************************");
    G_debug(1, "Backward transformation:");
    G_debug(1, "Orthogonal rotation matrix:");
    G_debug(1, "%.4f %.4f %.4f", OR[0], OR[1], OR[2]);
    G_debug(1, "%.4f %.4f %.4f", OR[3], OR[4], OR[5]);
    G_debug(1, "%.4f %.4f %.4f", OR[6], OR[7], OR[8]);
    G_debug(1, "x, y, z shift: %.4f %.4f %.4f", OR[9], OR[10], OR[11]);
    G_debug(1, "x, y, z scale: %.4f %.4f %.4f", OR[12], OR[13], OR[14]);

    return status;
}
예제 #6
0
static double  totcs(void)
{  double  int_val = 0.0;
   calccoef();
   if (err_code == 0) int_val=gauss345(cross_section,cos1,cos2,eps);
   return int_val;
}