Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

spin.cc

Go to the documentation of this file.
00001 #include "spin.hh"
00002 #include "register.hh"
00003 
00004 namespace anoid {
00005     namespace plugin {
00006 
00007         using namespace simple;
00008         using namespace config;
00009 
00010         void Spin::init(Configuration &c) {
00011             spin[1] = spin[2] = spin[3] =
00012                 spin[4] = spin[6] = spin[7] =
00013                 spin[8] = spin[9] = spin[11] =
00014                 spin[12] = spin[13] = spin[14] = 0.0;
00015             spin[0] = spin[5] = spin[10] = spin[15] = 1.0; 
00017             /* spin = c.getMatrix("spin"); */
00018             Rotation::init(c);
00019             registerName("Spin");
00020         }
00021 
00022         double *Spin::getSpin() {
00023             return spin;
00024         }
00025 
00026         void Spin::setRotation(double *r) {
00027             copyMatrix(rotation, r);
00028         }
00029 
00030         void Spin::setSpin(double *s) {
00031             copyMatrix(spin, s);
00032         }
00033 
00034         void Spin::update() {
00035             copyMatrix(oldRotation, rotation);
00036             matAdd(rotation, spin);
00037 
00038             Vector X(rotation[0], rotation[4], rotation[8]);
00039             Vector Y(rotation[1], rotation[5], rotation[9]);
00040 
00041             X.setNorm(1.0);
00042             Vector Z(X % Y);
00043 
00044             Z.setNorm(1.0);
00045             Y = Z % X;
00046 
00047             Y.setNorm(1.0); // Not really needed
00048 
00049             rotation[0] = X.getX();
00050             rotation[4] = X.getY();
00051             rotation[8] = X.getZ();
00052 
00053             rotation[1] = Y.getX();
00054             rotation[5] = Y.getY();
00055             rotation[9] = Y.getZ();
00056 
00057             rotation[2] = Z.getX();
00058             rotation[6] = Z.getY();
00059             rotation[10] = Z.getZ();
00060 
00061             Rotation::update();
00062         }
00063 
00064         Register(Spin)
00065 
00066     };
00067 };

Anoid NG © Michael Westergaard, Martin Stig Stissing, Ronni Michael Laursen, and Kristian Bisgaard Lassen