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

« back to all changes in this revision

Viewing changes to half_sphere_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
                                half_sphere_slab.c
 
6
 
 
7
Purpose:
 
8
        Check which atoms are inside the semi-spherical slab.  Semi-spher.
 
9
        slab is  defined by  two concentric  spheres and  a single  plane,
 
10
        passing through  the slab center.  A given atom is inside the slab
 
11
        if it is outside the inner sphere,  inside the outer sphere and in
 
12
        front of  the plane.  Use this slab type  to hide  the entire rear
 
13
        half as well as the inner part of a globular protein. The position
 
14
        of the  plane  is  fixed,  while  the position  of both  spherical
 
15
        surfaces may be adjusted.
 
16
 
 
17
Input:
 
18
        (1) Pointer to MolComplexS structure.
 
19
 
 
20
Output:
 
21
        (1) Slab flag  set for  each atom.  The value  one  is assigned to
 
22
            atoms inside the slab, zero to the rest.
 
23
        (2) Return value.
 
24
 
 
25
Return value:
 
26
        The number of atoms inside the slab.
 
27
 
 
28
========includes:============================================================*/
 
29
 
 
30
#include <stdio.h>
 
31
 
 
32
#include <X11/Xlib.h>
 
33
#include <X11/Xutil.h>
 
34
#include <X11/Xos.h>
 
35
#include <X11/Xatom.h>
 
36
 
 
37
#include "defines.h"
 
38
#include "typedefs.h"
 
39
 
 
40
/*======semi-spherical slab:=================================================*/
 
41
 
 
42
size_t HalfSphereSlab_ (MolComplexS *curr_mol_complexSP)
 
43
{
 
44
size_t          atoms_inside_slabN = 0;
 
45
size_t          atomsN, atomI;
 
46
AtomS           *curr_atomSP;
 
47
double          x0, y0, z0, r0_squared, r1_squared;
 
48
double          x, y, z, rho_squared, r_squared;
 
49
 
 
50
/* The number of atoms in a complex: */
 
51
atomsN = curr_mol_complexSP->atomsN;
 
52
 
 
53
/* Copy the slab center coordinates: */
 
54
x0 = curr_mol_complexSP->slab_center_vectorS.x;
 
55
y0 = curr_mol_complexSP->slab_center_vectorS.y;
 
56
z0 = curr_mol_complexSP->slab_center_vectorS.z;
 
57
r0_squared = curr_mol_complexSP->slab_back_relative_position;
 
58
r0_squared *= r0_squared;
 
59
r1_squared = curr_mol_complexSP->slab_front_relative_position;
 
60
r1_squared *= r1_squared;
 
61
 
 
62
/* Set the slab flag for each atom: */
 
63
for (atomI = 0; atomI < atomsN; atomI++)
 
64
        {
 
65
        /** Pointer to the current atom: **/
 
66
        curr_atomSP = curr_mol_complexSP->atomSP + atomI;
 
67
 
 
68
        /** Set the initial values of slab flags to one; this **/
 
69
        /** will be changed later for atoms outside the slab: **/
 
70
        curr_atomSP->inside_slabF = 1;
 
71
        curr_atomSP->inside_projected_slabF = 1;
 
72
 
 
73
        /** Distance between the current atom and the cylinder axis: **/
 
74
        x = curr_atomSP->raw_atomS.x[0] - x0;
 
75
        z = curr_atomSP->raw_atomS.z[0] - z0;
 
76
        rho_squared = x * x + z * z;
 
77
 
 
78
        /** Distance between the current atom and the slab center: **/
 
79
        y = curr_atomSP->raw_atomS.y - y0;
 
80
        r_squared = rho_squared + y * y;
 
81
 
 
82
        /** First prepare the inside_projected_slabF: */
 
83
        if (rho_squared < r0_squared) curr_atomSP->inside_projected_slabF = 0;
 
84
        if (rho_squared > r1_squared) curr_atomSP->inside_projected_slabF = 0;
 
85
 
 
86
        /** If atom is behind  the back plane,  set slab **/
 
87
        /** flags to zero and go to check the next atom: **/
 
88
        if (z > 0.0)
 
89
                {
 
90
                curr_atomSP->inside_slabF = 0;
 
91
                curr_atomSP->inside_projected_slabF = 0;
 
92
                continue;
 
93
                }
 
94
 
 
95
        /** If atom is inside  the inner slab sphere: **/
 
96
        if (r_squared < r0_squared)
 
97
                {
 
98
                curr_atomSP->inside_slabF = 0;
 
99
                continue;
 
100
                }
 
101
 
 
102
        /** If atom is outside the outer slab sphere: **/
 
103
        if (r_squared > r1_squared)
 
104
                {
 
105
                curr_atomSP->inside_slabF = 0;
 
106
                continue;
 
107
                }
 
108
 
 
109
        /** If this points is reached, current atom is inside the slab: **/
 
110
        atoms_inside_slabN++;
 
111
        }
 
112
 
 
113
/* Return the number of atoms inside the slab: */
 
114
return atoms_inside_slabN;
 
115
}
 
116
 
 
117
/*===========================================================================*/
 
118