ait-survey

flat X

Jan 12th, 2015
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.80 KB | None | 0 0
  1. /***************************************************************************
  2. flat
  3.  
  4.  DSM floatデータ型で格納
  5.  read
  6.  2008/1/10
  7.  made by Yoshiyukiu Yamamoto
  8.  ver1.1 2009/3/7
  9.   ********************************************************************************/
  10.  #include<stdio.h>
  11.  #include<stdlib.h>
  12.  #include<string.h>
  13.  #include<math.h>
  14.  
  15.  int main(int argc,char *argv[])
  16.  {      
  17.      
  18.          /*****************************************************
  19.           1.Definition of Variables
  20.           ******************************************************/
  21.          FILE *fpw;  //file pointer for input&output file
  22.          int no,i,j;
  23.          float x,y,z,lh;
  24.          unsigned char r,g,b;
  25.          double zy,azy,azr,zr;
  26.          int max;
  27.      
  28.      /*****************************************************
  29.            2.command Line arguments processing
  30.            ******************************************************/
  31.           if(argc!=5)
  32.           {
  33.                   fprintf(stderr,"Usage: %s (1)output_xyz FILENAME\n",argv[0]);
  34.                  exit(1);
  35.          }
  36.          printf("OPEN FILE NAME:%s\n",argv[1]);
  37.  
  38.          /**********************************************************************************
  39.           **********************************************************************************
  40.           4.  FILE OPEN + Binary File Input
  41.           **********************************************************************************
  42.  ***************************************************************************************/
  43.  
  44.          // open input file
  45.       /*   if((fpr=fopen(argv[1],"r"))==NULL)
  46.          {
  47.                 printf("ファイルのオープンに失敗しました。プログラムを終了します。\n");
  48.                 exit(1);
  49.          }
  50.          */
  51.          //write file
  52.          if((fpw=fopen(argv[1],"w"))==NULL)
  53.          {
  54.                 fprintf(stderr,"DSM by GSI データファイル.raw\n");
  55.                 exit(1);
  56.          }
  57.          azr=0;
  58.          azy=0;
  59.          zr=atof(argv[2]);
  60.          zy=atof(argv[2]);
  61.          lh=atof(argv[3]);
  62.          max=atoi(argv[4]);
  63.     /*******************************************************
  64.          データの読み取り書き込み
  65.          *******************************************************/
  66.     /* データ処理 */
  67.                for(i=0;i<max;i++)
  68.        {
  69.                for(j=0;j<max;j++)
  70.     {
  71.                azr=azr+zr*j;
  72.                azy=azy+zy*i;
  73.                x=cos(azy)*lh*tan(azr);
  74.                y=sin(azy)*lh*tan(azr);
  75.                z=0;
  76.                r=127;
  77.                g=127;
  78.                b=127;
  79.            //printf("x=%f,y=%f,z=%f,r=%d,g=%d,b=%d\n",x,y,z,r,g,b);
  80.                fprintf(fpw,"%f %f %f %d %d %d\n",x,y,z,r,g,b);
  81.                }
  82. }
  83.        /* ファイル・クローズ*/
  84.           //fclose(fpr);
  85.           fclose(fpw);
  86.  }
Advertisement
Add Comment
Please, Sign In to add comment