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];
659 qWarning(
"Frame::setReferenceFrame would create a loop in Frame hierarchy");
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)
Quaternion inverse() const
Vec transformOfIn(const Vec &src, const Frame *const in) const
void getOrientation(double &q0, double &q1, double &q2, double &q3) const
Vec inverseTransformOf(const Vec &src) const
void getRotation(double &q0, double &q1, double &q2, double &q3) const
void getTransformOf(const float src[3], float res[3]) const
void getLocalInverseTransformOf(const float src[3], float res[3]) const
void getMatrix(GLdouble m[4][4]) const
Vec localInverseCoordinatesOf(const Vec &src) const
Vec transformOf(const Vec &src) const
void setPositionWithConstraint(Vec &position)
void getCoordinatesOf(const float src[3], float res[3]) const
void getLocalCoordinatesOf(const float src[3], float res[3]) const
void getTransformOfFrom(const float src[3], float res[3], const Frame *const from) const
void setRotationWithConstraint(Quaternion &rotation)
virtual QDomElement domElement(const QString &name, QDomDocument &document) const
void getCoordinatesOfIn(const float src[3], float res[3], const Frame *const in) const
Vec rotate(const Vec &v) const
void getWorldMatrix(GLdouble m[4][4]) const
virtual void constrainTranslation(Vec &translation, Frame *const frame)
void setConstraint(Constraint *const constraint)
void setTranslationWithConstraint(Vec &translation)
void getCoordinatesOfFrom(const float src[3], float res[3], const Frame *const from) const
Vec inverseRotate(const Vec &v) 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 getPosition(float &x, float &y, float &z) const
void rotate(Quaternion &q)
The Vec class represents 3D positions and 3D vectors.
const GLdouble * matrix() const
const GLdouble * worldMatrix() const
void getLocalTransformOf(const float src[3], float res[3]) 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
void getInverseTransformOf(const float src[3], float res[3]) const
Quaternion rotation() const
void setFromMatrix(const GLdouble m[4][4])
void getTransformOfIn(const float src[3], float res[3], const Frame *const in) const
Vec transformOfFrom(const Vec &src, const Frame *const from) const
void getTranslation(float &x, float &y, float &z) 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 getInverseCoordinatesOf(const float src[3], float res[3]) const
void projectOnAxis(const Vec &direction)
const Frame * referenceFrame_
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)
void getLocalInverseCoordinatesOf(const float src[3], float res[3]) const
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)
void alignWithFrame(const Frame *const frame, bool move=false, float threshold=0.85f)
virtual void initFromDOMElement(const QDomElement &element)
void rotateAroundPoint(Quaternion &rotation, const Vec &point)