00001 #include "CMTTensor.h"
00002
00003 CMTTensor::CMTTensor():
00004 Zxx(0),
00005 Zxy(0),
00006 Zyx(0),
00007 Zyy(0),
00008 dZxx(0),
00009 dZxy(0),
00010 dZyx(0),
00011 dZyy(0),
00012 frequency(0),
00013 rotangle(0),
00014 Rx(0),
00015 Ry(0),
00016 Nu(0)
00017 {
00018 }
00019
00020 CMTTensor::CMTTensor(const std::complex<double> &xx,const std::complex<double> &xy,const std::complex<double> &yx,
00021 const std::complex<double> &yy, const double freq, const double angle):
00022 Zxx(xx),
00023 Zxy(xy),
00024 Zyx(yx),
00025 Zyy(yy),
00026 dZxx(0),
00027 dZxy(0),
00028 dZyx(0),
00029 dZyy(0),
00030 frequency(freq),
00031 rotangle(angle),
00032 Rx(0),
00033 Ry(0),
00034 Nu(0)
00035 {
00036 }
00037
00038 CMTTensor& CMTTensor::operator= (const CMTTensor& source)
00039 {
00040 if (this == &source)
00041 return *this;
00042 Zxx = source.Zxx;
00043 Zxy = source.Zxy;
00044 Zyx = source.Zyx;
00045 Zyy = source.Zyy;
00046 dZxx = source.dZxx;
00047 dZxy = source.dZxy;
00048 dZyx = source.dZyx;
00049 dZyy = source.dZyy;
00050 frequency = source.frequency;
00051 rotangle = source.rotangle;
00052 Rx = source.Rx;
00053 Ry = source.Ry;
00054 Nu = source.Nu;
00055 return *this;
00056 }
00057 CMTTensor::~CMTTensor()
00058 {
00059 }
00060
00061 void CMTTensor::Rotate(double angle)
00062 {
00063 dcomp newxx, newxy, newyx, newyy;
00064 const double cangle = cos(angle);
00065 const double sangle = sin(angle);
00066 newxx = Zxx * cangle*cangle + (Zxy + Zyx)* sangle * cangle + Zyy * sangle*sangle;
00067 newxy = Zxy * cangle*cangle - (Zxx - Zyy) * sangle * cangle - Zyx * sangle*sangle;
00068 newyx = Zyx * cangle*cangle - (Zxx - Zyy) * sangle * cangle - Zxy * sangle*sangle;
00069 newyy = Zyy * cangle*cangle - (Zxy + Zyx) * sangle * cangle + Zxx * sangle*sangle;
00070 Zxx = newxx;
00071 Zxy = newxy;
00072 Zyx = newyx;
00073 Zyy = newyy;
00074 rotangle += angle;
00075 }