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 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
|
#define PI 3.1415926535897932384626
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
void fnjoint();
void chcp();
double sgn();
void ATV(double atvx[15],double atvy[15], double atvz[15],
double tvx[5],double tvy[5],double tvz[5]);
main()
{
static int atomnum,n,i,j,k,l,m,i1,i2,j1,j2;
static double za0,za1,za2,za3;
static double ka1,ka2,ka3,al,be,ga,c1,c2,c3,s2,s3;
static double **xyz,rxyz[10],tvxyz[5][4];
static double tvx[5],tvy[5],tvz[5];
static double atvx[15],atvy[15],atvz[15];
static double la1,la2,la3,ang1,ang2,ang3;
static double r,dx,dy,dz;
static char Name[100];
/*----------- input data ------------------------------------*/
scanf("%lf %lf %lf",&tvx[1],&tvy[1],&tvz[1]);
scanf("%lf %lf %lf",&tvx[2],&tvy[2],&tvz[2]);
scanf("%lf %lf %lf",&tvx[3],&tvy[3],&tvz[3]);
scanf("%i",&atomnum);
xyz = (double**)malloc(sizeof(double*)*(atomnum+1));
for (i=0; i<=atomnum; i++){
xyz[i] = (double*)malloc(sizeof(double)*4);
}
ATV(atvx,atvy,atvz,tvx,tvy,tvz);
for (i=1; i<=atomnum; i++){
scanf("%lf %s %lf %lf %lf",&za0,&Name,&za1,&za2,&za3);
xyz[i][0] = za0;
xyz[i][1] = za1*tvx[1] + za2*tvx[2] + za3*tvx[3];
xyz[i][2] = za1*tvy[1] + za2*tvy[2] + za3*tvy[3];
xyz[i][3] = za1*tvz[1] + za2*tvz[2] + za3*tvz[3];
printf("%4d %3s %16.12f %16.12f %16.12f\n",
i,Name,xyz[i][1],xyz[i][2],xyz[i][3]);
}
/***************************
distance between two atoms
***************************/
/*
for (i=1; i<=atomnum; i++){
for (j=1; j<=atomnum; j++){
if (i!=j){
dx = xyz[i][1] - xyz[j][1];
dy = xyz[i][2] - xyz[j][2];
dz = xyz[i][3] - xyz[j][3];
r = sqrt(dx*dx + dy*dy + dz*dz);
printf("Atoms %4d and %4d R=%15.12f\n",i,j,r);
}
}
}
*/
/* freeing of array */
for (i=0; i<=atomnum; i++){
free(xyz[i]);
}
free(xyz);
}
void ATV(double atvx[15],double atvy[15], double atvz[15],
double tvx[5],double tvy[5],double tvz[5])
{
atvx[0] = 0;
atvy[0] = 0;
atvz[0] = 0;
atvx[1] = tvx[1];
atvy[1] = tvy[1];
atvz[1] = tvz[1];
atvx[2] = tvx[2];
atvy[2] = tvy[2];
atvz[2] = tvz[2];
atvx[3] = tvx[3];
atvy[3] = tvy[3];
atvz[3] = tvz[3];
atvx[4] = tvx[1] + tvx[3];
atvy[4] = tvy[1] + tvy[3];
atvz[4] = tvz[1] + tvz[3];
atvx[5] = tvx[1] - tvx[3];
atvy[5] = tvy[1] - tvy[3];
atvz[5] = tvz[1] - tvz[3];
atvx[6] = tvx[1] + tvx[2];
atvy[6] = tvy[1] + tvy[2];
atvz[6] = tvz[1] + tvz[2];
atvx[7] = tvx[1] - tvx[2];
atvy[7] = tvy[1] - tvy[2];
atvz[7] = tvz[1] - tvz[2];
atvx[8] = tvx[2] + tvx[3];
atvy[8] = tvy[2] + tvy[3];
atvz[8] = tvz[2] + tvz[3];
atvx[9] = tvx[2] - tvx[3];
atvy[9] = tvy[2] - tvy[3];
atvz[9] = tvz[2] - tvz[3];
atvx[10] = tvx[1] + tvx[2] + tvx[3];
atvy[10] = tvy[1] + tvy[2] + tvy[3];
atvz[10] = tvz[1] + tvz[2] + tvz[3];
atvx[11] = -tvx[1] + tvx[2] + tvx[3];
atvy[11] = -tvy[1] + tvy[2] + tvy[3];
atvz[11] = -tvz[1] + tvz[2] + tvz[3];
atvx[12] = tvx[1] - tvx[2] + tvx[3];
atvy[12] = tvy[1] - tvy[2] + tvy[3];
atvz[12] = tvz[1] - tvz[2] + tvz[3];
atvx[13] = tvx[1] + tvx[2] - tvx[3];
atvy[13] = tvy[1] + tvy[2] - tvy[3];
atvz[13] = tvz[1] + tvz[2] - tvz[3];
}
void fnjoint(char name1[100],char name2[100],char name3[100])
{
static char name4[100];
char *f1 = name1,
*f2 = name2,
*f3 = name3,
*f4 = name4;
while(*f1)
{
*f4 = *f1;
*f1++;
*f4++;
}
while(*f2)
{
*f4 = *f2;
*f2++;
*f4++;
}
while(*f3)
{
*f4 = *f3;
*f3++;
*f4++;
}
*f4 = *f3;
chcp(name3,name4);
}
void chcp(char name1[100],char name2[100])
{
char *f1 = name1,
*f2 = name2;
while(*f2)
{
*f1 = *f2;
*f1++;
*f2++;
}
*f1 = *f2;
}
double sgn(double nu)
{
double result;
if (nu<0)
result = -1;
else
result = 1;
return result;
}
|