Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /***************************************************************************
- flat
- DSM floatデータ型で格納
- read
- 2008/1/10
- made by Yoshiyukiu Yamamoto
- ver1.1 2009/3/7
- ********************************************************************************/
- #include<stdio.h>
- #include<stdlib.h>
- #include<string.h>
- #include<math.h>
- int main(int argc,char *argv[])
- {
- /*****************************************************
- 1.Definition of Variables
- ******************************************************/
- FILE *fpw; //file pointer for input&output file
- int no,i,j;
- float x,y,z,lh;
- unsigned char r,g,b;
- double zy,azy,azr,zr;
- int max;
- /*****************************************************
- 2.command Line arguments processing
- ******************************************************/
- if(argc!=5)
- {
- fprintf(stderr,"Usage: %s (1)output_xyz FILENAME\n",argv[0]);
- exit(1);
- }
- printf("OPEN FILE NAME:%s\n",argv[1]);
- /**********************************************************************************
- **********************************************************************************
- 4. FILE OPEN + Binary File Input
- **********************************************************************************
- ***************************************************************************************/
- // open input file
- /* if((fpr=fopen(argv[1],"r"))==NULL)
- {
- printf("ファイルのオープンに失敗しました。プログラムを終了します。\n");
- exit(1);
- }
- */
- //write file
- if((fpw=fopen(argv[1],"w"))==NULL)
- {
- fprintf(stderr,"DSM by GSI データファイル.raw\n");
- exit(1);
- }
- azr=0;
- azy=0;
- zr=atof(argv[2]);
- zy=atof(argv[2]);
- lh=atof(argv[3]);
- max=atoi(argv[4]);
- /*******************************************************
- データの読み取り書き込み
- *******************************************************/
- /* データ処理 */
- for(i=0;i<max;i++)
- {
- for(j=0;j<max;j++)
- {
- azr=azr+zr*j;
- azy=azy+zy*i;
- x=cos(azy)*lh*tan(azr);
- y=sin(azy)*lh*tan(azr);
- z=0;
- r=127;
- g=127;
- b=127;
- //printf("x=%f,y=%f,z=%f,r=%d,g=%d,b=%d\n",x,y,z,r,g,b);
- fprintf(fpw,"%f %f %f %d %d %d\n",x,y,z,r,g,b);
- }
- }
- /* ファイル・クローズ*/
- //fclose(fpr);
- fclose(fpw);
- }
Advertisement
Add Comment
Please, Sign In to add comment