-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathInitialFromFile.cpp
More file actions
43 lines (32 loc) · 1.02 KB
/
Copy pathInitialFromFile.cpp
File metadata and controls
43 lines (32 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <stdio.h>
#include <stdlib.h>
void initial(struct Ray*Ray0 , double Radius[], double Distance[], double Re_Index[])
{
int k,i;
i = 0;
Ray0->now_surface_number = -1;
Ray0->Wavelen = D_RAY;
char Inputdatas[200];
scanf("%s",&Inputdatas); //将输入的文件名暂存在Inputdatas
FILE *fw = fopen(Inputdatas, "r");
fscanf(fw,"%f",&Ray0->L0); //读入初始物距
if (Ray0->L0 < INFINITE) //判断是否为无穷远物
Ray0->IsInfinite = false;
else Ray0->IsInfinite = true;
fscanf(fw,"%f",&Ray0->U0_D0); //读入初始物方半孔径角U0或入瞳直径D0
fscanf(fw,"%f",&Ray0->Y0_W0); //读入初始物高Y0或半视场角W
fscanf(fw,"%d",&k);
Ray0->all_surface_number = k - 1;
for (i = 0; i < k; i++) //依次读入所有的r值(共k个)
{
fscanf(fw, "%f", &Radius[i]);
}
for (i = 0; i < k-1; i++) //依次读入所有的d值(共k-1个)
{
fscanf(fw, "%f", &Distance[i]);
}
for (i = 0; i <=k; i++) //依次读入所有的n值(共k+1个)
{
fscanf(fw, "%f", &Re_Index[i]);
}
}