1
/* Copyright (C) 2000 Damir Zucic */
3
/*=============================================================================
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.
18
(1) Pointer to MolComplexS structure.
21
(1) Slab flag set for each atom. The value one is assigned to
22
atoms inside the slab, zero to the rest.
26
The number of atoms inside the slab.
28
========includes:============================================================*/
33
#include <X11/Xutil.h>
35
#include <X11/Xatom.h>
40
/*======semi-spherical slab:=================================================*/
42
size_t HalfSphereSlab_ (MolComplexS *curr_mol_complexSP)
44
size_t atoms_inside_slabN = 0;
47
double x0, y0, z0, r0_squared, r1_squared;
48
double x, y, z, rho_squared, r_squared;
50
/* The number of atoms in a complex: */
51
atomsN = curr_mol_complexSP->atomsN;
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;
62
/* Set the slab flag for each atom: */
63
for (atomI = 0; atomI < atomsN; atomI++)
65
/** Pointer to the current atom: **/
66
curr_atomSP = curr_mol_complexSP->atomSP + atomI;
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;
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;
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;
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;
86
/** If atom is behind the back plane, set slab **/
87
/** flags to zero and go to check the next atom: **/
90
curr_atomSP->inside_slabF = 0;
91
curr_atomSP->inside_projected_slabF = 0;
95
/** If atom is inside the inner slab sphere: **/
96
if (r_squared < r0_squared)
98
curr_atomSP->inside_slabF = 0;
102
/** If atom is outside the outer slab sphere: **/
103
if (r_squared > r1_squared)
105
curr_atomSP->inside_slabF = 0;
109
/** If this points is reached, current atom is inside the slab: **/
110
atoms_inside_slabN++;
113
/* Return the number of atoms inside the slab: */
114
return atoms_inside_slabN;
117
/*===========================================================================*/