Example #1
0
/* delta >=0, d -> d/(1+delta), else d -> d * (1-delta). */
bool foo_advance (int iw, double delta)
{
    double tmp[3];
    if (delta >= 0) delta = 1/(1+delta);
    else delta = (1-delta);
    if (n[iw].anchor >= 0)
    {
        V3SUB (AX_3D[iw].x, B->BALL[n[iw].anchor].x, tmp);
        V3ADDMUL (B->BALL[n[iw].anchor].x, delta, tmp, AX_3D[iw].x);
    }
    else
    {
        V3SUB (AX_3D[iw].x, n[iw].hook, tmp);
        V3ADDMUL (n[iw].hook, delta, tmp, AX_3D[iw].x);
    }
    return (TRUE);
} /* end advance() */
Example #2
0
bool pointer_advance (int iw, int to_x, int to_y)
{
    double delta, tmp[3];
    if (n[iw].ly == to_y) return (FALSE);
    delta = exp(2*(n[iw].ly-to_y)/n[iw].mgs_radius);
    if (n[iw].anchor >= 0)
    {
        V3SUB (AX_3D[iw].x, B->BALL[n[iw].anchor].x, tmp);
        V3ADDMUL (B->BALL[n[iw].anchor].x, delta, tmp, AX_3D[iw].x);
    }
    else
    {
        V3SUB (AX_3D[iw].x, n[iw].hook, tmp);
        V3ADDMUL (n[iw].hook, delta, tmp, AX_3D[iw].x);
    }
    n[iw].lx = to_x;
    n[iw].ly = to_y;
    return (TRUE);
} /* end pointer_advance() */
Example #3
0
/* hook to the center of the appearing cylinder part */
void hook_to_cylinder (int k, double *hook)
{
    register int i;
    register double tmp;
    for (i=0; i<np; i++)
        if (k < N->idx[i+1]) break;
    tmp = (B->BALL[i].radius + C->CYLINDER[k].axis[3] -
           B->BALL[N->list[k]].radius) / 2.;
    V3ADDMUL (C->CYLINDER[k].x0, tmp, C->CYLINDER[k].axis, hook);
    return;
} /* end hook_to_cylinder() */
Example #4
0
/* 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() */