![]() |
VR-Forces 4.0.4 Class Documentation
|
00001 /******************************************************************************* 00002 ** Copyright (c) 2002 MaK Technologies, Inc. 00003 ** All rights reserved. 00004 *******************************************************************************/ 00005 /******************************************************************************* 00006 ** $RCSfile: vrfcomplex.h,v $ $Revision: 1.3 $ $State: Exp $ 00007 *******************************************************************************/ 00008 00011 00012 #ifndef _DtComplex_H_ 00013 #define _DtComplex_H_ 00014 00015 #include <vlutil/vlUtil.h> 00016 00020 00021 #include "vrfutil/vrfutilDefines.h" 00022 class DT_DLL_vrfutil DtComplex 00023 { 00024 public: 00027 DtComplex (void) {}; 00029 DtComplex (double realPart, double imagPart) 00030 : myRealPart (realPart), myImagPart (imagPart) 00031 {}; 00033 DtComplex (const DtComplex& orig) 00034 : myRealPart (orig.myRealPart), myImagPart (orig.myImagPart) 00035 {}; 00036 00038 const DtComplex & operator= (const DtComplex& orig); 00039 00040 double realPart (void) const {return myRealPart;}; 00041 double imagPart (void) const {return myImagPart;}; 00042 double magnitude (void) const 00043 {return ::sqrt (myRealPart * myRealPart + myImagPart * myImagPart);}; 00044 double angle (void) const {return atan2 (myImagPart, myRealPart);}; 00045 00048 void conjugate (DtComplex * result) const 00049 {result->myRealPart = myRealPart; 00050 result->myImagPart = - myImagPart; 00051 }; 00052 00053 void negate (DtComplex * result) const 00054 {result->myRealPart = -myRealPart; 00055 result->myImagPart = -myImagPart; 00056 }; 00057 00059 void sqrt (DtComplex * result) const; 00060 void pow (DtComplex * result, int exponent) const; 00061 00064 void add (DtComplex * result, const DtComplex& other) const 00065 {result->myRealPart = myRealPart + other.myRealPart; 00066 result->myImagPart = myImagPart + other.myImagPart; 00067 }; 00068 00069 void subtract (DtComplex * result, const DtComplex& other) const 00070 {result->myRealPart = myRealPart - other.myRealPart; 00071 result->myImagPart = myImagPart - other.myImagPart; 00072 }; 00073 00074 void multiply (DtComplex * result, const DtComplex& other) const 00075 {result->myRealPart = 00076 myRealPart * other.myRealPart - myImagPart * other.myImagPart; 00077 result->myImagPart = 00078 myRealPart * other.myImagPart + myImagPart * other.myRealPart; 00079 }; 00080 00081 void divide (DtComplex * result, double denom) const 00082 {result->myRealPart = myRealPart / denom; 00083 result->myImagPart = myImagPart / denom; 00084 }; 00085 00086 void divide (DtComplex * result, const DtComplex& other) const; 00087 00089 void add (DtComplex * result, 00090 const DtComplex& first, 00091 const DtComplex& second) const; 00092 00093 void add (DtComplex * result, 00094 const DtComplex& first, 00095 const DtComplex& second, 00096 const DtComplex& third) const; 00097 00098 void add (DtComplex * result, 00099 const DtComplex& first, 00100 const DtComplex& second, 00101 const DtComplex& third, 00102 const DtComplex& fourth) const; 00103 00104 void multiply (DtComplex * result, 00105 const DtComplex& first, 00106 const DtComplex& second) const; 00107 00108 void multiply (DtComplex * result, 00109 const DtComplex& first, 00110 const DtComplex& second, 00111 const DtComplex& third) const; 00112 00113 void multiply (DtComplex * result, 00114 const DtComplex& first, 00115 const DtComplex& second, 00116 const DtComplex& third, 00117 const DtComplex& fourth) const; 00118 00119 private: 00120 double myRealPart; 00121 double myImagPart; 00122 }; 00123 00124 #endif