00001 #ifndef GPA_H_ 00002 #define GPA_H_ 00003 00004 #include <vector> 00005 #include <complex> 00006 #include <Matrix.h> 00007 00008 00009 using namespace std; 00010 00011 00013 class GPA 00014 { 00015 00016 public: 00017 00018 static const double EPSILON = 1e-12; 00019 static const double SQRT2 = 1.414213562373095; 00020 00026 GPA(Matrix<double> *data=0, int individuals=0, int landmarks=0, int dimensions=0); 00027 00029 virtual ~GPA(); 00030 00036 void LoadData(Matrix<double> *data, int individuals, int landmarks, int dimensions); 00037 00044 void PerformGPA(int alignment = 0, bool scale = true, bool rotate = true, bool translate = true, bool reflection = true); 00045 00052 void SetProcrustesDistanceMethod(int method); 00053 00059 void SetAlignment(int alignment); 00060 00063 int GetNumberOfSpecimens(); 00064 00067 int GetNumberOfLandmarks(); 00068 00071 int GetNumberOfDimensions(); 00072 00075 void GetProcrustesMean(vector<vector<double> > *m); 00076 00079 void GetProcrustesMean(Matrix<double> *m); 00080 00083 void GetMeanAsComplex(vector<complex<double> > *m); 00084 00088 void GetProcrustesResiduals(int i, vector<vector<double> > *r); 00089 void GetProcrustesResiduals(int i, Matrix<double> *r); 00090 00095 void GetProcrustesCoordinates(int i, Matrix<double> *proc, bool scale = false); 00096 00100 void GetProcrustesCoordinates(Matrix<double> *P, bool scale = false); 00101 00104 void GetCentroidSizes(vector<double> *c); 00105 00109 void GetSimilarityMatrix(int i, Matrix<double> *S); 00110 00113 void GetSimilarityMatrices(vector<Matrix<double> > *S); 00114 00118 void GetTransformationMatrix(int i, Matrix<double> *T); 00119 00122 void GetTransformationMatrices(vector<Matrix<double> > *T); 00123 00133 double GetProcrustesDistance(int i, int j, int method = 0, bool formSpace = false); 00134 00142 void GetProcrustesDistances(Matrix<double> *dist, int method = 0, bool formSpace = false); 00143 00146 void GetFormSpaceCoordinates(Matrix<double> *F); 00147 00150 bool IsCalculated(); 00151 00152 void SetMaxIterations(int maxIterations) 00153 { 00154 m_maxIterations = maxIterations; 00155 } 00156 00157 void SetMinTolerance(double minTolerance) 00158 { 00159 m_minTolerance = minTolerance; 00160 } 00161 00162 private: 00163 00164 bool m_calculated; 00165 int m_method; 00166 int m_alignment; 00167 int m_landmarks; 00168 int m_dimensions; 00169 int m_individuals; 00170 int m_currentSpecimen; 00171 int m_scale; 00172 00173 int m_maxIterations; 00174 double m_minTolerance; 00175 00176 Matrix<double> m_procrustesMean; 00177 vector<Matrix<double> > m_originalCoordinates; 00178 vector<Matrix<double> > m_procrustesCoordinates; 00179 vector<Matrix<double> > m_procrustesResiduals; 00180 vector<double> m_centroidSizes; 00181 vector<vector<double> > m_translations; 00182 }; 00183 00184 #endif // GPA_H_ 00185