~ubuntu-branches/ubuntu/breezy/garlic/breezy

« back to all changes in this revision

Viewing changes to cylin_slab.c

  • Committer: Bazaar Package Importer
  • Author(s): zhaoway
  • Date: 2001-04-24 07:09:13 UTC
  • Revision ID: james.westby@ubuntu.com-20010424070913-uzpupnwdfhmliebz
Tags: upstream-1.1
ImportĀ upstreamĀ versionĀ 1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2000 Damir Zucic */
 
2
 
 
3
/*=============================================================================
 
4
 
 
5
                                cylin_slab.c
 
6
 
 
7
Purpose:
 
8
        Check which atoms are inside the cylindrical slab. Cylindrical slab
 
9
        is defined by two concentric cylinders.  A given atom is inside the
 
10
        slab if it is outside  the inner and inside the outer cylinder. Use
 
11
        this slab type to hide the inner part (the "cork") of a  porin-like
 
12
        protein. The y axis is a symmetry axis.
 
13
 
 
14
Input:
 
15
        (1) Pointer to MolComplexS structure.
 
16
 
 
17
Output:
 
18
        (1) Slab flag set for each atom. The value one is assigned to atoms
 
19
            inside the slab, zero to the rest.
 
20
        (2) Return value.
 
21
 
 
22
Return value:
 
23
        The number of atoms inside the slab.
 
24
 
 
25
========includes:============================================================*/
 
26
 
 
27
#include <stdio.h>
 
28
 
 
29
#include <X11/Xlib.h>
 
30
#include <X11/Xutil.h>
 
31
#include <X11/Xos.h>
 
32
#include <X11/Xatom.h>
 
33
 
 
34
#include "defines.h"
 
35
#include "typedefs.h"
 
36
 
 
37
/*======cylindrical slab:====================================================*/
 
38
 
 
39
size_t CylinSlab_ (MolComplexS *curr_mol_complexSP)
 
40
{
 
41
size_t          atoms_inside_slabN = 0;
 
42
size_t          atomsN, atomI;
 
43
AtomS           *curr_atomSP;
 
44
double          x0, z0, rho0_squared, rho1_squared;
 
45
double          x, z, rho_squared;
 
46
 
 
47
/* The number of atoms in a complex: */
 
48
atomsN = curr_mol_complexSP->atomsN;
 
49
 
 
50
/* Copy the slab center coordinates: */
 
51
x0 = curr_mol_complexSP->slab_center_vectorS.x;
 
52
z0 = curr_mol_complexSP->slab_center_vectorS.z;
 
53
rho0_squared = curr_mol_complexSP->slab_back_relative_position;
 
54
rho0_squared *= rho0_squared;
 
55
rho1_squared = curr_mol_complexSP->slab_front_relative_position;
 
56
rho1_squared *= rho1_squared;
 
57
 
 
58
/* Set the slab flag for each atom: */
 
59
for (atomI = 0; atomI < atomsN; atomI++)
 
60
        {
 
61
        /** Pointer to the current atom: **/
 
62
        curr_atomSP = curr_mol_complexSP->atomSP + atomI;
 
63
 
 
64
        /** Set the initial values of slab flags to one; this **/
 
65
        /** will be changed later for atoms outside the slab: **/
 
66
        curr_atomSP->inside_slabF = 1;
 
67
        curr_atomSP->inside_projected_slabF = 1;
 
68
 
 
69
        /** Distance between the current atom and the cylinder axis: **/
 
70
        x = curr_atomSP->raw_atomS.x[0] - x0;
 
71
        z = curr_atomSP->raw_atomS.z[0] - z0;
 
72
        rho_squared = x * x + z * z;
 
73
 
 
74
        /** If atom is inside  the inner cylinder, set **/
 
75
        /** slab flag to zero and check the next atom: **/
 
76
        if (rho_squared < rho0_squared)
 
77
                {
 
78
                curr_atomSP->inside_slabF = 0;
 
79
                curr_atomSP->inside_projected_slabF = 0;
 
80
                continue;
 
81
                }
 
82
 
 
83
        /** If atom is outside the outer slab cylinder: **/
 
84
        if (rho_squared > rho1_squared)
 
85
                {
 
86
                curr_atomSP->inside_slabF = 0;
 
87
                curr_atomSP->inside_projected_slabF = 0;
 
88
                continue;
 
89
                }
 
90
 
 
91
        /** If this points is reached, current atom is inside the slab: **/
 
92
        atoms_inside_slabN++;
 
93
        }
 
94
 
 
95
/* Return the number of atoms inside the slab: */
 
96
return atoms_inside_slabN;
 
97
}
 
98
 
 
99
/*===========================================================================*/
 
100