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f, -1.0f, 0.0f,
413 1.0f, -1.0f, 1.0f, 0.0f, -1.0f, 0.0f,
414 -1.0f, -1.0f, 1.0f, 0.0f, -1.0f, 0.0f,
415 -1.0f, -1.0f, -1.0f, 0.0f, -1.0f, 0.0f,
417 -1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f,
418 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f,
419 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f,
420 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f,
421 -1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f,
422 -1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f,
525 int i, j, k, l, m, n, o;
529 cvol = (paral[0][1]*paral[1][2]-paral[0][2]*paral[1][1])*paral[2][0];
530 cvol += (paral[0][2]*paral[1][0]-paral[0][0]*paral[1][2])*paral[2][1];
531 cvol += (paral[0][0]*paral[1][1]-paral[0][1]*paral[1][0])*paral[2][2];
535 object_3d * slab = g_malloc0 (
sizeof*slab);
537 slab -> num_vertices = 36*(
plot -> extra_cell[0]+1)*(
plot -> extra_cell[1]+1)*(
plot -> extra_cell[2]+1);
538 slab -> vertices =
allocfloat (slab -> vert_buffer_size*slab -> num_vertices);
547 pos = vec3 (slab -> vertices[j], slab -> vertices[j+1], slab -> vertices[j+2]);
548 pos = m4_mul_pos (rot, pos);
549 slab -> vertices[j] = pos.
x +
cpos.x;
550 slab -> vertices[j+1] = pos.
y +
cpos.y;
551 slab -> vertices[j+2] = pos.
z +
cpos.z;
554 for (i=0; i<
plot -> extra_cell[0]+1; i++)
556 for (j=0; j<
plot -> extra_cell[1]+1; j++)
558 for (k=0; k<
plot -> extra_cell[2]+1; k++)
569 slab -> vertices[m+6+o] = (o) ? 1.0 : 0.0;
573 if (! o) slab -> vertices[m+6+o] =
col.
red;
574 if (o == 1) slab -> vertices[m+6+o] =
col.
green;
575 if (o == 2) slab -> vertices[m+6+o] =
col.
blue;
579 pos = m4_mul_pos (rot, pos);
580 slab -> vertices[m+3] = pos.
x;
581 slab -> vertices[m+4] = pos.
y;
582 slab -> vertices[m+5] = pos.
z;
583 slab -> vertices[m+9] = slab_alpha;
605 double ang[3], cang[3], sang[3];
610 if (
wingl -> cell_win -> cparam[i+15] == 90.0)
618 ang[i] =
wingl -> cell_win -> cparam[i+15]*
pi/180.0;
619 sang[i] = sin(ang[i]);
620 cang[i] = cos(ang[i]);
623 paral[0][0] =
wingl -> cell_win -> cparam[9];
626 paral[1][0] =
wingl -> cell_win -> cparam[10] * cang[2];
627 paral[1][1] =
wingl -> cell_win -> cparam[10] * sang[2];
629 paral[2][0] =
wingl -> cell_win -> cparam[11] * cang[1];
630 tmp = (cang[0] - cang[1]*cang[2]) / sang[2];
631 paral[2][1] =
wingl -> cell_win -> cparam[11] * tmp;
632 paral[2][2] =
wingl -> cell_win -> cparam[11] * sqrt(sang[1]*sang[1] - tmp*tmp);
635 vec3(
wingl -> cell_win -> cparam[6],
wingl -> cell_win -> cparam[7],
wingl -> cell_win -> cparam[8]),
636 paral, null,
wingl -> cell_win -> slab_alpha);
641 vec3_t cat = vec3(
wingl -> cell_win -> cparam[6],
wingl -> cell_win -> cparam[7],
wingl -> cell_win -> cparam[8]);
645 for (i=-1; i<2; i+=2)
647 for (j=-1; j<2; j+=2)
649 for (k=-1; k<2; k+=2)
651 ps[l].
x = 0.5*(i*paral[0][0] + j*paral[1][0] + k*paral[2][0]);
652 ps[l].
y = 0.5*(i*paral[0][1] + j*paral[1][1] + k*paral[2][1]);
653 ps[l].
z = 0.5*(i*paral[0][2] + j*paral[1][2] + k*paral[2][2]);
654 ps[l] = m4_mul_pos (rot, ps[l]);
655 ps[l]= v3_add (ps[l], cat);
664 pmax[0] =
max(pmax[0],ps[l].
x);
665 pmax[1] =
max(pmax[1],ps[l].
y);
666 pmax[2] =
max(pmax[2],ps[l].
z);
680 ps[0] = v3_sub (ps[0], cat);
681 ps[7] = v3_sub (ps[7], cat);
683 for (i=0; i<
proj_gl -> nspec; i++)
wingl -> cell_win -> slab_lot[i] = 0;
684 wingl -> cell_win -> slab_atoms = 0;
688 slab_center.
x = cat.
x;
689 slab_center.
y = cat.
y;
690 slab_center.
z = cat.
z;
694 at = vec3(slab_center.
x+at_slab.
x, slab_center.
y+at_slab.
y, slab_center.
z+at_slab.
z);
695 if (at.x <= pmax[0] && at.y <= pmax[1] && at.z <= pmax[2])
698 atc = v3_sub (at, cat);
702 val = v3_dot (ps[k], pn[j]);
703 vbl = v3_dot (atc, pn[j]);
704 if (fabs(vbl) < fabs(
val))
713 if (m == 6 && (! at_slab.
pbc ||
wingl -> cell_win -> slab_pbc))
715 wingl -> cell_win -> slab_atoms ++;
717 wingl -> cell_win -> slab_lot[l] ++;
734 vec3_t pos_a = vec3(-
wingl -> cell_win -> cparam[12]/2.0, 0.0, 0.0);
735 vec3_t pos_b = vec3(
wingl -> cell_win -> cparam[12]/2.0, 0.0, 0.0);
736 pos_a = m4_mul_pos (rot, pos_a);
737 pos_b = m4_mul_pos (rot, pos_b);
738 vec3_t cat = vec3 (
wingl -> cell_win -> cparam[6],
wingl -> cell_win -> cparam[7],
wingl -> cell_win -> cparam[8]);
739 pos_a = v3_add (pos_a, cat);
740 pos_b = v3_add (pos_b, cat);
744 object_3d * slab = g_malloc0 (
sizeof*slab);
745 object_3d * slab_cap = g_malloc0 (
sizeof*slab_cap);
747 slab -> num_instances = (
plot -> extra_cell[0]+1)*(
plot -> extra_cell[1]+1)*(
plot -> extra_cell[2]+1);
751 slab_cap -> num_instances = 2 * slab -> num_instances;
760 for (i=0; i<
plot -> extra_cell[0]+1; i++)
762 for (j=0; j<
plot -> extra_cell[1]+1; j++)
764 for (k=0; k<
plot -> extra_cell[2]+1; k++)
769 pos_a = v3_add (pos_a,
shift);
770 pos_b = v3_add (pos_b,
shift);
772 pos_a = v3_sub (pos_a,
shift);
773 pos_b = v3_sub (pos_b,
shift);
780 for (i=0; i<
plot -> extra_cell[0]+1; i++)
782 for (j=0; j<
plot -> extra_cell[1]+1; j++)
784 for (k=0; k<
plot -> extra_cell[2]+1; k++)
789 pos_a = v3_add (pos_a,
shift);
790 pos_b = v3_add (pos_b,
shift);
793 pos_a = v3_sub (pos_a,
shift);
794 pos_b = v3_sub (pos_b,
shift);
801 wingl -> cell_win -> slab_vol =
pi*pow(
wingl -> cell_win -> cparam[13], 2)*
wingl -> cell_win -> cparam[12];
802 for (i=0; i<
proj_gl -> nspec; i++)
wingl -> cell_win -> slab_lot[i] = 0;
803 wingl -> cell_win -> slab_atoms = 0;
807 slab_center.
x = cat.
x;
808 slab_center.
y = cat.
y;
809 slab_center.
z = cat.
z;
814 if (
wingl -> cell_win -> slab_pbc || ! at_slab.
pbc)
816 atc = vec3(at_slab.
x, at_slab.
y, at_slab.
z);
817 patc = v3_proj (atc,
axis);
818 if (v3_length(patc) <=
wingl -> cell_win -> cparam[12]/2.0 && v3_length(v3_sub(patc,atc)) <=
wingl -> cell_win -> cparam[13])
820 wingl -> cell_win -> slab_atoms ++;
822 wingl -> cell_win -> slab_lot[j] ++;