Bioplib
Protein Structure C Library
 All Data Structures Files Functions Variables Typedefs Macros Pages
CalcCellTrans.c
Go to the documentation of this file.
1 /************************************************************************/
2 /**
3 
4  \file CalcCellTrans.c
5 
6  \version V1.1
7  \date 07.07.14
8  \brief Calculate offsets for creating a crystal lattice
9 
10  \copyright (c) UCL / Dr. Andrew C. R. Martin 1993-1995
11  \author Dr. Andrew C. R. Martin
12  \par
13  Institute of Structural & Molecular Biology,
14  University College London,
15  Gower Street,
16  London.
17  WC1E 6BT.
18  \par
19  andrew@bioinf.org.uk
20  andrew.martin@ucl.ac.uk
21 
22 **************************************************************************
23 
24  This code is NOT IN THE PUBLIC DOMAIN, but it may be copied
25  according to the conditions laid out in the accompanying file
26  COPYING.DOC.
27 
28  The code may be modified as required, but any modifications must be
29  documented so that the person responsible can be identified.
30 
31  The code may not be sold commercially or included as part of a
32  commercial product except as described in the file COPYING.DOC.
33 
34 **************************************************************************
35 
36  Description:
37  ============
38 
39 
40 **************************************************************************
41 
42  Usage:
43  ======
44 
45 **************************************************************************
46 
47  Revision History:
48  =================
49 - V1.0R 12.10.05 Original
50 - V1.1 07.07.14 Use bl prefix for functions By: CTP
51 
52 *************************************************************************/
53 /* Defines required for includes
54 */
55 
56 /************************************************************************/
57 /* Doxygen
58  -------
59  #GROUP Handling PDB Data
60  #SUBGROUP Calculations
61  #FUNCTION blCalcCellTrans()
62  Calculates the offsets to apply in X, Y and Z directions for creating
63  a crystal lattice from the unit cell parameters.
64 */
65 /************************************************************************/
66 /* Includes
67 */
68 #include <stdio.h>
69 #include <math.h>
70 
71 #include "SysDefs.h"
72 #include "MathType.h"
73 #include "pdb.h"
74 #include "fsscanf.h"
75 
76 /************************************************************************/
77 /* Defines
78 */
79 
80 /************************************************************************/
81 /* Prototypes
82 */
83 
84 /************************************************************************/
85 /*>void blCalcCellTrans(VEC3F UnitCell, VEC3F CellAngles,
86  VEC3F *xtrans, VEC3F *ytrans, VEC3F *ztrans)
87  -----------------------------------------------------------------
88 *//**
89 
90  \param[in] UnitCell The unit cell dimensions
91  \param[in] CellAngles The unit cell angles
92  \param[out] *xtrans Translation to apply along X axis
93  \param[out] *ytrans Translation to apply along Y axis
94  \param[out] *ztrans Translation to apply along Z axis
95 
96  Calculates the offsets to apply in X, Y and Z directions for creating
97  a crystal lattice from the unit cell parameters.
98 
99 - 11.10.95 Original By: ACRM, Based losely on code from Rasmol
100 - 07.07.14 Use bl prefix for functions By: CTP
101 */
102 void blCalcCellTrans(VEC3F UnitCell, VEC3F CellAngles,
103  VEC3F *xtrans, VEC3F *ytrans, VEC3F *ztrans)
104 {
105  REAL lena, lenb, lenc,
106  cosa, cosb, cosg, sing,
107  tmpx, tmpy, tmpz, temp;
108 
109  lena = UnitCell.x; /* A */
110  lenb = UnitCell.y; /* B */
111  lenc = -1.0*UnitCell.z; /* C */
112 
113  cosa = (REAL)cos((double)(CellAngles.x)); /* Alpha */
114  cosb = (REAL)cos((double)(CellAngles.y)); /* Beta */
115  cosg = (REAL)cos((double)(CellAngles.z)); /* Gamma */
116  sing = (REAL)sin((double)(CellAngles.z)); /* Gamma */
117 
118  temp = cosa*cosa + cosb*cosb + cosg*cosg - 2.0*cosa*cosb*cosg;
119  tmpx = cosb;
120  tmpy = (cosa - cosb*cosg)/sing;
121  tmpz = (REAL)sqrt((double)(1.0-temp))/sing;
122 
123  xtrans->x = lena;
124  xtrans->y = (REAL)0.0;
125  xtrans->z = (REAL)0.0;
126 
127  ytrans->x = lenb*cosg;
128  ytrans->y = lenb*sing;
129  ytrans->z = (REAL)0.0;
130 
131  ztrans->x = lenc*tmpx;
132  ztrans->y = lenc*tmpy;
133  ztrans->z = lenc*tmpz;
134 }
135 
136 
Include file for PDB routines.
REAL x
Definition: MathType.h:70
void blCalcCellTrans(VEC3F UnitCell, VEC3F CellAngles, VEC3F *xtrans, VEC3F *ytrans, VEC3F *ztrans)
Definition: MathType.h:69
double REAL
Definition: MathType.h:67
Include file for fsscanf()
System-type variable type definitions.
Type definitions for maths.
REAL z
Definition: MathType.h:70
REAL y
Definition: MathType.h:70