void hyperbolic_coordinates() {
const double DIMX = 800; const double DIMY = 800;
const double B = 64; const double S = 128;
const double miu = -2; const double mau = 2;
const double miv = 0; const double mav = 8;
const int N = 24; const int M = 1024;
FILE * fp = fopen("c:\\temp\\hyperbolic_coordinates.svg","w");
fprintf(fp,
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"
"<svg\n"
"xmlns:svg=\"http://www.w3.org/2000/svg\"\n"
"xmlns=\"http://www.w3.org/2000/svg\"\n"
"version=\"1.0\"\n"
"width=\"%g\"\n"
"height=\"%g\"\n"
"id=\"rocco\">\n"
,DIMX,DIMY
);
fprintf(fp,"<g id=\"edge_layer1\" style=\"fill:none;stroke:#800000;stroke-width:1.5;stroke-opacity:1\">\n" );
int i,j;
for(j=0;j<N;++j) {
const double v = miv + (mav-miv)*double(j)/(N-1);
fprintf(fp, "<path d=\"" );
bool first = true;
for(i=0;i<M;++i) {
const double u = miu + (mau-miu)*double(i)/(M-1);
double x = v*exp( u); double y = v*exp(-u);
x = x*S+B; y = DIMY-(y*S+B);
if(x>=B && x<=DIMX-B && y>=B && y<=DIMY-B ) {
if(first) fprintf(fp,"M ");
else fprintf(fp,"L ");
fprintf(fp,"%g %g ",x,y);
first = false;
}
}
fprintf(fp,"\"/>\n");
}
fprintf(fp,
"</g>\n"
"<g id=\"edge_layer2\" style=\"fill:none;stroke:#000080;stroke-width:1.5;stroke-opacity:1\">\n"
);
for(i=0;i<N ;++i) {
const double u = miu + (mau-miu)*double(i)/(N-1);
fprintf(fp, "<path d=\"");
bool first = true;
for(j=0;j<M;++j) {
const double v = miv + (mav-miv)*double(j)/(M-1);
double x = v*exp( u); double y = v*exp(-u);
x = x*S+B; y = DIMY-(y*S+B);
if(x>=B && x<=DIMX-B && y>=B && y<=DIMY-B ) {
if(first) fprintf(fp,"M ");
else fprintf(fp,"L ");
fprintf(fp,"%g %g ",x,y);
first = false;
}
}
fprintf(fp,"\"/>\n");
}
fprintf(fp,
"</g>\n"
"</svg>\n"
);
fclose(fp);
}