1
/* Copyright (C) 2000 Damir Zucic */
3
/*=============================================================================
8
Find geometric center position. Add it to MolComplexS structure.
11
(1) Pointer to MolComplexS structure (macromolecular complex).
14
(1) Geometric center vector stored to MolComplexS structure.
18
(1) Positive if there are some atoms.
19
(2) Zero if there are no atoms at all.
21
========includes:============================================================*/
25
#include <X11/Xutil.h>
27
#include <X11/Xatom.h>
32
/*======find geometric center position:======================================*/
34
int GeometricCenter_ (MolComplexS *mol_complexSP)
38
double x = 0.0, y = 0.0, z = 0.0, denom;
40
atomsN = mol_complexSP->atomsN;
41
if (atomsN <= 0) return 0;
43
curr_atomSP = mol_complexSP->atomSP;
44
for (i = 0; i < atomsN; i++)
46
x += curr_atomSP->raw_atomS.x[0];
47
y += curr_atomSP->raw_atomS.y;
48
z += curr_atomSP->raw_atomS.z[0];
51
denom = 1.0 / (double) atomsN; /* This is safe: atomsN is checked above! */
52
mol_complexSP->geometric_center_vectorS.x = x * denom;
53
mol_complexSP->geometric_center_vectorS.y = y * denom;
54
mol_complexSP->geometric_center_vectorS.z = z * denom;
59
/*===========================================================================*/