File: rot.c

package info (click to toggle)
openmx 3.7.6-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 325,856 kB
  • ctags: 3,575
  • sloc: ansic: 152,655; f90: 2,080; python: 876; makefile: 675; sh: 25; perl: 18
file content (80 lines) | stat: -rw-r--r-- 1,709 bytes parent folder | download | duplicates (4)
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
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define PI            3.1415926535897932384626

int main(int argc, char *argv[]) 
{

  static int ct_AN;
  static double Gxyz2[10][10];
  static double xyz2[10][10];
  static double Q1,Q2,Q3;
  static double Sx,Sy,Sz,Cx,Cy,Cz;
  static double Rot[5][5],r;

  Gxyz2[1][1] = 0.0;
  Gxyz2[1][2] = 0.0;
  Gxyz2[1][3] = 0.0;

  Gxyz2[2][1] = 0.76;
  Gxyz2[2][2] = 0.59;
  Gxyz2[2][3] = 0.00;

  Gxyz2[3][1] = -0.76;
  Gxyz2[3][2] =  0.59;
  Gxyz2[3][3] =  0.00;

  Q1 = 30.0/180.0*PI;
  Q2 = 40.0/180.0*PI;
  Q3 = 50.0/180.0*PI;


  Sx = sin(Q1);
  Cx = cos(Q1);

  Sy = sin(Q2);
  Cy = cos(Q2);
  
  Sz = sin(Q3);
  Cz = cos(Q3);

  Rot[1][1] = Cy*Cz;
  Rot[1][2] = Sx*Sy*Cz - Cx*Sz;
  Rot[1][3] = Cx*Sy*Cz + Sx*Sz;

  Rot[2][1] = Cy*Sz;
  Rot[2][2] = Sx*Sy*Sz + Cx*Cz;
  Rot[2][3] = Cx*Sy*Sz - Sx*Cz;

  Rot[3][1] = -Sy;
  Rot[3][2] = Sx*Cy;
  Rot[3][3] = Cx*Cy;

  for (ct_AN=1; ct_AN<=3; ct_AN++){

    xyz2[ct_AN][1] =  Rot[1][1]*Gxyz2[ct_AN][1] 
                    + Rot[1][2]*Gxyz2[ct_AN][2]  
                    + Rot[1][3]*Gxyz2[ct_AN][3];
  
    xyz2[ct_AN][2] =  Rot[2][1]*Gxyz2[ct_AN][1] 
                    + Rot[2][2]*Gxyz2[ct_AN][2]  
                    + Rot[2][3]*Gxyz2[ct_AN][3];
  

    xyz2[ct_AN][3] =  Rot[3][1]*Gxyz2[ct_AN][1] 
                    + Rot[3][2]*Gxyz2[ct_AN][2]  
                    + Rot[3][3]*Gxyz2[ct_AN][3];

    r = sqrt(  xyz2[ct_AN][1]*xyz2[ct_AN][1] 
             + xyz2[ct_AN][2]*xyz2[ct_AN][2]
             + xyz2[ct_AN][3]*xyz2[ct_AN][3]
             );

    //  printf("r=%15.12f\n",r); 
    printf(" %15.12f %15.12f %15.12f\n",xyz2[ct_AN][1],xyz2[ct_AN][2],xyz2[ct_AN][3]);
  }

}