-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathatom.cpp
63 lines (54 loc) · 1.05 KB
/
atom.cpp
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
#include<iostream>
#include"atom.h"
atom::atom(double x0,double y0) {
xi=x0;
yi=y0;
}
atom::atom(void){
}
ostream& operator << (ostream& os, atom a0) {
// Output the atom position to the stream in the format n/d
os <<'('<<a0.xi<<','<<a0.yi<<')';
return os;
}
rxy::rxy(void){
}
rxy::rxy(double x0,double y0) {
x=x0;
y=y0;
}
rxy::rxy(vector<atom>::iterator a0) {
x=a0->xi;
y=a0->yi;
}
rxy::rxy(double a0) {
x=cos(a0);
y=sin(a0);
}
double operator * (rxy a0, rxy a1) {
return( a0.x * a1.x + a0.y*a1.y);
}
rxy operator / (rxy a0, int n0) {
return( rxy(a0.x /n0 , a0.y / n0));
}
rxy operator /= (rxy &a0, int n0) {
a0.x /= n0;
a0.y /= n0;
return( a0);
}
rxy operator * (double q0, rxy a0) {
return( rxy(a0.x *q0 , a0.y * q0));
}
rxy operator += (rxy &a0, rxy a1) {
a0.x += a1.x;
a0.y += a1.y;
return(a0);
}
double rxy::abs2()
{
return( this->x* this->x + this->y * this->y);
}
double det(rxy a0, rxy a1) {
//determinant
return(a0.x*a1.y-a1.x*a0.y);
}