#include #include #include #include #include using namespace std; namespace bu = boost::units; namespace bg = boost::geometry; namespace bac = boost::astronomy::coordinate; // some quantity typedef bu::quantity t; typedef bu::quantity s; /* template class A : coordinate type X : Xquantity Y : Yquantity Z : Zquantity */ template class affine { private: double tform[3][3]; // affine 3x3 matrix public: //constructor initialises tform matrix affine(double tform[3][3]); // function that operates on cartesian representation vector and returns the answer bac::cartesian_representation transform_affine(bac::cartesian_representation); }; // tform initialisation template affine::affine(double tform[3][3]) { for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) this->tform[i][j] = tform[i][j]; } // logic template bac::cartesian_representation affine::transform_affine(bac::cartesian_representation v) { bac::cartesian_representation res; X x; Y y; Z z; double r, temp[3], tres[3] = {0, 0, 0}; temp[0] = v.get_x().value(); temp[1] = v.get_y().value(); temp[2] = v.get_z().value(); v.get_x().value(); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) tres[i] += this->tform[i][j] * temp[j]; } x = tres[0]; res.set_x(x); return res; } int main() { bac::cartesian_representation x; double mat[3][3] = { {3, 0, 0}, {0, 4, 0}, {0, 0, 1}}; affine A(mat); A.transform_affine(x); return 0; }