/* -*- C++ -*- * Copyright ©2004 Hugo Mills * * This software is distributed under the terms of the GNU GPL v3 * For more information on the GPL, see the file COPYING or * visit http://www.gnu.org/ * * This software is distributed without warranty */ #ifndef XFORBIT_H #define XFORBIT_H #include "magellan/vectors.h" #include "magellan/plugin.h" class XfOrbit; #include "magellan/plugininfo_orbit.h" #include "magellan/configlexer.h" #include "magellan/parsertools.h" #include "magellan/values.h" class XfOrbit : public Plugin { public: XfOrbit() { } virtual bool f(dvec3&, const dvec3&) const; virtual bool g(dvec3&, const dvec3&) const; virtual void reset(void) { } protected: virtual ~XfOrbit() { } void setmatrices(double, double); template inline void mmul3(std::valarray& res, const std::valarray& m1, const std::valarray& m2) const { for(int i=0; i<3; i++) for(int j=0; j<3; j++) { res[i*3+j] = 0; for(int k=0; k<3; k++) res[i*3+j] += m1[i*3+k] * m2[k*3+j]; } } template inline void vmul3(std::valarray& res, const std::valarray& m, const std::valarray& v) const { for(int i=0; i<3; i++) { res[i] = 0; for(int j=0; j<3; j++) res[i] += m[i*3+j] * v[j]; } } typedef enum { RA_X, RA_Y, RA_Z } RotAxis; inline void rot_mat(dmat3& res, RotAxis ra, double angle) const { res[1] = res[2] = res[3] = res[5] = res[6] = res[7] = 0.0; res[0] = res[4] = res[8] = 1.0; switch(ra) { case RA_X: res[4] = res[8] = cos(angle); res[7] = sin(angle); res[5] = -res[7]; break; case RA_Y: res[0] = res[8] = cos(angle); res[6] = sin(angle); res[2] = -res[6]; break; case RA_Z: res[0] = res[4] = cos(angle); res[3] = sin(angle); res[1] = -res[3]; break; } } dmat3 matrix; dmat3 imatrix; }; #endif