Add files via upload
This commit is contained in:
462
sub_sphere.c
462
sub_sphere.c
@@ -71,9 +71,15 @@ void init_wave_sphere(t_wave_sphere wsphere[NX*NY])
|
||||
}
|
||||
|
||||
/* cotangent, taking care of not dividing by zero */
|
||||
for (j=1; j<NY-1; j++) wsphere[i*NY+j].cottheta = wsphere[i*NY+j].ctheta/wsphere[i*NY+j].stheta;
|
||||
wsphere[i*NY].cottheta = wsphere[i*NY+1].cottheta;
|
||||
wsphere[i*NY + NY-1].cottheta = wsphere[i*NY+1].cottheta;
|
||||
/* TODO clean up cottheta range ? */
|
||||
for (j=DPOLE; j<NY-DPOLE; j++) wsphere[i*NY+j].cottheta = wsphere[i*NY+j].ctheta/wsphere[i*NY+j].stheta;
|
||||
for (j=0; j<DPOLE; j++) wsphere[i*NY+j].cottheta = wsphere[i*NY+DPOLE].cottheta;
|
||||
for (j=NY-DPOLE; j<NY; j++) wsphere[i*NY+j].cottheta = wsphere[i*NY+DPOLE-1].cottheta;
|
||||
|
||||
/* old version */
|
||||
// for (j=1; j<NY-1; j++) wsphere[i*NY+j].cottheta = wsphere[i*NY+j].ctheta/wsphere[i*NY+j].stheta;
|
||||
// wsphere[i*NY].cottheta = wsphere[i*NY+1].cottheta;
|
||||
// wsphere[i*NY + NY-1].cottheta = wsphere[i*NY+1].cottheta;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,9 +235,9 @@ void read_negative_dem_values(double *height_values, t_wave_sphere wsphere[NX*NY
|
||||
void init_dem(t_wave_sphere wsphere[NX*NY], int dem_number)
|
||||
/* init heights from digital elevation map */
|
||||
{
|
||||
int i, j, ii, jj, k, nx, ny, maxrgb, nmaxpixels = 4915200, scan, rgbval, diff, sshift, nshift, hmin, hmax, ishift;
|
||||
int i, j, ii, jj, k, nx, ny, maxrgb, nmaxpixels = 4915200, scan, rgbval, diff, sshift, nshift, hmin, hmax, ishift, hsum;
|
||||
int *rgb_values;
|
||||
double cratio, rx, ry, cy, dx, dy, pscal, norm, vscale1, vscale2, gradx, grady, deltar, deltai[3], deltaj[3], dphi, dtheta, n[3], hsea;
|
||||
double cratio, rx, ry, cy, dx, dy, pscal, norm, vscale1, vscale2, gradx, grady, deltar, deltai[3], deltaj[3], dphi, dtheta, n[3], hsea, hmean;
|
||||
double *height_values, *height_values_tmp;
|
||||
FILE *image_file;
|
||||
|
||||
@@ -259,6 +265,20 @@ void init_dem(t_wave_sphere wsphere[NX*NY], int dem_number)
|
||||
hsea = 255.0*PLANET_SEALEVEL/DEM_MAXHEIGHT;
|
||||
break;
|
||||
}
|
||||
case (DEM_VENUS):
|
||||
{
|
||||
nmaxpixels = 4096*2048;
|
||||
image_file = fopen("Venus_Magellan_Topography_Global_4641m_v02_scaled2.ppm", "r");
|
||||
hsea = 255.0*PLANET_SEALEVEL/DEM_MAXHEIGHT;
|
||||
break;
|
||||
}
|
||||
case (DEM_MERCURY):
|
||||
{
|
||||
nmaxpixels = 1280*380;
|
||||
image_file = fopen("Mercury_Messenger_DEM_Global_665m_1024_1_cropped.ppm", "r");
|
||||
hsea = 255.0*PLANET_SEALEVEL/DEM_MAXHEIGHT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
rgb_values = (int *)malloc(3*nmaxpixels*sizeof(int));
|
||||
@@ -269,6 +289,9 @@ void init_dem(t_wave_sphere wsphere[NX*NY], int dem_number)
|
||||
scan = fscanf(image_file,"%i %i\n", &nx, &ny);
|
||||
scan = fscanf(image_file,"%i\n", &maxrgb);
|
||||
|
||||
printf("nx = %i, ny = %i, maxrgb = %i\n", nx, ny, maxrgb);
|
||||
sleep(1);
|
||||
|
||||
hmin = maxrgb;
|
||||
hmax = 0;
|
||||
|
||||
@@ -294,12 +317,29 @@ void init_dem(t_wave_sphere wsphere[NX*NY], int dem_number)
|
||||
{
|
||||
scan = fscanf(image_file,"%i\n", &rgbval);
|
||||
rgb_values[3*(j*nx+i)+k] = rgbval;
|
||||
if (rgbval < hmin) hmin = rgbval;
|
||||
if (rgbval < hmin)
|
||||
{
|
||||
if (B_DOMAIN == D_SPHERE_VENUS)
|
||||
{
|
||||
if (rgbval > 0) hmin = rgbval;
|
||||
}
|
||||
else hmin = rgbval;
|
||||
}
|
||||
if (rgbval > hmax) hmax = rgbval;
|
||||
}
|
||||
|
||||
printf("hmin = %i, hmax = %i, hsea = %i\n", hmin, hmax, (int)hsea);
|
||||
|
||||
|
||||
if (B_DOMAIN == D_SPHERE_VENUS)
|
||||
{
|
||||
hsum = 0;
|
||||
for (j=0; j<ny; j++)
|
||||
for (i=0; i<nx; i++)
|
||||
hsum += rgb_values[3*(j*nx+i)];
|
||||
hmean = (double)hsum/(double)(nx*ny);
|
||||
printf("hmean = %.2f\n", hmean);
|
||||
}
|
||||
|
||||
cratio = 1.0/(double)(hmax-hmin);
|
||||
rx = (double)nx/(double)NX;
|
||||
ry = (double)ny/(double)(NY - sshift - nshift);
|
||||
@@ -317,6 +357,13 @@ void init_dem(t_wave_sphere wsphere[NX*NY], int dem_number)
|
||||
height_values[i*NY+j] = ((double)rgb_values[3*(jj*nx+ii)]-hsea)*cratio;
|
||||
wsphere[i*NY+j].altitude = ((double)rgb_values[3*(jj*nx+ii)]-hsea)*cratio;
|
||||
|
||||
/* take care of black areas (missing data) on venus */
|
||||
if ((B_DOMAIN == D_SPHERE_VENUS)&&(rgb_values[3*(jj*nx+ii)] == 0))
|
||||
{
|
||||
height_values[i*NY+j] = VENUS_NODATA_FACTOR*hmean*cratio;
|
||||
wsphere[i*NY+j].altitude = VENUS_NODATA_FACTOR*hmean*cratio;
|
||||
}
|
||||
|
||||
if (OTHER_PLANET)
|
||||
wsphere[i*NY+j].indomain = (wsphere[i*NY+j].altitude < 0.0);
|
||||
|
||||
@@ -712,6 +759,22 @@ void init_planet_map(t_wave_sphere wsphere[NX*NY], int planet)
|
||||
dem_number = DEM_MOON;
|
||||
break;
|
||||
}
|
||||
case (D_SPHERE_VENUS):
|
||||
{
|
||||
printf("Reading Venus map\n");
|
||||
nmaxpixels = 1440*720;
|
||||
image_file = fopen("Venus_map_NASA_JPL_Magellan-Venera-Pioneer.ppm", "r");
|
||||
dem_number = DEM_VENUS;
|
||||
break;
|
||||
}
|
||||
case (D_SPHERE_MERCURY):
|
||||
{
|
||||
printf("Reading Mercury map\n");
|
||||
nmaxpixels = 2304*1152;
|
||||
image_file = fopen("Mercury_color_photo.ppm", "r");
|
||||
dem_number = DEM_MERCURY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
scan = fscanf(image_file,"%i %i\n", &nx, &ny);
|
||||
@@ -833,6 +896,34 @@ int ij_to_sphere(int i, int j, double r, t_wave_sphere wsphere[NX*NY], double xy
|
||||
return(pscal/norm_observer > COS_VISIBLE);
|
||||
}
|
||||
|
||||
|
||||
int ij_to_sphere_r(int i, int j, double r, t_wave_sphere wsphere[NX*NY], double xyz[3])
|
||||
/* convert spherical to rectangular coordinates */
|
||||
{
|
||||
double pscal, newr;
|
||||
static double norm_observer;
|
||||
static int first = 1;
|
||||
|
||||
if (first)
|
||||
{
|
||||
norm_observer = sqrt(observer[0]*observer[0] + observer[1]*observer[1] + observer[2]*observer[2]);
|
||||
first = 0;
|
||||
}
|
||||
|
||||
xyz[0] = wsphere[i*NY+j].x;
|
||||
xyz[1] = wsphere[i*NY+j].y;
|
||||
xyz[2] = wsphere[i*NY+j].z;
|
||||
|
||||
pscal = xyz[0]*observer[0] + xyz[1]*observer[1] + xyz[2]*observer[2];
|
||||
|
||||
xyz[0] *= r;
|
||||
xyz[1] *= r;
|
||||
xyz[2] *= r;
|
||||
|
||||
return(pscal/norm_observer > COS_VISIBLE);
|
||||
}
|
||||
|
||||
|
||||
int init_circle_sphere(t_circles_sphere *circles, int circle_pattern)
|
||||
/* initialise circles on sphere */
|
||||
/* for billiard shape D_SPHERE_CIRCLES */
|
||||
@@ -987,6 +1078,224 @@ int init_circle_sphere(t_circles_sphere *circles, int circle_pattern)
|
||||
return(ncircles);
|
||||
}
|
||||
|
||||
void init_sphere_maze(t_wave_sphere wsphere[NX*NY], int spiral, int wave, int npole)
|
||||
/* initialize maze on sphere */
|
||||
{
|
||||
int nblocks, block, i, j, k, n, p, q, np, na, inrect;
|
||||
double rmin, rmax, angle, r, dr, phi, dphi, phi1, ww, width = 0.02, theta, theta1, phaseshift;
|
||||
t_maze* maze;
|
||||
t_rectangle* polyrect;
|
||||
|
||||
maze = (t_maze *)malloc(NXMAZE*NYMAZE*sizeof(t_maze));
|
||||
polyrect = (t_rectangle *)malloc(NMAXPOLY*sizeof(t_rectangle));
|
||||
|
||||
printf("Initializing maze\n");
|
||||
init_circular_maze(maze);
|
||||
printf("Maze initialized\n");
|
||||
|
||||
printf("Building maze walls\n");
|
||||
/* build walls of maze */
|
||||
|
||||
np = 0;
|
||||
na = 0;
|
||||
|
||||
/* build walls of maze */
|
||||
nblocks = NYMAZE/NXMAZE;
|
||||
rmin = 0.3;
|
||||
rmax = PID + 0.2;
|
||||
angle = DPI/(double)nblocks;
|
||||
|
||||
dr = (rmax - rmin)/(double)(NXMAZE);
|
||||
|
||||
/* add straight walls */
|
||||
for (block = 0; block < nblocks; block++)
|
||||
{
|
||||
printf("Block %i\n", block);
|
||||
dphi = angle;
|
||||
|
||||
/* first circle */
|
||||
n = nmaze(0, block*NXMAZE);
|
||||
r = rmin - 0.5*width;
|
||||
phi = (double)block*angle;
|
||||
|
||||
if (maze[n].south)
|
||||
{
|
||||
polyrect[np].x1 = phi - 0.5*width;
|
||||
polyrect[np].y1 = r;
|
||||
polyrect[np].x2 = phi + 0.5*width;
|
||||
polyrect[np].y2 = r+dr+width;
|
||||
// printf("Adding rectangle at (%.3f, %.3f) - (%.3f, %.3f)\n", polyrect[np].x1, polyrect[np].y1, polyrect[np].x2, polyrect[np].y2);
|
||||
np++;
|
||||
}
|
||||
|
||||
/* second circle */
|
||||
r = rmin + dr - 0.5*width;
|
||||
dphi *= 0.5;
|
||||
for (q=0; q<2; q++)
|
||||
{
|
||||
n = nmaze(1, block*NXMAZE + q);
|
||||
phi = (double)(block)*angle + (double)q*dphi;
|
||||
|
||||
if (maze[n].south)
|
||||
{
|
||||
polyrect[np].x1 = phi - 0.5*width;
|
||||
polyrect[np].y1 = r;
|
||||
polyrect[np].x2 = phi + 0.5*width;
|
||||
polyrect[np].y2 = r+dr+width;
|
||||
// printf("Adding rectangle at (%.3f, %.3f) - (%.3f, %.3f)\n", polyrect[np].x1, polyrect[np].y1, polyrect[np].x2, polyrect[np].y2);
|
||||
np++;
|
||||
}
|
||||
}
|
||||
|
||||
/* other circles */
|
||||
ww = 2;
|
||||
i = 2;
|
||||
while (ww < NXMAZE)
|
||||
{
|
||||
dphi *= 0.5;
|
||||
for (p = 0; p < ww; p++)
|
||||
{
|
||||
r = rmin + (double)i*dr - 0.5*width;
|
||||
// printf("Segment, i = %i, dphi = %.2lg, r = %.2lg\n", i, dphi, r);
|
||||
for (q = 0; q < 2*ww; q++)
|
||||
{
|
||||
j = block*NXMAZE + q;
|
||||
n = nmaze(i,j);
|
||||
phi = (double)(block)*angle + (double)q*dphi;
|
||||
|
||||
if (maze[n].south)
|
||||
{
|
||||
polyrect[np].x1 = phi - 0.5*width;
|
||||
polyrect[np].y1 = r;
|
||||
polyrect[np].x2 = phi + 0.5*width;
|
||||
polyrect[np].y2 = r+dr+width;
|
||||
// printf("Adding rectangle at (%.3f, %.3f) - (%.3f, %.3f)\n", polyrect[np].x1, polyrect[np].y1, polyrect[np].x2, polyrect[np].y2);
|
||||
np++;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
ww *= 2;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* add circular arcs */
|
||||
for (block = 0; block < nblocks; block++)
|
||||
{
|
||||
dphi = angle;
|
||||
|
||||
/* first circle */
|
||||
n = nmaze(0, block*NXMAZE);
|
||||
r = rmin;
|
||||
phi = (double)block*angle;
|
||||
|
||||
if ((block > 0)&&(maze[n].west))
|
||||
{
|
||||
polyrect[np].x1 = phi;
|
||||
polyrect[np].y1 = r - 0.5*width;
|
||||
polyrect[np].x2 = phi + dphi + 0.05*width;
|
||||
polyrect[np].y2 = r + 0.5*width;
|
||||
np++;
|
||||
}
|
||||
|
||||
/* second circle */
|
||||
r = rmin + dr;
|
||||
dphi *= 0.5;
|
||||
for (q=0; q<2; q++)
|
||||
{
|
||||
n = nmaze(1, block*NXMAZE + q);
|
||||
phi = (double)(block)*angle + (double)q*dphi;
|
||||
|
||||
if (maze[n].west)
|
||||
{
|
||||
polyrect[np].x1 = phi;
|
||||
polyrect[np].y1 = r - 0.5*width;
|
||||
polyrect[np].x2 = phi + dphi + 0.05*width;
|
||||
polyrect[np].y2 = r + 0.5*width;
|
||||
np++;
|
||||
}
|
||||
}
|
||||
|
||||
/* other circles */
|
||||
ww = 2;
|
||||
i = 2;
|
||||
while (ww < NXMAZE)
|
||||
{
|
||||
dphi *= 0.5;
|
||||
for (p = 0; p < ww; p++)
|
||||
{
|
||||
r = rmin + (double)i*dr;
|
||||
printf("Circle, i = %i, dphi = %.2lg, r = %.2lg\n", i, dphi, r);
|
||||
for (q = 0; q < 2*ww; q++)
|
||||
{
|
||||
j = block*NXMAZE + q;
|
||||
n = nmaze(i,j);
|
||||
phi = (double)(block)*angle + (double)q*dphi;
|
||||
|
||||
if (maze[n].west)
|
||||
{
|
||||
polyrect[np].x1 = phi;
|
||||
polyrect[np].y1 = r - 0.5*width;
|
||||
polyrect[np].x2 = phi + dphi + 0.05*width;
|
||||
polyrect[np].y2 = r + 0.5*width;
|
||||
np++;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
ww *= 2;
|
||||
}
|
||||
}
|
||||
|
||||
/* outer boundary of maze */
|
||||
polyrect[np].x1 = dphi;
|
||||
polyrect[np].y1 = rmax - 0.5*width;
|
||||
polyrect[np].x2 = DPI;
|
||||
polyrect[np].y2 = rmax + 0.5*width;
|
||||
np++;
|
||||
|
||||
|
||||
printf("Maze walls built\n");
|
||||
|
||||
phaseshift = ZERO_MERIDIAN*PI/180.0;
|
||||
for (i=0; i<NX; i++)
|
||||
{
|
||||
phi = DPI*(double)i/(double)NX + phaseshift;
|
||||
if (phi > DPI) phi -= DPI;
|
||||
for (j=0; j<NY; j++)
|
||||
{
|
||||
theta = PI*(1.0 - (double)j/(double)NY);
|
||||
if (spiral)
|
||||
{
|
||||
phi -= PID/(double)NY;
|
||||
if (phi < 0.0) phi += DPI;
|
||||
}
|
||||
if (wave)
|
||||
{
|
||||
theta1 = theta;
|
||||
theta += 0.03*cos(6.0*phi)*theta;
|
||||
if (theta > PI) theta = PI;
|
||||
phi += 0.00075*cos(20.0*theta1)*theta1;
|
||||
// if (phi > DPI) phi -= DPI;
|
||||
if (phi < 0.0) phi += DPI;
|
||||
}
|
||||
inrect = 0;
|
||||
for (n=0; n<np; n++) for (k=-1; k<2; k++)
|
||||
{
|
||||
phi1 = phi + k*DPI;
|
||||
if (((phi1 > polyrect[n].x1)&&(phi1 < polyrect[n].x2)&&(theta > polyrect[n].y1)&&(theta < polyrect[n].y2))) inrect = 1;
|
||||
}
|
||||
wsphere[i*NY+j].indomain = 1-inrect;
|
||||
}
|
||||
if (npole) for (j=NY-DPOLE*3/2; j<NY; j++) wsphere[i*NY+j].indomain = 0;
|
||||
}
|
||||
|
||||
free(maze);
|
||||
free(polyrect);
|
||||
|
||||
}
|
||||
|
||||
int xy_in_billiard_sphere(int i, int j, t_wave_sphere wsphere[NX*NY])
|
||||
/* returns 1 if (x,y) represents a point in the billiard */
|
||||
{
|
||||
@@ -1004,6 +1313,9 @@ int xy_in_billiard_sphere(int i, int j, t_wave_sphere wsphere[NX*NY])
|
||||
cos_rot = cos(JULIA_ROT*DPI/360.0);
|
||||
sin_rot = sin(JULIA_ROT*DPI/360.0);
|
||||
}
|
||||
else if (B_DOMAIN == D_SPHERE_MAZE) init_sphere_maze(wsphere, 0, 0, 0);
|
||||
else if (B_DOMAIN == D_SPHERE_MAZE_SPIRAL) init_sphere_maze(wsphere, 1, 0, 1);
|
||||
else if (B_DOMAIN == D_SPHERE_MAZE_WAVE) init_sphere_maze(wsphere, 0, 1, 1);
|
||||
first = 0;
|
||||
}
|
||||
|
||||
@@ -1088,22 +1400,9 @@ int xy_in_billiard_sphere(int i, int j, t_wave_sphere wsphere[NX*NY])
|
||||
if (u*u + v*v < MANDELLIMIT) return(1);
|
||||
return(0);
|
||||
}
|
||||
case (D_SPHERE_EARTH):
|
||||
{
|
||||
return(wsphere[i*NY+j].indomain);
|
||||
}
|
||||
case (D_SPHERE_MARS):
|
||||
{
|
||||
return(wsphere[i*NY+j].indomain);
|
||||
}
|
||||
case (D_SPHERE_MOON):
|
||||
{
|
||||
return(wsphere[i*NY+j].indomain);
|
||||
}
|
||||
default:
|
||||
{
|
||||
printf("Function xy_in_billiard_sphere not defined for this billiard \n");
|
||||
return(0);
|
||||
return(wsphere[i*NY+j].indomain);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1204,19 +1503,23 @@ void init_circular_wave_sphere(double phi0, double theta0, double phi[NX*NY], do
|
||||
/* initialise field with drop - phi is wave height, psi is phi at time t-1 */
|
||||
/* phi0 is longidude, theta0 is latitude */
|
||||
{
|
||||
int i, j;
|
||||
int i, j, jmin, jmax;
|
||||
double xy[2], pscal, dist, dist2, stheta, ctheta, phishift;
|
||||
|
||||
ctheta = cos(theta0 + PID);
|
||||
stheta = sin(theta0 + PID);
|
||||
phishift = ZERO_MERIDIAN*PI/180.0;
|
||||
|
||||
/* safety distance to avoid singularity at poles */
|
||||
jmin = DPOLE;
|
||||
jmax = NY-DPOLE;
|
||||
|
||||
printf("Initializing wave\n");
|
||||
// #pragma omp parallel for private(i,j,xy,dist2)
|
||||
for (i=0; i<NX; i++)
|
||||
{
|
||||
if (i%100 == 0) printf("Initializing column %i of %i\n", i, NX);
|
||||
for (j=0; j<NY; j++)
|
||||
for (j=jmin; j<jmax; j++)
|
||||
{
|
||||
pscal = cos(wsphere[i*NY+j].phi - phi0 - phishift)*wsphere[i*NY+j].stheta*stheta;
|
||||
pscal += wsphere[i*NY+j].ctheta*ctheta;
|
||||
@@ -1231,6 +1534,16 @@ void init_circular_wave_sphere(double phi0, double theta0, double phi[NX*NY], do
|
||||
else phi[i*NY+j] = 0.0;
|
||||
psi[i*NY+j] = 0.0;
|
||||
}
|
||||
for (j=0; j<jmin; j++)
|
||||
{
|
||||
phi[i*NY+j] = 0.0;
|
||||
psi[i*NY+j] = 0.0;
|
||||
}
|
||||
for (j=jmax; j<NY; j++)
|
||||
{
|
||||
phi[i*NY+j] = 0.0;
|
||||
psi[i*NY+j] = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1238,19 +1551,21 @@ void add_circular_wave_sphere(double amp, double phi0, double theta0, double phi
|
||||
/* initialise field with drop - phi is wave height, psi is phi at time t-1 */
|
||||
/* phi0 is longidude, theta0 is latitude */
|
||||
{
|
||||
int i, j;
|
||||
int i, j, jmin, jmax;
|
||||
double xy[2], pscal, dist, dist2, stheta, ctheta, phishift;
|
||||
|
||||
ctheta = cos(theta0 + PID);
|
||||
stheta = sin(theta0 + PID);
|
||||
phishift = ZERO_MERIDIAN*PI/180.0;
|
||||
|
||||
printf("Initializing wave\n");
|
||||
// #pragma omp parallel for private(i,j,xy,dist2)
|
||||
/* safety distance to avoid singularity at poles */
|
||||
jmin = DPOLE;
|
||||
jmax = NY-DPOLE;
|
||||
|
||||
#pragma omp parallel for private(i,j,xy,dist2)
|
||||
for (i=0; i<NX; i++)
|
||||
{
|
||||
if (i%100 == 0) printf("Initializing column %i of %i\n", i, NX);
|
||||
for (j=0; j<NY; j++)
|
||||
for (j=jmin; j<jmax; j++)
|
||||
{
|
||||
pscal = cos(wsphere[i*NY+j].phi - phi0 - phishift)*wsphere[i*NY+j].stheta*stheta;
|
||||
pscal += wsphere[i*NY+j].ctheta*ctheta;
|
||||
@@ -1260,8 +1575,6 @@ void add_circular_wave_sphere(double amp, double phi0, double theta0, double phi
|
||||
|
||||
if ((xy_in[i*NY+j])||(TWOSPEEDS))
|
||||
phi[i*NY+j] += amp*INITIAL_AMP*exp(-dist2/INITIAL_VARIANCE)*cos(-sqrt(dist2)/INITIAL_WAVELENGTH);
|
||||
else phi[i*NY+j] = 0.0;
|
||||
psi[i*NY+j] = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1284,13 +1597,23 @@ void compute_light_angle_sphere(short int xy_in[NX*NY], t_wave wave[NX*NY], t_wa
|
||||
|
||||
#pragma omp parallel for private(i,j)
|
||||
for (i=0; i<NX; i++)
|
||||
for (j=0; j<NY; j++) if (xy_in[i*NY+j])
|
||||
{
|
||||
for (j=0; j<NY - DPOLE; j++) if (xy_in[i*NY+j])
|
||||
{
|
||||
r = 1.0 + RSCALE*(*wave[i*NY+j].p_zfield[movie]);
|
||||
if (r > RMAX) r = RMAX;
|
||||
if (r < RMIN) r = RMIN;
|
||||
wsphere[i*NY+j].radius = r;
|
||||
}
|
||||
|
||||
/* TODO ? Avoid artifacts due to singularity at north pole */
|
||||
for (j=NY - DPOLE; j<NY; j++) if (xy_in[i*NY+j])
|
||||
{
|
||||
r = 1.0 + RSCALE*(*wave[i*NY+j].p_zfield[movie]);
|
||||
if (r > RMAX) r = RMAX;
|
||||
if (r < 1.0) r = 1.0;
|
||||
wsphere[i*NY+j].radius = r;
|
||||
}
|
||||
}
|
||||
|
||||
if (SHADE_WAVE)
|
||||
{
|
||||
@@ -1523,9 +1846,12 @@ void draw_wave_sphere_ij(int i, int iplus, int j, int jplus, int jcolor, int mov
|
||||
/* draw wave at simulation grid point (i,j) */
|
||||
{
|
||||
int k, l;
|
||||
short int draw;
|
||||
short int draw, draw_bc=1;
|
||||
double xyz[3], ca;
|
||||
|
||||
if (NON_DIRICHLET_BC)
|
||||
draw_bc = (xy_in[i*NY+j])&&(xy_in[iplus*NY+j])&&(xy_in[i*NY+jplus])&&(xy_in[iplus*NY+jplus]);
|
||||
|
||||
// if ((TWOSPEEDS)||(xy_in[i*NY+j]))
|
||||
// if (wsphere[i*NY+j].indomain)
|
||||
// if ((wsphere[i*NY+j].indomain)||(phi[i*NY+j] >= wsphere[i*NY+j].altitude + 0.001))
|
||||
@@ -1542,22 +1868,25 @@ void draw_wave_sphere_ij(int i, int iplus, int j, int jplus, int jcolor, int mov
|
||||
glColor3f(wsphere[i*NY+j].r*ca, wsphere[i*NY+j].g*ca, wsphere[i*NY+j].b*ca);
|
||||
else glColor3f(COLOR_OUT_R*ca, COLOR_OUT_G*ca, COLOR_OUT_B*ca);
|
||||
}
|
||||
glBegin(GL_TRIANGLE_FAN);
|
||||
if (ij_to_sphere(i, j, *wave[i*NY+j].p_zfield[movie], wsphere, xyz))
|
||||
draw_vertex_sphere(xyz);
|
||||
if (ij_to_sphere(iplus, j, *wave[iplus*NY+j].p_zfield[movie], wsphere, xyz))
|
||||
draw_vertex_sphere(xyz);
|
||||
if (ij_to_sphere(iplus, jplus, *wave[iplus*NY+j+1].p_zfield[movie], wsphere, xyz))
|
||||
draw_vertex_sphere(xyz);
|
||||
if (ij_to_sphere(i, jplus, *wave[i*NY+j+1].p_zfield[movie], wsphere, xyz))
|
||||
draw_vertex_sphere(xyz);
|
||||
glEnd ();
|
||||
if (draw_bc)
|
||||
{
|
||||
glBegin(GL_TRIANGLE_FAN);
|
||||
if (ij_to_sphere(i, j, *wave[i*NY+j].p_zfield[movie], wsphere, xyz))
|
||||
draw_vertex_sphere(xyz);
|
||||
if (ij_to_sphere(iplus, j, *wave[iplus*NY+j].p_zfield[movie], wsphere, xyz))
|
||||
draw_vertex_sphere(xyz);
|
||||
if (ij_to_sphere(iplus, jplus, *wave[iplus*NY+j+1].p_zfield[movie], wsphere, xyz))
|
||||
draw_vertex_sphere(xyz);
|
||||
if (ij_to_sphere(i, jplus, *wave[i*NY+j+1].p_zfield[movie], wsphere, xyz))
|
||||
draw_vertex_sphere(xyz);
|
||||
glEnd ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void draw_wave_sphere_3D(int movie, double phi[NX*NY], double psi[NX*NY], short int xy_in[NX*NY], t_wave wave[NX*NY], t_wave_sphere wsphere[NX*NY], int zplot, int cplot, int palette, int fade, double fade_value, int refresh)
|
||||
{
|
||||
int i, j, imax, imin;
|
||||
int i, j, imax, imin, jmax;
|
||||
double observer_angle, angle2;
|
||||
|
||||
blank();
|
||||
@@ -1581,6 +1910,9 @@ void draw_wave_sphere_3D(int movie, double phi[NX*NY], double psi[NX*NY], short
|
||||
if (imin >= NX-1) imin = NX-2;
|
||||
if (imax >= NX-1) imax = NX-2;
|
||||
|
||||
// jmax = NY-25;
|
||||
jmax = NY-3;
|
||||
|
||||
// printf("Angle = %.5lg, angle2 = %.5lg, imin = %i, imax = %i\n", observer_angle, angle2, imin, imax);
|
||||
|
||||
if (observer[2] > 0.0)
|
||||
@@ -1588,79 +1920,79 @@ void draw_wave_sphere_3D(int movie, double phi[NX*NY], double psi[NX*NY], short
|
||||
if (imin < imax)
|
||||
{
|
||||
for (i=imax; i>imin; i--)
|
||||
for (j=0; j<NY-2; j++)
|
||||
for (j=0; j<=jmax; j++)
|
||||
draw_wave_sphere_ij(i, i+1, j, j+1, j+1, movie, phi, psi, xy_in, wave, wsphere, zplot, cplot, palette, fade, fade_value);
|
||||
|
||||
for (i=imax+1; i<NX-1; i++)
|
||||
for (j=0; j<NY-2; j++)
|
||||
for (j=0; j<=jmax; j++)
|
||||
draw_wave_sphere_ij(i, i+1, j, j+1, j+1, movie, phi, psi, xy_in, wave, wsphere, zplot, cplot, palette, fade, fade_value);
|
||||
|
||||
for (j=0; j<NY-2; j++)
|
||||
for (j=0; j<=jmax; j++)
|
||||
draw_wave_sphere_ij(NX-1, 0, j, j+1, j+1, movie, phi, psi, xy_in, wave, wsphere, zplot, cplot, palette, fade, fade_value);
|
||||
|
||||
for (i=0; i<=imin; i++)
|
||||
for (j=0; j<NY-2; j++)
|
||||
for (j=0; j<=jmax; j++)
|
||||
draw_wave_sphere_ij(i, i+1, j, j+1, j+1, movie, phi, psi, xy_in, wave, wsphere, zplot, cplot, palette, fade, fade_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i=imax; i<imin; i++)
|
||||
for (j=0; j<NY-2; j++)
|
||||
for (j=0; j<=jmax; j++)
|
||||
draw_wave_sphere_ij(i, i+1, j, j+1, j+1, movie, phi, psi, xy_in, wave, wsphere, zplot, cplot, palette, fade, fade_value);
|
||||
|
||||
for (i=imax-1; i>=0; i--)
|
||||
for (j=0; j<NY-2; j++)
|
||||
for (j=0; j<=jmax; j++)
|
||||
draw_wave_sphere_ij(i, i+1, j, j+1, j+1, movie, phi, psi, xy_in, wave, wsphere, zplot, cplot, palette, fade, fade_value);
|
||||
|
||||
for (j=0; j<NY-2; j++)
|
||||
for (j=0; j<=jmax; j++)
|
||||
draw_wave_sphere_ij(NX-1, 0, j, j+1, j+1, movie, phi, psi, xy_in, wave, wsphere, zplot, cplot, palette, fade, fade_value);
|
||||
|
||||
for (i=NX-2; i>=imin; i--)
|
||||
for (j=0; j<NY-2; j++)
|
||||
for (j=0; j<=jmax; j++)
|
||||
draw_wave_sphere_ij(i, i+1, j, j+1, j+1, movie, phi, psi, xy_in, wave, wsphere, zplot, cplot, palette, fade, fade_value);
|
||||
}
|
||||
|
||||
/* North pole */
|
||||
for (i=0; i<NX-1; i++) for (j=NY-2; j<NY-1; j++)
|
||||
draw_wave_sphere_ij(i, i+1, j-1, j, j, movie, phi, psi, xy_in, wave, wsphere, zplot, cplot, palette, fade, fade_value);
|
||||
for (i=0; i<NX-1; i++)
|
||||
draw_wave_sphere_ij(i, i+1, NY-3, NY-2, NY-2, movie, phi, psi, xy_in, wave, wsphere, zplot, cplot, palette, fade, fade_value);
|
||||
|
||||
for (j=NY-2; j<NY-1; j++)
|
||||
draw_wave_sphere_ij(NX-1, 0, j-1, j, NY-DPOLE, movie, phi, psi, xy_in, wave, wsphere, zplot, cplot, palette, fade, fade_value);
|
||||
draw_wave_sphere_ij(NX-1, 0, NY-3, NY-2, NY-DPOLE, movie, phi, psi, xy_in, wave, wsphere, zplot, cplot, palette, fade, fade_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (imin < imax)
|
||||
{
|
||||
for (i=imax; i>imin; i--)
|
||||
for (j=NY-3; j>=0; j--)
|
||||
for (j=jmax; j>=0; j--)
|
||||
draw_wave_sphere_ij(i, i+1, j, j+1, j+1, movie, phi, psi, xy_in, wave, wsphere, zplot, cplot, palette, fade, fade_value);
|
||||
|
||||
for (i=imax+1; i<NX-1; i++)
|
||||
for (j=NY-3; j>=0; j--)
|
||||
for (j=jmax; j>=0; j--)
|
||||
draw_wave_sphere_ij(i, i+1, j, j+1, j+1, movie, phi, psi, xy_in, wave, wsphere, zplot, cplot, palette, fade, fade_value);
|
||||
|
||||
for (j=NY-3; j>=0; j--)
|
||||
for (j=jmax; j>=0; j--)
|
||||
draw_wave_sphere_ij(NX-1, 0, j, j+1, j+1, movie, phi, psi, xy_in, wave, wsphere, zplot, cplot, palette, fade, fade_value);
|
||||
|
||||
for (i=0; i<=imin; i++)
|
||||
for (j=NY-3; j>=0; j--)
|
||||
for (j=jmax; j>=0; j--)
|
||||
draw_wave_sphere_ij(i, i+1, j, j+1, j+1, movie, phi, psi, xy_in, wave, wsphere, zplot, cplot, palette, fade, fade_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i=imax; i<imin; i++)
|
||||
for (j=NY-3; j>=0; j--)
|
||||
for (j=jmax; j>=0; j--)
|
||||
draw_wave_sphere_ij(i, i+1, j, j+1, j+1, movie, phi, psi, xy_in, wave, wsphere, zplot, cplot, palette, fade, fade_value);
|
||||
|
||||
for (i=imax-1; i>=0; i--)
|
||||
for (j=NY-3; j>=0; j--)
|
||||
for (j=jmax; j>=0; j--)
|
||||
draw_wave_sphere_ij(i, i+1, j, j+1, j+1, movie, phi, psi, xy_in, wave, wsphere, zplot, cplot, palette, fade, fade_value);
|
||||
|
||||
for (j=NY-3; j>=0; j--)
|
||||
for (j=jmax; j>=0; j--)
|
||||
draw_wave_sphere_ij(NX-1, 0, j, j+1, j+1, movie, phi, psi, xy_in, wave, wsphere, zplot, cplot, palette, fade, fade_value);
|
||||
|
||||
for (i=NX-2; i>=imin; i--)
|
||||
for (j=NY-3; j>=0; j--)
|
||||
// for (i=NX-2; i>=imin; i--)
|
||||
for (i=NX-2; i>=imin-1; i--)
|
||||
for (j=jmax; j>=0; j--)
|
||||
draw_wave_sphere_ij(i, i+1, j, j+1, j+1, movie, phi, psi, xy_in, wave, wsphere, zplot, cplot, palette, fade, fade_value);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user