示例#1
0
文件: viewport.c 项目: dmt4/atomeye
/* Rotate viewport as V' = R*V but letting the anchor stay at the same place */
void rotate (int iw, double R[3][3])
{
    double V0[3][3], s[3], tmp[3];
    if (n[iw].anchor >= 0)
    {
        V3SUB (B->BALL[n[iw].anchor].x, AX_3D[iw].x, tmp);
        M3mV3 (AX_3D[iw].V, tmp, s);
    }
    else
    {
        V3SUB (n[iw].hook, AX_3D[iw].x, tmp);
        M3mV3 (AX_3D[iw].V, tmp, s);
    }
    M3EQV (AX_3D[iw].V, V0);
    V3mM3 (R[0], V0, AX_3D[iw].V[0]);
    V3mM3 (R[1], V0, AX_3D[iw].V[1]);
    V3NORMALIZE (AX_3D[iw].V[1], tmp[0]);
    /* ensure the orthogonality numerically */
    V3CROSS (AX_3D[iw].V[0], AX_3D[iw].V[1], AX_3D[iw].V[2]);
    V3NORMALIZE (AX_3D[iw].V[2], tmp[0]);
    V3CROSS (AX_3D[iw].V[1], AX_3D[iw].V[2], AX_3D[iw].V[0]);
    if (n[iw].anchor >= 0)
    {
        V3mM3 (s, AX_3D[iw].V, tmp);
        V3SUB (B->BALL[n[iw].anchor].x, tmp, AX_3D[iw].x);
    }
    else
    {
        V3mM3 (s, AX_3D[iw].V, tmp);
        V3SUB (n[iw].hook, tmp, AX_3D[iw].x);
    }
    return;
} /* end rotate() */
示例#2
0
文件: info.c 项目: sinamoeini/AtomEye
/* Save atoms selected in a monoclinic filter to a file */
void save_atoms_in_monoclinic_filter (int iw)
{
    M3 HH;
    double d0, zmargin, xytolerance, origin[3];
    char danswer[MAX_FILENAME_SIZE], *answer, fname[MAX_FILENAME_SIZE];
    char *taglist = NULL;
    int selected[2];
    
    V3SUB( B->BALL[n[iw].atom_stack[0]].x,
           B->BALL[n[iw].atom_stack[1]].x, HH[0] );
    V3SUB( B->BALL[n[iw].atom_stack[2]].x,
           B->BALL[n[iw].atom_stack[1]].x, HH[1] );
    V3CROSS (HH[0], HH[1], HH[2]);
    if (V3ISSMALL(HH[2]))
    {
        printf("The selected parallelogram is ill-conditioned\n"
               "for constructing a monoclinic filter.\n");
        return;
    }
    V3NORMALIZE (HH[2], d0);
    printf ("\"up\" is [%g %g %g]\n"
            "check it agrees with your mirror normal...\n", V3E(HH[2]));
        
    d0 = 2.5;
    zmargin = 0.01; 
    xytolerance = 0.01;
    xterm_get_focus(iw); clear_stdin_buffer();
    REALLOC (save_atoms_in_monoclinic_filter, taglist, np, char);
    while (1)
    {
        sprintf (danswer, "%g %g %g", d0, zmargin, xytolerance);
        answer = readline_gets
            ("Interplanar spacing [A]  z-margin [A]  xy-tolerance", danswer);
        sscanf(answer, "%lf %lf %lf", &d0, &zmargin, &xytolerance);
        V3ADDMUL (B->BALL[n[iw].atom_stack[1]].x, d0/2,HH[2], origin);
        if (tag_atoms_in_monoclinic_filter
            (origin,HH, d0+2*zmargin,xytolerance, selected,taglist)>0) break;
        strcpy (danswer, answer);
    }
    printf("down=%d and up=%d atoms selected in filter.\n",
           selected[0], selected[1]);
    while (1)
    {
        sprintf (danswer, "%s.idx", fbasename);
        answer = readline_gets("Save the selected atoms to", danswer);
        sscanf(answer, "%s", fname);
        if ( tested_to_be_writable(fname) )
        {
            save_dipole_indices (selected, taglist, fname);
            printf ("selected atom indices [0-%d] saved to %s.\n", np-1,fname);
            Free (taglist);
            break;
        }
        else
        {
            printf ("\n** %s: **\n", fname);
            printf ("** This file is unwritable! **\n");
        }
        strcpy(danswer, answer);
    }
    xterm_release_focus(iw);

    return;
} /* end save_atoms_in_monoclinic_filter() */