File: half_cylin_slab.c

package info (click to toggle)
garlic 1.6-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 4,516 kB
  • sloc: ansic: 52,465; makefile: 2,254
file content (110 lines) | stat: -rw-r--r-- 3,125 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/* Copyright (C) 2000, 2001 Damir Zucic */

/*=============================================================================

				half_cylin_slab.c

Purpose:
	Check which atoms are inside the semi-cylindrical slab.  Semi-cyl.
	slab is defined by two concentric cylinders and a plane which cuts
	both cylinders in equal halves. A given atom is inside the slab if
	it is outside the inner cylinder, inside the outer cylinder and in
	front of a plane.  The symmetry axis is y.  Use this  slab type to
	hide  the rear half  as well  as  the  inner part of  a porin-like
	protein.

Input:
	(1) Pointer to MolComplexS structure.

Output:
	(1) Slab flag  set for  each atom.  The value  one  is assigned to
	    atoms inside the slab, zero to the rest.
	(2) Return value.

Return value:
	The number of atoms inside the slab.

========includes:============================================================*/

#include <stdio.h>

#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>
#include <X11/Xatom.h>

#include "defines.h"
#include "typedefs.h"

/*======semi-cylindrical slab:===============================================*/

size_t HalfCylinSlab_ (MolComplexS *curr_mol_complexSP)
{
size_t		atoms_inside_slabN = 0;
size_t		atomsN, atomI;
AtomS		*curr_atomSP;
double		x0, z0, rho0_squared, rho1_squared;
double		x, z, rho_squared;

/* The number of atoms in a complex: */
atomsN = curr_mol_complexSP->atomsN;

/* Copy the slab center coordinates: */
x0   = curr_mol_complexSP->slab_center_vectorS.x;
z0   = curr_mol_complexSP->slab_center_vectorS.z;
rho0_squared = curr_mol_complexSP->slab_back_relative_position;
rho0_squared *= rho0_squared;
rho1_squared = curr_mol_complexSP->slab_front_relative_position;
rho1_squared *= rho1_squared;

/* Set the slab flag for each atom: */
for (atomI = 0; atomI < atomsN; atomI++)
	{
	/** Pointer to the current atom: **/
	curr_atomSP = curr_mol_complexSP->atomSP + atomI;

	/** Set the initial values of slab flags to one; this **/
	/** will be changed later for atoms outside the slab: **/
	curr_atomSP->inside_slabF = 1;
	curr_atomSP->inside_projected_slabF = 1;

	/** Distance between the current atom and the cylinder axis: **/
	x = curr_atomSP->raw_atomS.x[0] - x0;
	z = curr_atomSP->raw_atomS.z[0] - z0;
	rho_squared = x * x + z * z;

	/** If atom is behind  the rear plane,  set slab **/
	/** flags to zero and go to check the next atom: **/
	if (z > 0.0)
		{
		curr_atomSP->inside_slabF = 0;
		curr_atomSP->inside_projected_slabF = 0;
		continue;
		}

	/** If atom is inside the inner cylinder: **/
	if (rho_squared < rho0_squared)
		{
		curr_atomSP->inside_slabF = 0;
		curr_atomSP->inside_projected_slabF = 0;
		continue;
		}

	/** If atom is outside the outer slab cylinder: **/
	if (rho_squared > rho1_squared)
		{
		curr_atomSP->inside_slabF = 0;
		curr_atomSP->inside_projected_slabF = 0;
		continue;
		}

	/** If this points is reached, current atom is inside the slab: **/
	atoms_inside_slabN++;
	}

/* Return the number of atoms inside the slab: */
return atoms_inside_slabN;
}

/*===========================================================================*/