18 #ifndef MAGNES_COORDINATE_H    19 #define MAGNES_COORDINATE_H    23 #include "mathtools.h"    24 #include "coreexport.h"    47   void operator +=(
float f);
    51   void operator *=(
float f);
    53   void operator /=(
float f);
    63   float& 
x() { 
return m_xyz(0); }
    65   const float& 
x()
 const { 
return m_xyz(0); }
    67   float& 
y() { 
return m_xyz(1); }
    69   const float& 
y()
 const { 
return m_xyz(1); }
    71   float& 
z() { 
return m_xyz(2); }
    73   const float& 
z()
 const { 
return m_xyz(2); }
   125     float& 
W() { 
return _w; }
   127     const float& 
W()
 const { 
return _w; }
   131       return std::sqrt(_w*_w+_v.x()*_v.x()+_v.y()*_v.y()+_v.z()*_v.z());
   139       q1._v.
x()=-(this->_v.x());
   140       q1._v.
y()=-(this->_v.y());
   141       q1._v.
z()=-(this->_v.z());
   148       q1._w=  this->_w*q._w -  this->_v.x()*q._v.
x() - this->_v.y()*q._v.
y() -this->_v.z()*q._v.
z();
   149       q1._v.
x()=this->_w*q._v.
x()+this->_v.x()*q._w+this->_v.y()*q._v.
z()-this->_v.z()*q._v.
y();
   150       q1._v.
y()=this->_w*q._v.
y()+this->_v.y()*q._w+this->_v.z()*q._v.
x()-this->_v.x()*q._v.
z();
   151       q1._v.
z()=this->_w*q._v.
z()+this->_v.z()*q._w+this->_v.x()*q._v.
y()-this->_v.y()*q._v.
x();
   165       float norm=this->Norm();
   177         float seno=sin(angle);
   179         q.
V().
x() = (nrv.
x() * seno);
   180         q.
V().
y() = (nrv.
y() * seno);
   181         q.
V().
z() = (nrv.
z() * seno);
   191     float xx      = V().x()*V().x();
   192     float xy      = V().x() * V().y();
   193     float xz      = V().x()*V().z();
   194     float xw      = V().x()*W();
   195     float yy      = V().y()*V().y();
   196     float yz      = V().y() * V().z();
   197     float yw      = V().y()*W();
   198     float zz      = V().z()*V().z();
   199     float zw      = V().z() * W();
   200     glmatrix[0]  = 1 - 2 * ( yy + zz );
   201     glmatrix[1]  =     2 * ( xy - zw );
   202     glmatrix[2]  =     2 * ( xz + yw );
   203     glmatrix[4]  =     2 * ( xy + zw );
   204     glmatrix[5]  = 1 - 2 * ( xx + zz );
   205     glmatrix[6]  =     2 * ( yz - xw );
   206     glmatrix[8]  =     2 * ( xz - yw );
   207     glmatrix[9]  =     2 * ( yz + xw );
   208     glmatrix[10] = 1 - 2 * ( xx + yy );
   209     glmatrix[3]  =glmatrix[7] = glmatrix[11] = glmatrix[12] = glmatrix[13] = glmatrix[14] = 0;
   217     float xx      = V().x()*V().x();
   218     float xy      = V().x() * V().y();
   219     float xz      = V().x()*V().z();
   220     float xw      = V().x()*W();
   221     float yy      = V().y()*V().y();
   222     float yz      = V().y() * V().z();
   223     float yw      = V().y()*W();
   224     float zz      = V().z()*V().z();
   225     float zw      = V().z() * W();
   226     rotmatrix(0,0)  = 1 - 2 * ( yy + zz );
   227     rotmatrix(0,1)  =     2 * ( xy - zw );
   228     rotmatrix(0,2)  =     2 * ( xz + yw );
   229     rotmatrix(1,0)  =     2 * ( xy + zw );
   230     rotmatrix(1,1)  = 1 - 2 * ( xx + zz );
   231     rotmatrix(1,2)  =     2 * ( yz - xw );
   232     rotmatrix(2,0)  =     2 * ( xz - yw );
   233     rotmatrix(2,1)  =     2 * ( yz + xw );
   234     rotmatrix(2,2)  = 1 - 2 * ( xx + yy );
   241     double xx      = V().x()*V().x();
   242     double xy      = V().x() * V().y();
   243     double xz      = V().x()*V().z();
   244     double xw      = V().x()*W();
   245     double yy      = V().y()*V().y();
   246     double yz      = V().y() * V().z();
   247     double yw      = V().y()*W();
   248     double zz      = V().z()*V().z();
   249     double zw      = V().z() * W();
   250     rotmatrix(0,0)  = 1 - 2 * ( yy + zz );
   251     rotmatrix(0,1)  =     2 * ( xy - zw );
   252     rotmatrix(0,2)  =     2 * ( xz + yw );
   253     rotmatrix(1,0)  =     2 * ( xy + zw );
   254     rotmatrix(1,1)  = 1 - 2 * ( xx + zz );
   255     rotmatrix(1,2)  =     2 * ( yz - xw );
   256     rotmatrix(2,0)  =     2 * ( xz - yw );
   257     rotmatrix(2,1)  =     2 * ( yz + xw );
   258     rotmatrix(2,2)  = 1 - 2 * ( xx + yy );
   271   s << 
"(" << c.
x() << 
"," << c.
y() << 
","  << c.
z() << 
")";
   278   s << 
"[" << ( c.
W() ) << 
"," << ( c.
V() ) << 
"]" <<  std::endl;
   282 #endif // MAGNES_COORDINATE_H 
const float & z() const
Definition: coordinate.h:73
 
Quaternion Invert() const
Definition: coordinate.h:134
 
const float & x() const
Definition: coordinate.h:65
 
float & x()
Definition: coordinate.h:63
 
float & W()
Definition: coordinate.h:125
 
float & z()
Definition: coordinate.h:71
 
MAGNES_CORE_API std::ostream & operator<<(std::ostream &s, const Coordinate &c)
Definition: coordinate.h:269
 
the global magnes namespace 
Definition: ccchequation.h:38
 
const Coordinate & V() const
Definition: coordinate.h:123
 
void GLMatrix(D2Array< float > &glmatrix)
Definition: coordinate.h:188
 
Quaternion operator^(const Coordinate &c)
Definition: coordinate.h:157
 
Quaternion(double scalar, const Coordinate &c)
Definition: coordinate.h:119
 
float & y()
Definition: coordinate.h:67
 
void RotationMatrix(D2Array< float > &rotmatrix)
Definition: coordinate.h:214
 
monodimensional array 
Definition: mathtools.h:242
 
float Norm() const
Definition: coordinate.h:129
 
const float & y() const
Definition: coordinate.h:69
 
const float & W() const
Definition: coordinate.h:127
 
representaion of a 3D point 
Definition: coordinate.h:33
 
Quaternion()
Definition: coordinate.h:117
 
Coordinate & V()
Definition: coordinate.h:121
 
quaternion representation 
Definition: coordinate.h:113
 
Coordinate operator*(float f, Coordinate a)
Definition: coordinate.h:102
 
Quaternion operator^(const Quaternion &q)
Definition: coordinate.h:145