Changeset 321
- Timestamp:
- 03/26/08 12:00:36 (8 months ago)
- Location:
- trunk/matml/src/ternary
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/matml/src/ternary/geomview.c
r318 r321 71 71 int npoints Number of points. 72 72 73 double *points Point coordinates and colors in a 7xN array: x,y,z,r,g,b,a.73 ternary_point *points Point coordinates and colors. 74 74 75 75 int ntriangles Number of triangles. … … 79 79 80 80 int GeomviewDisplayTriangleCOFF 81 (FILE *geompipe, int npoints, double*points, int ntriangles, int *vertices)81 (FILE *geompipe, int npoints, ternary_point *points, int ntriangles, int *vertices) 82 82 { 83 83 int i; … … 89 89 90 90 for (i=0; i<npoints; i++) 91 fprintf (geompipe, "%g %g %g %g %g %g %g\n", points[ 7*i], points[7*i+1],92 points[ 7*i+2], points[7*i+3], points[7*i+4], points[7*i+5],93 points[ 7*i+6]);91 fprintf (geompipe, "%g %g %g %g %g %g %g\n", points[i].x, points[i].y, 92 points[i].z, points[i].red, points[i].green, points[i].blue, 93 points[i].alpha); 94 94 95 95 for (i=0; i<ntriangles; i++) -
trunk/matml/src/ternary/ternary.c
r318 r321 31 31 char gv_version[100]; 32 32 FILE *pfd = NULL; 33 double Gmin, Gmax, *points; 33 double Gmin, Gmax; 34 ternary_point *points; 34 35 35 36 if (argc>1) … … 37 38 38 39 /* Allocate arrays for point coordinates and colors and triangle vertices */ 39 if (!(points = calloc ((loop_max+1)*(loop_max+2)/2 * 7, sizeof (double))))40 if (!(points = calloc ((loop_max+1)*(loop_max+2)/2, sizeof (ternary_point)))) 40 41 { printf ("Cannot allocate point coordinate array\n"); exit (1); } 41 42 … … 55 56 for (j=0; j<=loop_max-i; j++) 56 57 { 57 index = 7 *(ROWSTART (i) + j);58 index = (ROWSTART (i) + j); 58 59 59 points [index]= (double)i/loop_max;60 points [index+1]= (double)j/loop_max;61 points [index+2] = free_energy (points[index], points[index+1], 0.);62 Gmin = (points [index+2]<Gmin) ? points [index+2]: Gmin;63 Gmax = (points [index+2]>Gmax) ? points [index+2]: Gmax;60 points[index].C2 = (double)i/loop_max; 61 points[index].C3 = (double)j/loop_max; 62 points[index].G = free_energy (points[index].C2, points[index].C3, 0.); 63 Gmin = (points[index].G<Gmin) ? points[index].G : Gmin; 64 Gmax = (points[index].G>Gmax) ? points[index].G : Gmax; 64 65 } 66 67 printf ("Calculated free energies\n"); 65 68 66 69 #define Grel(G) (((G)-Gmin)/(Gmax-Gmin)) … … 73 76 for (j=0; j<=loop_max-i; j++) 74 77 { 75 index = 7 *(ROWSTART (i) + j);78 index = (ROWSTART (i) + j); 76 79 77 points [index] += 0.5 * points [index+1]; 78 points [index+1] *= sqrt(3)/2.; 80 /* Switch y and z because geomview uses z as depth */ 81 points[index].x = points[index].C2 + 0.5 * points[index].C3; 82 points[index].y = Grel(points[index].G); 83 points[index].z = (1. - points[index].C3) * sqrt(3)/2.; 79 84 80 points [index+3] = RED (Grel (points [index+2]));81 points [index+4] = GREEN (Grel (points [index+2]));82 points [index+5] = BLUE (Grel (points [index+2]));83 points [index+6]= 1.;85 points[index].red = RED (Grel (points[index].G)); 86 points[index].green = GREEN (Grel (points[index].G)); 87 points[index].blue = BLUE (Grel (points[index].G)); 88 points[index].alpha = 1.; 84 89 } 90 91 printf ("Rescaled points\n"); 85 92 86 93 /* Calculate triangle vertex indices */ … … 108 115 verts [3*index+2] = ROWSTART(i+1); 109 116 117 printf ("Calculated triangle vertex indices\n"); 118 110 119 /* Send points and triangle vertex data to Geomview */ 111 120 if (i=GeomviewDisplayTriangleCOFF (pfd, (loop_max+1)*(loop_max+2)/2, points, 112 121 loop_max*loop_max, verts)) 113 122 { printf ("main: Error %d in Geomview Display\n", i); exit (i); } 123 124 printf ("Sent points to geomview\n"); 114 125 115 126 { -
trunk/matml/src/ternary/ternary.h
r320 r321 11 11 #include <stdio.h> 12 12 13 typedef struct { 14 double C2; /*+ Ternary concentration variable 2 (0 -> 1) +*/ 15 double C3; /*+ Ternary concentration variable 3 (0 -> 1-C2) +*/ 16 double G; /*+ Free energy +*/ 17 double x; /*+ Visualization x-coordinate (0 -> 1) +*/ 18 double y; /*+ Visualization y-coordinate (transformed free energy) +*/ 19 double z; /*+ Visualization z-coordinate (0 -> sqrt(3)/2) +*/ 20 double red; /*+ Visualization color red value (0 -> 1) +*/ 21 double green; /*+ Visualization color green value (0 -> 1) +*/ 22 double blue; /*+ Visualization color blue value (0 -> 1) +*/ 23 double alpha; /*+ Visualization color alpha value (0 -> 1) +*/ 24 } ternary_point; /*+ Ternary "point" structure. +*/ 25 13 26 double free_energy (double C2, double C3, double T); 14 27 15 28 int GeomviewBegin (FILE **geompipe, char *version); 16 29 int GeomviewDisplayTriangleCOFF 17 (FILE *geompipe, int npoints, double *points, int ntriangles, int *vertices); 30 (FILE *geompipe, int npoints, ternary_point *points, 31 int ntriangles, int *vertices); 18 32 int GeomviewEnd (FILE **geompipe); 19 33