26 #ifndef OD_GEQUATERNION_H
27 #define OD_GEQUATERNION_H
58 :
w( 1. ),
x( 0. ),
y( 0. ),
z( 0. )
62 :
w(ww),
x(xx),
y(yy),
z(zz)
77 double trace = matrix[0][0] + matrix[1][1] + matrix[2][2];
80 w = sqrt(1.0 + trace) / 2.0;
82 double w4 = (4.0 *
w);
83 x = (matrix[1][2] - matrix[2][1]) / w4;
84 y = (matrix[2][0] - matrix[0][2]) / w4;
85 z = (matrix[0][1] - matrix[1][0]) / w4;
90 if (matrix[1][1] > matrix[0][0]) i = 1;
91 if (matrix[2][2] > matrix[i][i]) i = 2;
95 double s = sqrt((matrix[i][i] - (matrix[j][j] + matrix[k][k])) + 1.0);
99 if (s != 0.0) s = 0.5/s;
101 q[3] = (matrix[j][k] - matrix[k][j]) * s;
102 q[j] = (matrix[i][j] + matrix[j][i]) * s;
103 q[k] = (matrix[i][k] + matrix[k][i]) * s;
117 matrix( 0, 0 ) =
w *
w +
x *
x -
y *
y -
z *
z;
118 matrix( 1, 0 ) = 2. * (
x *
y -
w *
z );
119 matrix( 2, 0 ) = 2. * (
w *
y +
x *
z );
121 matrix( 0, 1 ) = 2. * (
w *
z +
x *
y );
122 matrix( 1, 1 ) =
w *
w -
x *
x +
y *
y -
z *
z;
123 matrix( 2, 1 ) = 2. * (
y *
z -
w *
x );
125 matrix( 0, 2 ) = 2. * (
x *
z -
w *
y );
126 matrix( 1, 2 ) = 2. * (
w *
x +
y *
z );
127 matrix( 2, 2 ) =
w *
w -
x *
x -
y *
y +
z *
z;
157 return fabs(
x - quat.
x) <=
tol.equalVector() &&
158 fabs(
y - quat.
y) <=
tol.equalVector() &&
159 fabs(
z - quat.
z) <=
tol.equalVector() &&
160 fabs(
w - quat.
w) <=
tol.equalVector();
165 return isEqualTo(quat);
169 return !isEqualTo(quat);
#define GE_TOOLKIT_EXPORT
OdGePoint3d & transformBy(const OdGeMatrix3d &xfm)
static GE_STATIC_EXPORT const OdGeQuaternion kOrigin
OdGeQuaternion & set(const OdGeMatrix3d &matrix)
OdGeMatrix3d getMatrix() const
OdGeQuaternion(double ww, double xx, double yy, double zz)
OdGeQuaternion & set(double ww, double xx, double yy, double zz)
OdGePoint3d rotate(OdGePoint3d &sourcePoint) const
bool isEqualTo(const OdGeQuaternion &quat, const OdGeTol &tol=OdGeContext::gTol) const
OdGeVector3d rotate(OdGeVector3d &vector) const
OdGeVector3d & transformBy(const OdGeMatrix3d &xfm)
GLfloat GLfloat GLfloat z
GLfloat GLfloat GLfloat GLfloat w
bool operator==(const BlockRefPath &rA, const BlockRefPath &rB)
DOM.
bool operator!=(const BlockRefPath &rA, const BlockRefPath &rB)
DOM.
static GE_STATIC_EXPORT OdGeTol gTol