示例#1
0
void CPositionOrbit::GetXYZ(double & x, double & y, double & z)
{
	// Local variables (mostly renaming mParams variables for convenience).
	// Remember to convert the angular parameters into radians.
    double l1, l2, m1, m2, n1, n2;
    double inc = mParams[0] * PI / 180.0;
    double Omega = mParams[1] * PI / 180.0;
    double omega = mParams[2] * PI / 180.0;
    double alpha = mParams[3];
    double e = mParams[4];
    double tau = mParams[5];
    double T = mParams[6];
    double t = mTime;

	// Pre-compute a few values
    double n = ComputeN(T);
    double M = ComputeM(tau, n, t);
    double E = ComputeE(M, e);

    double cos_E = cos(E);
    double sin_E = sin(E);
    double beta = sqrt(1 - e*e);

    // Now compute the orbital coefficients
    Compute_Coefficients(Omega, inc, omega, l1, m1, n1, l2, m2, n2);
    Compute_xyz(alpha, beta, e, l1, l2, m1, m2, n1, n2, cos_E, sin_E, x, y, z);
}
示例#2
0
int main(int argc, char* argv[]) {
	//***System.out.println("MLCS Version 1.0\n");
	//get input parameters and initialize global variables
	if(argc<3){
		printf("Too few parameters! Please provide parameters in order as follows,\n");
		printf("(1) The number of Strings.\n");
		printf("(2) Alphabet size (4 or 20).\n");
		printf("(3) Input file name.\n");
		exit(1);
	}

	MAXSTR = atoi(argv[1]);

	ABC_len = atoi(argv[2]);
	if (ABC_len==4){
		ABC_str = ABC_str_4;
		ABC_idx = ABC_idx_4;
	}else if (ABC_len==20){
		ABC_str = ABC_str_20;
		ABC_idx = ABC_idx_20;
	}else{
		printf("Unsupported alphabet size!\n");
		return 1;
	}

	strcpy(data_file_fullname, argv[3]);

	//check the content of the input sequence file
	FILE *my_file = fopen(data_file_fullname, "r");
	if (my_file == NULL) {
		printf("Empty string file: %s!\n", data_file_fullname);
		return 1;
	} else {
		MAXSTRSIZE = 0;
		char cur_line[10000];

		while (!feof(my_file)) {
			fscanf(my_file, "%s\n", cur_line);
			//sscanf(cur_line, "%s", cur_line);
			int len = strlen(cur_line);
			if (!len) continue;
			if (len > MAXSTRSIZE)
				 MAXSTRSIZE = len;
			cur_n_str ++;
		}
		fclose(my_file);
	}
	
	if (cur_n_str == 0){
		printf("\nNumber of input strings is %d.\n", cur_n_str);
		return 1;
	}else if (MAXSTR > cur_n_str){
		MAXSTR = cur_n_str;
	}
	printf("\nNumber of input strings is %d.\n", MAXSTR);

	//allocate memory for global variables
	data = Allocate2DArray<char>(MAXSTR, MAXSTRSIZE+1);
	str_lngth = new int[MAXSTR];

	//read input strings and do preprocessing
	cur_n_str = 0;
	int i, j;
	my_file = fopen(data_file_fullname, "r");
	while (!feof(my_file) && (cur_n_str < MAXSTR)) {
		fscanf(my_file, "%s\n", data[cur_n_str]);
		int len = strlen(data[cur_n_str]);
		if (!len)continue;
		
		str_lngth[cur_n_str]=len;
		//printf("string N%d: '%s'\n", cur_n_str, data[cur_n_str]);    
				
		cur_T.push_back(Allocate2DArray<short>(len+1, ABC_len));
		
		for (i=0; i<ABC_len; i++) {
			cur_T[cur_n_str][len][i] = len+1;
		}

		for (j=len-1; j>=0; j--) {
			for (i=0; i<ABC_len; i++) {
				cur_T[cur_n_str][j][i] = cur_T[cur_n_str][j+1][i];
			}
			cur_T[cur_n_str][j][ABC_idx[data[cur_n_str][j]-'A']] = j;
		}

		cur_n_str ++;
	}
	fclose(my_file);

	ComputeM();

	//find MLCS of strings
	Mainloop();

	//release memory
	Free2DArray<char>(data);

	delete[] str_lngth;
	
	for (i=0; i<cur_T.size(); i++){
		short** temp = cur_T[i];
		Free2DArray<short>(temp);
	}

	for (i=0; i<(MAXSTR+1)/2; i++) {
		short** temp = cur_M[i];
		Free2DArray<short>(temp);
	}

	printf("Done!\n");
	return 0;
}