27 using namespace qglviewer;
36 : constraint_(NULL), referenceFrame_(NULL)
46 : t_(position), q_(orientation), constraint_(NULL), referenceFrame_(NULL)
125 static GLdouble m[4][4];
127 return (
const GLdouble*)(m);
214 for (
int i=0; i<4; ++i)
215 for (
int j=0; j<4; ++j)
216 m[i][j] = mat[i*4+j];
223 for (
int i=0; i<16; ++i)
230 if (fabs(m[3][3]) < 1E-8)
232 qWarning(
"Frame::setFromMatrix: Null homogeneous coefficient");
237 for (
int i=0; i<3; ++i)
239 t_[i] = m[3][i] / m[3][3];
240 for (
int j=0; j<3; ++j)
242 rot[i][j] = m[j][i] / m[3][3];
244 q_.setFromRotationMatrix(rot);
275 for (
int i=0; i<4; ++i)
276 for (
int j=0; j<4; ++j)
277 mat[i][j] = m[i*4+j];
659 qWarning(
"Frame::setReferenceFrame would create a loop in Frame hierarchy");
662 bool identical = (referenceFrame_ == refFrame);
663 referenceFrame_ = refFrame;
673 const Frame* f = frame;
708 const Frame* fr =
this;
757 const Frame* fr =
this;
759 while ((fr != NULL) && (fr != in))
779 for (
int i=0; i<3 ; ++i)
787 for (
int i=0; i<3 ; ++i)
795 for (
int i=0; i<3 ; ++i)
803 for (
int i=0; i<3 ; ++i)
811 for (
int i=0; i<3 ; ++i)
819 for (
int i=0; i<3 ; ++i)
849 const Frame* fr =
this;
898 const Frame* fr =
this;
900 while ((fr != NULL) && (fr != in))
920 for (
int i=0; i<3 ; ++i)
928 for (
int i=0; i<3 ; ++i)
936 for (
int i=0; i<3 ; ++i)
944 for (
int i=0; i<3 ; ++i)
952 for (
int i=0; i<3 ; ++i)
960 for (
int i=0; i<3 ; ++i)
988 QDomElement e = document.createElement(name);
1011 QDomElement child=element.firstChild().toElement();
1012 while (!child.isNull())
1014 if (child.tagName() ==
"position")
1016 if (child.tagName() ==
"orientation")
1019 child = child.nextSibling().toElement();
1047 Vec directions[2][3];
1048 for (
int d=0; d<3; ++d)
1050 Vec dir((d==0)? 1.0 : 0.0, (d==1)? 1.0 : 0.0, (d==2)? 1.0 : 0.0);
1054 directions[0][d] = dir;
1058 float maxProj = 0.0f;
1060 unsigned short index[2];
1061 index[0] = index[1] = 0;
1062 for (
int i=0; i<3; ++i)
1063 for (
int j=0; j<3; ++j)
1064 if ( (proj=fabs(directions[0][i]*directions[1][j])) >= maxProj )
1074 float coef = directions[0][index[0]] * directions[1][index[1]];
1075 if (fabs(coef) >= threshold)
1077 const Vec axis = cross(directions[0][index[0]], directions[1][index[1]]);
1078 float angle = asin(axis.
norm());
1085 unsigned short d = (index[1]+1) % 3;
1086 Vec dir((d==0)? 1.0 : 0.0, (d==1)? 1.0 : 0.0, (d==2)? 1.0 : 0.0);
1090 for (
int i=0; i<3; ++i)
1092 float proj = fabs(directions[0][i]*dir);
1100 if (max >= threshold)
1102 const Vec axis = cross(directions[0][index[0]], dir);
1103 float angle = asin(axis.
norm());
1104 if (directions[0][index[0]] * dir >= 0.0)