-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathballplot.cpp
More file actions
272 lines (241 loc) · 10.4 KB
/
ballplot.cpp
File metadata and controls
272 lines (241 loc) · 10.4 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
/*============================================================================
* Daniel J. Greenhoe
*============================================================================*/
/*=====================================
* headers
*=====================================*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include "main.h"
#include "r1.h"
#include "r2.h"
#include "r3.h"
#include "r4.h"
#include "r6.h"
#include "elliptic.h"
#include "larc.h"
#include "mca.h"
#include "euclid.h"
/*=====================================
* function prototypes
*=====================================*/
int plot_print_header(FILE *fptr, const time_t time1, const char *comment, FILE *lptr);
int plot_log_header(FILE *fptr);
int plot_dna_seq(const unsigned seed, int N, const char *filename);
/*-------------------------------------------------------------------------
* compute metric ball with center <p> and radius <r>
* using Balloon metric (deprecated metric)
*-------------------------------------------------------------------------*/
int plot_balloon_metric_ball(vectR2 p, double r, FILE *fptr){
ellipsec ellipse;
time_t time1,time2;
struct tm *gmt;
double seconds;
double x,y,d;
vectR2 q;
time(&time1);
gmt = gmtime(&time1);
fprintf(fptr,"%%========================================================================\n");
fprintf(fptr,"%% Daniel J. Greenhoe \n");
fprintf(fptr,"%% The command \\fileplot{<filename>} may be used in a LaTeX environment\n");
fprintf(fptr,"%% for plotting data.\n");
fprintf(fptr,"%% \\fileplot is available in the LaTeX PSTricks package.\n");
fprintf(fptr,"%% References: http://www.ctan.org/pkg/pstricks-base\n");
fprintf(fptr,"%% http://www.ctan.org/pkg/pstricks-add\n");
//fprintf(fptr,"%% %4d %2d %2d %2d:%2d\n",gmt->tm_year,gmt->tm_mon,gmt->tm_hour,gmt->tm_hour,gmt->tm_min);
fprintf(fptr,"%% GMT %s",asctime(gmt));
fprintf(fptr,"%%========================================================================\n");
fprintf(fptr,"[\n");
for (x=-5;x<=5;x+=0.03){
for (y=-5;y<=5;y+=0.03){
q.put(x,y);
d=metric_balloon(p,q);
if(d<=r)fprintf(fptr,"(%9.6lf,%9.6lf) %%=(x,y); p=(%9.6lf,%9.6lf) d(p,q)=%9.6lf\n",q.getx(),q.gety(),p.getx(),p.gety(),d);
}
printf(":");
}
fprintf(fptr,"]\n");
time(&time2);
gmt = gmtime(&time2);
seconds = difftime(time2,time1);
fprintf(fptr,"%%========================================================================\n");
fprintf(fptr,"%% end data \n");
fprintf(fptr,"%% GMT %s",asctime(gmt));
fprintf(fptr,"%% (%.0lf seconds ellapsed)\n",seconds);
fprintf(fptr,"%%========================================================================\n");
return 0;
}
/*-------------------------------------------------------------------------
* compute Lebesgue arc metric ball in R^2 with center <p> and radius <r>
* using Lebesgue arc metric
*-------------------------------------------------------------------------*/
int plot_larc_ball(vectR2 p, double r, FILE *fptr){
ellipsec ellipse;
time_t time1,time2;
struct tm *gmt;
double seconds;
double x,y,d;
vectR2 q;
time(&time1);
gmt = gmtime(&time1);
fprintf(fptr,"%%========================================================================\n");
fprintf(fptr,"%% Daniel J. Greenhoe \n");
fprintf(fptr,"%% data file for plotting Lebesgue Arc metric ball\n");
fprintf(fptr,"%% The command \\fileplot{<filename>} may be used in a LaTeX environment\n");
fprintf(fptr,"%% for plotting data.\n");
fprintf(fptr,"%% \\fileplot is available in the LaTeX PSTricks package.\n");
fprintf(fptr,"%% Reference: http://www.ctan.org/pkg/pstricks-base\n");
//fprintf(fptr,"%% %4d %2d %2d %2d:%2d\n",gmt->tm_year,gmt->tm_mon,gmt->tm_hour,gmt->tm_hour,gmt->tm_min);
fprintf(fptr,"%% GMT %s",asctime(gmt));
fprintf(fptr,"%%========================================================================\n");
fprintf(fptr,"[\n");
for (x=-3;x<=5;x+=0.025){
for (y=-3;y<=5;y+=0.025){
q.put(x,y);
d=larc_metric(p,q);
if(d<=r)fprintf(fptr,"(%9.6lf,%9.6lf) %%=(x,y); p=(%9.6lf,%9.6lf) d(p,q)=%9.6lf\n",q.getx(),q.gety(),p.getx(),p.gety(),d);
}
printf(":");
}
fprintf(fptr,"]\n");
time(&time2);
gmt = gmtime(&time2);
seconds = difftime(time2,time1);
fprintf(fptr,"%%========================================================================\n");
fprintf(fptr,"%% end data \n");
fprintf(fptr,"%% GMT %s",asctime(gmt));
fprintf(fptr,"%% (%.0lf seconds ellapsed)\n",seconds);
fprintf(fptr,"%%========================================================================\n");
return 0;
}
/*-------------------------------------------------------------------------
* compute Lebesgue arc metric ball in R^3 with center <p> and radius <r>
* using Lebesgue arc metric
*-------------------------------------------------------------------------*/
int plot_larc_ball(vectR3 p, double r, FILE *fptr){
time_t time1,time2;
struct tm *gmt;
double seconds;
double theta,phi;
vectR3 q;
const double minrq = 0.0;
const double maxrq = 1.0e6;
const double maxerror = 1.0e6;
const long int N = 1000;
time(&time1);
gmt = gmtime(&time1);
fprintf(fptr,"%%========================================================================\n");
fprintf(fptr,"%% Daniel J. Greenhoe \n");
fprintf(fptr,"%% data file for plotting Lebesgue Arc metric ball in R^3\n");
fprintf(fptr,"%% The tikzpicture environment may be used in LaTeX\n");
fprintf(fptr,"%% for plotting data.\n");
fprintf(fptr,"%% tikzpicture is available in the LaTeX pgfplots package.\n");
fprintf(fptr,"%% Reference:\n");
fprintf(fptr,"%% ftp://ftp.ccu.edu.tw/pub/tex/graphics/pgf/contrib/pgfplots/doc/pgfplots.pdf\n");
fprintf(fptr,"%% GMT %s",asctime(gmt));
fprintf(fptr,"%%========================================================================\n");
for(phi=PI/2; phi>=-PI/2; phi-=PI/18){
for(theta=0; theta<2*PI; theta+=2*PI/36){
//q = larc_findq( p, theta, phi, r, 1000);
q = larc_findq( p, theta, phi, r, minrq, maxrq, maxerror, N );
fprintf(fptr,"%9.6lf %9.6lf %9.6lf %%=q; p=(%9.6lf,%9.6lf,%9.6lf)\n",q.getx(),q.gety(),q.getz(),p.getx(),p.gety(),p.getz());
}
fprintf(fptr,"\n");
printf(":");
}
time(&time2);
gmt = gmtime(&time2);
seconds = difftime(time2,time1);
fprintf(fptr,"%%========================================================================\n");
fprintf(fptr,"%% end data \n");
fprintf(fptr,"%% GMT %s",asctime(gmt));
fprintf(fptr,"%% (%.0lf seconds ellapsed)\n",seconds);
fprintf(fptr,"%%========================================================================\n");
return 0;
}
/*-------------------------------------------------------------------------
* compute alpha-scaled Euclidean metric ball in R^3
* with center <p> and radius <r> using Euclidean metric
*-------------------------------------------------------------------------*/
int plot_euclidean_metric_ball(double alpha, vectR3 p, double r, FILE *fptr){
time_t time1,time2;
struct tm *gmt;
double seconds;
double theta,phi;
vectR3 q;
time(&time1);
gmt = gmtime(&time1);
fprintf(fptr,"%%========================================================================\n");
fprintf(fptr,"%% Daniel J. Greenhoe \n");
fprintf(fptr,"%% data file for plotting an %lf-scaled Euclidean metric ball in R^3\n",alpha);
fprintf(fptr,"%% The tikzpicture environment may be used in LaTeX\n");
fprintf(fptr,"%% for plotting data.\n");
fprintf(fptr,"%% tikzpicture is available in the LaTeX pgfplots package.\n");
fprintf(fptr,"%% Reference:\n");
fprintf(fptr,"%% ftp://ftp.ccu.edu.tw/pub/tex/graphics/pgf/contrib/pgfplots/doc/pgfplots.pdf\n");
fprintf(fptr,"%% GMT %s",asctime(gmt));
fprintf(fptr,"%%========================================================================\n");
//fprintf(fptr,"\n");
for(phi=PI/2; phi>=-PI/2; phi-=PI/18){
for(theta=0; theta<2*PI; theta+=2*PI/36){
q=ae_findq(alpha,p,theta,phi,r,1000);
//fprintf(fptr,"%9.6lf %9.6lf %9.6lf\n",q.getx(),q.gety(),q.getz());
fprintf(fptr,"%9.6lf %9.6lf %9.6lf %%=q; p=(%9.6lf,%9.6lf,%9.6lf)\n",q.getx(),q.gety(),q.getz(),p.getx(),p.gety(),p.getz());
}
fprintf(fptr,"\n");
printf(":");
}
time(&time2);
gmt = gmtime(&time2);
seconds = difftime(time2,time1);
fprintf(fptr,"%%========================================================================\n");
fprintf(fptr,"%% end data \n");
fprintf(fptr,"%% GMT %s",asctime(gmt));
fprintf(fptr,"%% (%.0lf seconds ellapsed)\n",seconds);
fprintf(fptr,"%%========================================================================\n");
return 0;
}
/*-------------------------------------------------------------------------
* compute mean circular arc metric ball in R^2 with center <p> and radius <r>
*-------------------------------------------------------------------------*/
int plot_mca_metric_ball(vectR2 p, double r, FILE *fptr){
ellipsec ellipse;
time_t time1,time2;
struct tm *gmt;
double seconds;
double x,y,d;
vectR2 q;
time(&time1);
gmt = gmtime(&time1);
fprintf(fptr,"%%========================================================================\n");
fprintf(fptr,"%% Daniel J. Greenhoe \n");
fprintf(fptr,"%% data file for plotting Mean Circular Arc metric ball\n");
fprintf(fptr,"%% The command \\fileplot{<filename>} may be used in a LaTeX environment\n");
fprintf(fptr,"%% for plotting data.\n");
fprintf(fptr,"%% \\fileplot is available in the LaTeX PSTricks package.\n");
fprintf(fptr,"%% Reference: http://www.ctan.org/pkg/pstricks-base\n");
fprintf(fptr,"%% GMT %s",asctime(gmt));
fprintf(fptr,"%%========================================================================\n");
fprintf(fptr,"[\n");
for (x=-3;x<=5;x+=0.025){
for (y=-3;y<=5;y+=0.025){
q.put(x,y);
d=mca_metric(p,q);
if(d<=r)fprintf(fptr,"(%9.6lf,%9.6lf) %%=(x,y); p=(%9.6lf,%9.6lf) d(p,q)=%9.6lf\n",q.getx(),q.gety(),p.getx(),p.gety(),d);
}
printf(":");
}
fprintf(fptr,"]\n");
time(&time2);
gmt = gmtime(&time2);
seconds = difftime(time2,time1);
fprintf(fptr,"%%========================================================================\n");
fprintf(fptr,"%% end data \n");
fprintf(fptr,"%% GMT %s",asctime(gmt));
fprintf(fptr,"%% (%.0lf seconds ellapsed)\n",seconds);
fprintf(fptr,"%%========================================================================\n");
return 0;
}