36 : 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];
275 for (
int i=0; i<4; ++i)
276 for (
int j=0; j<4; ++j)
277 mat[i][j] = m[i*4+j];
668 qWarning(
"Frame::setReferenceFrame would create a loop in Frame hierarchy");
682 const Frame* f = frame;
717 const Frame* fr =
this;
766 const Frame* fr =
this;
768 while ((fr != NULL) && (fr != in))
788 for (
int i=0; i<3 ; ++i)
796 for (
int i=0; i<3 ; ++i)
804 for (
int i=0; i<3 ; ++i)
812 for (
int i=0; i<3 ; ++i)
820 for (
int i=0; i<3 ; ++i)
828 for (
int i=0; i<3 ; ++i)
858 const Frame* fr =
this;
907 const Frame* fr =
this;
909 while ((fr != NULL) && (fr != in))
929 for (
int i=0; i<3 ; ++i)
937 for (
int i=0; i<3 ; ++i)
945 for (
int i=0; i<3 ; ++i)
953 for (
int i=0; i<3 ; ++i)
961 for (
int i=0; i<3 ; ++i)
969 for (
int i=0; i<3 ; ++i)
997 QDomElement e = document.createElement(name);
1020 QDomElement child=element.firstChild().toElement();
1021 while (!child.isNull())
1023 if (child.tagName() ==
"position")
1025 if (child.tagName() ==
"orientation")
1028 child = child.nextSibling().toElement();
1057 Vec directions[2][3];
1058 for (
unsigned short d=0; d<3; ++d)
1060 Vec dir((d==0)? 1.0 : 0.0, (d==1)? 1.0 : 0.0, (d==2)? 1.0 : 0.0);
1064 directions[0][d] = dir;
1068 qreal maxProj = 0.0;
1070 unsigned short index[2];
1071 index[0] = index[1] = 0;
1072 for (
unsigned short i=0; i<3; ++i)
1073 for (
unsigned short j=0; j<3; ++j)
1074 if ( (proj=fabs(directions[0][i]*directions[1][j])) >= maxProj )
1084 qreal coef = directions[0][index[0]] * directions[1][index[1]];
1085 if (fabs(coef) >= threshold)
1087 const Vec axis = cross(directions[0][index[0]], directions[1][index[1]]);
1088 qreal angle = asin(axis.
norm());
1094 unsigned short d = (index[1]+1) % 3;
1095 Vec dir((d==0)? 1.0 : 0.0, (d==1)? 1.0 : 0.0, (d==2)? 1.0 : 0.0);
1099 for (
unsigned short i=0; i<3; ++i)
1101 qreal proj = fabs(directions[0][i]*dir);
1109 if (max >= threshold)
1111 const Vec axis = cross(directions[0][index[0]], dir);
1112 qreal angle = asin(axis.
norm());
1113 if (directions[0][index[0]] * dir >= 0.0)
Quaternion inverse() const
Vec transformOfIn(const Vec &src, const Frame *const in) const
Vec inverseTransformOf(const Vec &src) const
void getInverseTransformOf(const qreal src[3], qreal res[3]) const
void getMatrix(GLdouble m[4][4]) const
void getCoordinatesOfIn(const qreal src[3], qreal res[3], const Frame *const in) const
void getLocalInverseCoordinatesOf(const qreal src[3], qreal res[3]) const
Vec localInverseCoordinatesOf(const Vec &src) const
void getLocalInverseTransformOf(const qreal src[3], qreal res[3]) const
Vec transformOf(const Vec &src) const
void setPositionWithConstraint(Vec &position)
void getTransformOfFrom(const qreal src[3], qreal res[3], const Frame *const from) const
void setRotationWithConstraint(Quaternion &rotation)
virtual QDomElement domElement(const QString &name, QDomDocument &document) const
void getCoordinatesOf(const qreal src[3], qreal res[3]) const
Vec rotate(const Vec &v) const
void getWorldMatrix(GLdouble m[4][4]) const
void getLocalCoordinatesOf(const qreal src[3], qreal res[3]) const
virtual void constrainTranslation(Vec &translation, Frame *const frame)
void setConstraint(Constraint *const constraint)
void getTransformOf(const qreal src[3], qreal res[3]) const
void setTranslationWithConstraint(Vec &translation)
Vec inverseRotate(const Vec &v) const
void getTransformOfIn(const qreal src[3], qreal res[3], const Frame *const in) const
void setFromRotationMatrix(const float m[3][3])
void setReferenceFrame(const Frame *const refFrame)
Vec localCoordinatesOf(const Vec &src) const
void setRotation(const Quaternion &rotation)
void rotate(Quaternion &q)
The Vec class represents 3D positions and 3D vectors.
const GLdouble * matrix() const
const GLdouble * worldMatrix() const
void getPosition(qreal &x, qreal &y, qreal &z) const
bool settingAsReferenceFrameWillCreateALoop(const Frame *const frame)
void setTranslation(const Vec &translation)
Vec localTransformOf(const Vec &src) const
void projectOnLine(const Vec &origin, const Vec &direction)
Quaternion normalized() const
Quaternion rotation() const
void getTranslation(qreal &x, qreal &y, qreal &z) const
void getCoordinatesOfFrom(const qreal src[3], qreal res[3], const Frame *const from) const
void setFromMatrix(const GLdouble m[4][4])
void getInverseCoordinatesOf(const qreal src[3], qreal res[3]) const
Vec transformOfFrom(const Vec &src, const Frame *const from) const
void setTranslationAndRotation(const Vec &translation, const Quaternion &rotation)
Vec coordinatesOf(const Vec &src) const
The Quaternion class represents 3D rotations and orientations.
Quaternion orientation() const
void setOrientationWithConstraint(Quaternion &orientation)
Vec coordinatesOfFrom(const Vec &src, const Frame *const from) const
void setTranslationAndRotationWithConstraint(Vec &translation, Quaternion &rotation)
Constraint * constraint() const
void setPosition(const Vec &position)
void projectOnAxis(const Vec &direction)
const Frame * referenceFrame_
void alignWithFrame(const Frame *const frame, bool move=false, qreal threshold=0.0)
void getOrientation(qreal &q0, qreal &q1, qreal &q2, qreal &q3) const
The Frame class represents a coordinate system, defined by a position and an orientation.
void getMatrix(GLdouble m[4][4]) const
Frame & operator=(const Frame &frame)
void setOrientation(const Quaternion &orientation)
virtual void constrainRotation(Quaternion &rotation, Frame *const frame)
const Frame * referenceFrame() const
Vec localInverseTransformOf(const Vec &src) const
Vec inverseCoordinatesOf(const Vec &src) const
void setPositionAndOrientation(const Vec &position, const Quaternion &orientation)
Vec coordinatesOfIn(const Vec &src, const Frame *const in) const
void setPositionAndOrientationWithConstraint(Vec &position, Quaternion &orientation)
virtual void initFromDOMElement(const QDomElement &element)
void getRotation(qreal &q0, qreal &q1, qreal &q2, qreal &q3) const
void getLocalTransformOf(const qreal src[3], qreal res[3]) const
void rotateAroundPoint(Quaternion &rotation, const Vec &point)