27 |
|
} |
28 |
|
|
29 |
|
void pov_write(FILE *out_file, struct coords *the_coords, int n_atoms, |
30 |
< |
int d_hydrogens, int d_bonds, int d_atoms){ |
30 |
> |
int d_hydrogens, int d_bonds, int d_atoms, int d_vectors){ |
31 |
|
|
32 |
|
int i,j; /*loop counters */ |
33 |
|
int skip_atom, skip_bond, test1, test2; /*booleans */ |
47 |
|
"//************************************************************\n" |
48 |
|
"\n" |
49 |
|
"\n"); |
50 |
< |
|
50 |
> |
|
51 |
|
for(i = 0; i < n_atoms; i++){ |
52 |
|
|
53 |
< |
skip_atom = 0; |
53 |
> |
skip_atom = 0; |
54 |
|
|
55 |
|
if(!d_hydrogens){ |
56 |
|
skip_atom = !strcmp("H", the_coords[i].name); |
57 |
|
} |
58 |
|
|
59 |
< |
if(!skip_atom){ |
60 |
< |
|
59 |
> |
if(!skip_atom){ |
60 |
> |
|
61 |
|
fprintf(out_file, |
62 |
|
"make_%s_atom( %lf, %lf, %lf )\n", |
63 |
|
the_coords[i].name, |
66 |
|
the_coords[i].y); |
67 |
|
} |
68 |
|
} |
69 |
< |
|
69 |
> |
|
70 |
|
fprintf(out_file, |
71 |
|
"\n" |
72 |
|
"\n"); |
73 |
+ |
} |
74 |
+ |
|
75 |
+ |
|
76 |
+ |
if (d_vectors) { |
77 |
+ |
|
78 |
+ |
fprintf(out_file, |
79 |
+ |
"//************************************************************\n" |
80 |
+ |
"// The list of vectors\n" |
81 |
+ |
"//************************************************************\n" |
82 |
+ |
"\n" |
83 |
+ |
"\n"); |
84 |
+ |
|
85 |
+ |
for(i = 0; i < n_atoms; i++){ |
86 |
+ |
|
87 |
+ |
if (the_coords[i].hasVector) { |
88 |
+ |
fprintf(out_file, |
89 |
+ |
"make_%s_vector(%lf, %lf, %lf, %lf, %lf, %lf)\n", |
90 |
+ |
the_coords[i].name, |
91 |
+ |
the_coords[i].x, |
92 |
+ |
the_coords[i].z, |
93 |
+ |
the_coords[i].y, |
94 |
+ |
the_coords[i].ux, |
95 |
+ |
the_coords[i].uz, |
96 |
+ |
the_coords[i].uy); |
97 |
+ |
} |
98 |
+ |
} |
99 |
|
|
100 |
+ |
fprintf(out_file, |
101 |
+ |
"\n" |
102 |
+ |
"\n"); |
103 |
|
} |
104 |
< |
|
104 |
> |
|
105 |
|
if(d_bonds){ |
106 |
|
|
107 |
|
fprintf(out_file, |
284 |
|
" #local z2 = end_2z;\n" |
285 |
|
"\n" |
286 |
|
" #if(ROTATE)\n" |
287 |
< |
" #local x1_new = A11 * x1 + A12 * y1 + A13 * z1;\n" |
288 |
< |
" #local y1_new = A21 * x1 + A22 * y1 + A23 * z1;\n" |
289 |
< |
" #local z1_new = A31 * x1 + A32 * y1 + A33 * z1;\n" |
287 |
> |
" #local x1_new = rotatePointX + A11 * (x1-rotatePointX) + A12 * (y1-rotatePointY) + A13 * (z1-rotatePointZ);\n" |
288 |
> |
" #local y1_new = rotatePointY + A21 * (x1-rotatePointX) + A22 * (y1-rotatePointY) + A23 * (z1-rotatePointZ);\n" |
289 |
> |
" #local z1_new = rotatePointZ + A31 * (x1-rotatePointX) + A32 * (y1-rotatePointY) + A33 * (z1-rotatePointZ);\n" |
290 |
|
"\n" |
291 |
< |
" #local x2_new = A11 * x2 + A12 * y2 + A13 * z2;\n" |
292 |
< |
" #local y2_new = A21 * x2 + A22 * y2 + A23 * z2;\n" |
293 |
< |
" #local z2_new = A31 * x2 + A32 * y2 + A33 * z2;\n" |
291 |
> |
" #local x2_new = rotatePointX + A11 * (x2-rotatePointX) + A12 * (y2-rotatePointY) + A13 * (z2-rotatePointZ);\n" |
292 |
> |
" #local y2_new = rotatePointY + A21 * (x2-rotatePointX) + A22 * (y2-rotatePointY) + A23 * (z2-rotatePointZ);\n" |
293 |
> |
" #local z2_new = rotatePointZ + A31 * (x2-rotatePointX) + A32 * (y2-rotatePointY) + A33 * (z2-rotatePointZ);\n" |
294 |
|
"\n" |
295 |
|
" #else\n" |
296 |
|
" #local x1_new = x1;" |
328 |
|
"\n" |
329 |
|
" #if(ROTATE)\n" |
330 |
|
"\n" |
331 |
< |
" #local x1_new = A11 * x1 + A12 * y1 + A13 * z1;\n" |
332 |
< |
" #local y1_new = A21 * x1 + A22 * y1 + A23 * z1;\n" |
333 |
< |
" #local z1_new = A31 * x1 + A32 * y1 + A33 * z1;\n" |
331 |
> |
" #local x1_new = rotatePointX + A11 * (x1-rotatePointX) + A12 * (y1-rotatePointY) + A13 * (z1-rotatePointZ);\n" |
332 |
> |
" #local y1_new = rotatePointY + A21 * (x1-rotatePointX) + A22 * (y1-rotatePointY) + A23 * (z1-rotatePointZ);\n" |
333 |
> |
" #local z1_new = rotatePointZ + A31 * (x1-rotatePointX) + A32 * (y1-rotatePointY) + A33 * (z1-rotatePointZ);\n" |
334 |
|
"\n" |
335 |
|
" #else\n" |
336 |
|
"\n" |
343 |
|
" sphere{\n" |
344 |
|
" < x1_new, y1_new, z1_new >,\n" |
345 |
|
" ATOM_SPHERE_FACTOR * %lf\n" |
346 |
+ |
" texture{\n" |
347 |
+ |
" pigment{ rgb < %lf, %lf, %lf > }\n" |
348 |
+ |
" finish{\n" |
349 |
+ |
" ambient .2\n" |
350 |
+ |
" diffuse .6\n" |
351 |
+ |
" specular 1\n" |
352 |
+ |
" roughness .001\n" |
353 |
+ |
" metallic\n" |
354 |
+ |
" }\n" |
355 |
+ |
" }\n" |
356 |
+ |
" }\n" |
357 |
+ |
"#end\n" |
358 |
+ |
"#macro make_%s_vector " |
359 |
+ |
"(center_x, center_y, center_z, ux, uy, uz)\n" |
360 |
+ |
"\n" |
361 |
+ |
" #local vx = VECTOR_SCALE * ux;\n" |
362 |
+ |
" #local vy = VECTOR_SCALE * uy;\n" |
363 |
+ |
" #local vz = VECTOR_SCALE * uz;\n" |
364 |
+ |
" #local x1 = center_x - 0.5 * vx;\n" |
365 |
+ |
" #local y1 = center_y - 0.5 * vy;\n" |
366 |
+ |
" #local z1 = center_z - 0.5 * vz;\n" |
367 |
+ |
" #local x2 = center_x + 0.5 * vx;\n" |
368 |
+ |
" #local y2 = center_y + 0.5 * vy;\n" |
369 |
+ |
" #local z2 = center_z + 0.5 * vz;\n" |
370 |
+ |
" #local v2 = vx*vx + vy*vy + vz*vz;\n" |
371 |
+ |
" #local vl = sqrt(v2);\n" |
372 |
+ |
" #local x3 = x1 + vx * (1.0 - CONE_FRACTION);\n" |
373 |
+ |
" #local y3 = y1 + vy * (1.0 - CONE_FRACTION);\n" |
374 |
+ |
" #local z3 = z1 + vz * (1.0 - CONE_FRACTION);\n" |
375 |
+ |
"\n" |
376 |
+ |
" #if(ROTATE)\n" |
377 |
+ |
" #local x1_new = rotatePointX + A11 * (x1-rotatePointX) + A12 * (y1-rotatePointY) + A13 * (z1-rotatePointZ);\n" |
378 |
+ |
" #local y1_new = rotatePointY + A21 * (x1-rotatePointX) + A22 * (y1-rotatePointY) + A23 * (z1-rotatePointZ);\n" |
379 |
+ |
" #local z1_new = rotatePointZ + A31 * (x1-rotatePointX) + A32 * (y1-rotatePointY) + A33 * (z1-rotatePointZ);\n" |
380 |
+ |
"\n" |
381 |
+ |
" #local x2_new = rotatePointX + A11 * (x2-rotatePointX) + A12 * (y2-rotatePointY) + A13 * (z2-rotatePointZ);\n" |
382 |
+ |
" #local y2_new = rotatePointY + A21 * (x2-rotatePointX) + A22 * (y2-rotatePointY) + A23 * (z2-rotatePointZ);\n" |
383 |
+ |
" #local z2_new = rotatePointZ + A31 * (x2-rotatePointX) + A32 * (y2-rotatePointY) + A33 * (z2-rotatePointZ);\n" |
384 |
+ |
"\n" |
385 |
+ |
" #local x3_new = rotatePointX + A11 * (x3-rotatePointX) + A12 * (y3-rotatePointY) + A13 * (z3-rotatePointZ);\n" |
386 |
+ |
" #local y3_new = rotatePointY + A21 * (x3-rotatePointX) + A22 * (y3-rotatePointY) + A23 * (z3-rotatePointZ);\n" |
387 |
+ |
" #local z3_new = rotatePointZ + A31 * (x3-rotatePointX) + A32 * (y3-rotatePointY) + A33 * (z3-rotatePointZ);\n" |
388 |
+ |
"\n" |
389 |
+ |
" #else\n" |
390 |
+ |
" #local x1_new = x1;" |
391 |
+ |
" #local y1_new = y1;" |
392 |
+ |
" #local z1_new = z1;" |
393 |
+ |
"\n" |
394 |
+ |
" #local x2_new = x2;" |
395 |
+ |
" #local y2_new = y2;" |
396 |
+ |
" #local z2_new = z2;" |
397 |
+ |
"\n" |
398 |
+ |
" #local x3_new = x3;" |
399 |
+ |
" #local y3_new = y3;" |
400 |
+ |
" #local z3_new = z3;" |
401 |
+ |
"\n" |
402 |
+ |
" #end\n" |
403 |
+ |
"\n" |
404 |
+ |
" cylinder{\n" |
405 |
+ |
" < x1_new, y1_new, z1_new >,\n" |
406 |
+ |
" < x3_new, y3_new, z3_new >,\n" |
407 |
+ |
" STICK_RADIUS\n" |
408 |
|
" texture{\n" |
409 |
|
" pigment{ rgb < %lf, %lf, %lf > }\n" |
410 |
|
" finish{\n" |
416 |
|
" }\n" |
417 |
|
" }\n" |
418 |
|
" }\n" |
419 |
+ |
" cone{\n" |
420 |
+ |
" < x2_new, y2_new, z2_new >, 0.0\n" |
421 |
+ |
" < x3_new, y3_new, z3_new >, CONE_RADIUS\n" |
422 |
+ |
" texture{\n" |
423 |
+ |
" pigment{ rgb < %lf, %lf, %lf > }\n" |
424 |
+ |
" finish{\n" |
425 |
+ |
" ambient .2\n" |
426 |
+ |
" diffuse .6\n" |
427 |
+ |
" specular 1\n" |
428 |
+ |
" roughness .001\n" |
429 |
+ |
" metallic\n" |
430 |
+ |
" }\n" |
431 |
+ |
" }\n" |
432 |
+ |
" }\n" |
433 |
|
"#end\n" |
434 |
|
"\n" |
435 |
|
"\n", |
438 |
|
red, green, blue, |
439 |
|
name, |
440 |
|
radius, |
441 |
+ |
red, green, blue, |
442 |
+ |
name, |
443 |
+ |
red, green, blue, |
444 |
|
red, green, blue); |
445 |
|
|
446 |
|
current_type = current_type->next; |