- double n = atof (in_d);
- int size = 2 * (2 * n - 1) + 1;
- double divisor = 4 * n + 3;
-
- for (int itheta = 0; itheta < size; itheta++) {
- double theta = atan (2 * itheta / division);
- printf ("%lf: ", theta);
- double step = d * cos(theta);
- for (int id = 0; id < size; id++) {
- printf ("%lf ", id * step);
+ double d = atof (in_d);
+ int size = 4 * n + 3;
+ int max = 2 * n + 1;
+ int min = -max;
+ double theta_base = PI/4;
+ // theta_base = 0;
+
+ double theta_vec [size];
+ for (int i = 0; i < size; i++) {
+ int m = i - (2 * n + 1);
+ theta_vec[i] = atan (static_cast<double>(2 * m) / size);
+ }
+
+ if (opt_xy) {
+ int m;
+ for (m = 0; m < size; m++) {
+ double step = d * cos(theta_vec[m]);
+ for (int id = min; id <= max; id++) {
+ double r = id * step;
+ double x = r * cos(theta_vec[m] + theta_base);
+ double y = r * sin(theta_vec[m] + theta_base);
+ printf ("%lf,%lf ", x, y);
+ }
+ printf ("\n");
+ }
+
+ for (m = 0; m < size; m++) {
+ double step = d * cos(theta_vec[m]);
+ for (int id = min; id <= max; id++) {
+ double r = id * step;
+ double x = r * cos(theta_vec[m] + PI/2 + theta_base);
+ double y = r * sin(theta_vec[m] + PI/2 + theta_base);
+ printf ("%lf,%lf ", x, y);
+ }
+ printf ("\n");
+ }
+ } else {
+ int m;
+ for (m = 0; m < size; m++) {
+ if (! opt_polar_rt)
+ printf ("%lf: ", theta_vec[m] + theta_base);
+ double step = d * cos(theta_vec[m]);
+ for (int id = min; id <= max; id++) {
+ if (opt_polar_rt)
+ printf ("%lf,", theta_vec[m] + theta_base);
+ printf ("%lf ", id * step);
+ }
+ printf ("\n");
+ }
+
+ for (m = 0; m < size; m++) {
+ if (! opt_polar_rt)
+ printf ("%lf: ", theta_vec[m] + PI/2 + theta_base);
+ double step = d * cos(theta_vec[m]);
+ for (int id = min; id <= max; id++) {
+ if (opt_polar_rt)
+ printf ("%lf,", theta_vec[m] + PI/2 + theta_base);
+ printf ("%lf ", id * step);
+ }
+ printf ("\n");