void
grid_coor(char *buffer, com_table *ctp, struct rt_i *UNUSED(rtip))
{
    extern int str_dbl();  /* function to convert string to double */
    int i = 0;
    int rc = 0;    /* the return code value from str_dbl() */
    vect_t Gr;

    while (isspace((int)*(buffer+i)))
	++i;
    if (*(buffer+i) == '\0') {
	/* display current grid coordinates */
	fprintf(stdout, "(h, v, d) = (%4.2f, %4.2f, %4.2f)\n",
	       grid(HORZ) * base2local,
	       grid(VERT) * base2local,
	       grid(DIST) * base2local);
	return;
    }
    if ((rc = str_dbl(buffer+i, &Gr[HORZ])) == 0) {
	/* get horz coor */
	com_usage(ctp);
	return;
    }
    i += rc;
    while (isspace((int)*(buffer+i)))
	++i;
    if ((rc = str_dbl(buffer+i, &Gr[VERT])) == 0) {
	/* get vert coor */
	com_usage(ctp);
	return;
    }
    i += rc;
    while (isspace((int)*(buffer+i)))
	++i;
    if (*(buffer+i) == '\0') {
	/* if there is no dist coor, set default */
	grid(HORZ) = Gr[HORZ] * local2base;
	grid(VERT) = Gr[VERT] * local2base;
	grid2targ();
	return;
    }
    if ((rc = str_dbl(buffer+i, &Gr[DIST])) == 0) {
	/* set dist coor */
	com_usage(ctp);
	return;
    }
    i += rc;
    while (isspace((int)*(buffer+i)))
	++i;
    if (*(buffer+i) != '\0') {
	/* check for garbage at the end of the line */
	com_usage(ctp);
	return;
    }
    grid(HORZ) = Gr[HORZ] * local2base;
    grid(VERT) = Gr[VERT] * local2base;
    grid(DIST) = Gr[DIST] * local2base;
    grid2targ();
}
void
az_el(char *buffer, com_table *ctp, struct rt_i *UNUSED(rtip))
{
    extern int str_dbl();  /* function to convert string to double */
    int i = 0;      /* current position on the *buffer */
    int rc = 0;     /* the return code value from str_dbl()   */
    double az;
    double el;

    while (isspace((int)*(buffer+i)))
	++i;
    if (*(buffer+i) == '\0') {
	/* display current az and el values */
	bu_log("(az, el) = (%4.2f, %4.2f)\n",
	       azimuth(), elevation());
	return;
    }
    if ((rc = str_dbl(buffer+i, &az)) == 0) {
	/* get az value */
	com_usage(ctp);
	return;
    }
    if (fabs(az) > 360) {
	/* check for valid az value */

	bu_log("Error:  |azimuth| <= 360\n");
	return;
    }
    i += rc;
    while (isspace((int)*(buffer+i)))
	++i;
    if ((rc = str_dbl(buffer+i, &el)) == 0) {
	/* get el value */
	com_usage(ctp);
	return;
    }
    if (fabs(el) > 90) {
	/* check for valid el value */
	bu_log("Error:  |elevation| <= 90\n");
	return;
    }
    i += rc;
    while (isspace((int)*(buffer+i)))
	++i;
    if (*(buffer+i) != '\0') {
	/* check for garbage at the end of the line */
	com_usage(ctp);
	return;
    }
    azimuth() = az;
    elevation() = el;
    ae2dir();
}
void
target_coor(char *buffer, com_table *ctp, struct rt_i *UNUSED(rtip))
{
    extern int str_dbl();  /* function to convert string to double */
    int i = 0;
    int rc = 0;     /* the return code value from str_dbl() */
    vect_t Tar;	    /* Target x, y and z */

    while (isspace((int)*(buffer+i)))
	++i;
    if (*(buffer+i) == '\0') {
	/* display current target coors */
	fprintf(stdout, "(x, y, z) = (%4.2f, %4.2f, %4.2f)\n",
	       target(X) * base2local,
	       target(Y) * base2local,
	       target(Z) * base2local);
	return;
    }
    if ((rc = str_dbl(buffer+i, &Tar[X])) == 0) {
	/* get target x coor */
	com_usage(ctp);
	return;
    }
    i += rc;
    while (isspace((int)*(buffer+i)))
	++i;
    if ((rc = str_dbl(buffer+i, &Tar[Y])) == 0) {
	/* get target y coor */
	com_usage(ctp);
	return;
    }
    i += rc;
    while (isspace((int)*(buffer+i)))
	++i;
    if ((rc = str_dbl(buffer+i, &Tar[Z])) == 0) {
	/* get target z coor */
	com_usage(ctp);
	return;
    }
    i += rc;
    while (isspace((int)*(buffer+i)))
	++i;
    if (*(buffer+i) != '\0') {
	/* check for garbage at the end of the line */
	com_usage(ctp);
	return;
    }
    target(X) = Tar[X] * local2base;
    target(Y) = Tar[Y] * local2base;
    target(Z) = Tar[Z] * local2base;
    targ2grid();
}
void
dir_vect(char *buffer, com_table *ctp, struct rt_i *UNUSED(rtip))
{
    extern int str_dbl();  /* function to convert string to double */
    int i = 0;
    int rc = 0;    /* the return code value from str_dbl() */
    vect_t Dir;	   /* Direction vector x, y and z */

    while (isspace((int)*(buffer+i)))
	++i;
    if (*(buffer+i) == '\0') {
	/* display current direct coors */
	fprintf(stdout, "(x, y, z) = (%4.2f, %4.2f, %4.2f)\n",
	       direct(X), direct(Y), direct(Z));
	return;
    }
    if ((rc = str_dbl(buffer+i, &Dir[X])) == 0) {
	/* get direct x coor */
	com_usage(ctp);
	return;
    }
    i += rc;
    while (isspace((int)*(buffer+i)))
	++i;
    if ((rc = str_dbl(buffer+i, &Dir[Y])) == 0) {
	/* get direct y coor */
	com_usage(ctp);
	return;
    }
    i += rc;
    while (isspace((int)*(buffer+i)))
	++i;
    if ((rc = str_dbl(buffer+i, &Dir[Z])) == 0) {
	/* get direct z coor */
	com_usage(ctp);
	return;
    }
    i += rc;
    while (isspace((int)*(buffer+i)))
	++i;
    if (*(buffer+i) != '\0') {
	/* check for garbage at the end of the line */
	com_usage(ctp);
	return;
    }
    VUNITIZE(Dir);
    direct(X) = Dir[X];
    direct(Y) = Dir[Y];
    direct(Z) = Dir[Z];
    dir2ae();
}
Example #5
0
int main(int argc, char* argv[]) {
	std::cout << "\n";

	if(argc != 8) {
		std::cout << "Invalid parameters, usage: <int|double> <rows> <columns> <offset> <range> <seed> <output-file>\n";
		return 1;
	}
	
	int param = 0;
	bool is_int = true; // false -> is_double
	
	std::string str_int("int");
	std::string str_dbl("double");

	std::string type(argv[++param]);

	if(str_int.compare(type) == 0)
		is_int = true;
	else if(str_dbl.compare(type) == 0)
		is_int = false;
	else {
		std::cout << "Invalid type-parameter: write 'int' or 'double'";
		return 2;
	}

	int ctr_i;
	int rng_i;
	double ctr_d;
	double rng_d;
	
	int n = std::stoi(argv[++param]); // number of rows
	int d = std::stoi(argv[++param]); // number of columns
	
	if(is_int) {
		ctr_i = std::stoi(argv[++param]);
		rng_i = std::stoi(argv[++param]);
	}
	else {
		ctr_d = std::stod(argv[++param]); // where the random data should be centered
		rng_d = std::stod(argv[++param]); // the range of the data -> ctr +- rng
	}

	int seed = std::stoi(argv[++param]);
	char *path = argv[++param]; // the output-path

	std::cout << "Generating random " << type  << "-data and dumping to file...\n";

	if(is_int)
		dump_rand_data_i(n, d, ctr_i, rng_i, path, CSV_DELIM, seed);
	else
		dump_rand_data_d(n, d, ctr_d, rng_d, path, CSV_DELIM, seed);

	std::cout << "Done!\n";
}