00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef CHORD_H
00021 #define CHORD_H
00022
00023 #include "specfun.h"
00024 #include "mtrand.h"
00025 #include "conftrans.h"
00026 #include <vector>
00027 #include <assert.h>
00028
00033 class chord {
00037 double rs;
00038
00042 double rf;
00043
00047 double fs;
00048
00052 double ff;
00053
00054 public:
00062 chord(double rs, double rf, double fs, double ff);
00063
00071 chord(const chord &c0, const chord &c1, const chord &c2, const chord &c3);
00072
00081 chord(const std::vector<int> &idx, const std::vector <chord> &chords);
00082
00088 chord(const chord& another, double p);
00089
00090
00095 inline bool isVertical() const {
00096 return tol_eq(fs,ff);
00097 };
00098
00103 inline bool isHorizontal() const {
00104 return tol_eq(rs,rf);
00105 };
00106
00111 inline double getRS() const {
00112 return rs;
00113 };
00114
00119 inline double getRF() const {
00120 return rf;
00121 };
00122
00127 inline double getFS() const {
00128 return fs;
00129 };
00130
00135 inline double getFF() const {
00136 return ff;
00137 };
00138
00143 inline dcmplx getS() const {
00144 const dcmplx I(0.0,1.0);
00145 return rs*exp(I*fs);
00146 };
00147
00152 inline dcmplx getF() const {
00153 const dcmplx I(0.0,1.0);
00154 return rf*exp(I*ff);
00155 };
00156
00162 inline dcmplx getCenter(const conftrans& ct) const {
00163 const dcmplx I(0.0,1.0);
00164 double rm=(rf+rs)/2;
00165 double fm=(ff+fs)/2;
00166
00167 return ct.T((rs*exp(I*fs)+rf*exp(I*ff)+rs*exp(I*ff)+rf*exp(I*fs)+
00168 rm*exp(I*fs)+rm*exp(I*ff)+rs*exp(I*fm)+rf*exp(I*fm))/8.0);
00169 };
00170
00177 inline dcmplx getRandom(const conftrans& ct, MTRand& mt) const {
00178 const dcmplx I(0.0,1.0);
00179 double rm=rs+(rf-rs)*mt.rand();
00180 double fm=fs+(ff-fs)*mt.rand();
00181
00182 return ct.T(rm*exp(I*fm));
00183 };
00184
00189 double getRadius(const conftrans &CT) const;
00190
00199 inline double getIntR(double p) const {
00200 return rs+0.5*(rf-rs)*(1+p);
00201 };
00202
00211 inline double getIntF(double p) const {
00212 return fs+0.5*(ff-fs)*(1+p);
00213 };
00214
00226 dcmplx getIntZ(double p) const;
00227
00233 dcmplx getIntZJac(double p) const;
00234
00240 inline double getVHLength() const {
00241 assert(isVertical()||isHorizontal());
00242 return rf-rs+ff-fs;
00243 };
00244
00250 inline double getLength() const {
00251 assert(isVertical()||isHorizontal());
00252 if (isVertical()) return rf-rs;
00253 else return rs*(ff-fs);
00254 };
00255
00262 chord& shiftS(double amt);
00263
00270 chord& shiftF(double amt);
00271
00278 inline const chord shiftedS(double amt) const {
00279 assert(isVertical()||isHorizontal());
00280 return chord(*this).shiftS(amt);
00281 };
00282
00289 inline const chord shiftedF(double amt) const {
00290 assert(isVertical()||isHorizontal());
00291 return chord(*this).shiftF(amt);
00292 };
00293
00299 bool equal(const chord& another) const;
00300
00304 void printChord() const;
00305
00306
00311 virtual int getStorage();
00312
00316 ~chord();
00317
00318 };
00319
00320 #endif