Jpp  17.2.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Member Functions | List of all members
JMATH::JSVD3D::JQuaternion Struct Reference

Auxiliary class for quaternion computation. More...

Inheritance diagram for JMATH::JSVD3D::JQuaternion:

Public Member Functions

 JQuaternion (JMatrix3S &S)
 Constructor. More...
 

Private Member Functions

void conjugate (const int x, const int y, const int z, JMatrix3S &S)
 Get conjugate of symmetric matrix for given order. More...
 

Detailed Description

Auxiliary class for quaternion computation.

Definition at line 233 of file JSVD3D.hh.

Constructor & Destructor Documentation

JMATH::JSVD3D::JQuaternion::JQuaternion ( JMatrix3S S)
inline

Constructor.

Finds transformation that diagonalizes the given symmetric matrix by using Jacobi eigen analysis.

Parameters
Smatrix

Definition at line 243 of file JSVD3D.hh.

244  {
245  // follow same indexing convention as GLM
246 
247  (*this)[3] = 1.0;
248  (*this)[0] = 0.0;
249  (*this)[1] = 0.0;
250  (*this)[2] = 0.0;
251 
252  for (int i = 0; i != 4; ++i) {
253 
254  // eliminate maximum off-diagonal element on every iteration,
255  // while cycling over all 3 possible rotations in fixed order.
256  // (p,q) = (0,1), (1,2), (0,2) still retains asymptotic convergence.
257 
258  conjugate(0, 1, 2, S); // (p,q) = (0,1)
259  conjugate(1, 2, 0, S); // (p,q) = (1,2)
260  conjugate(2, 0, 1, S); // (p,q) = (0,2)
261  }
262  }
void conjugate(const int x, const int y, const int z, JMatrix3S &S)
Get conjugate of symmetric matrix for given order.
Definition: JSVD3D.hh:274

Member Function Documentation

void JMATH::JSVD3D::JQuaternion::conjugate ( const int  x,
const int  y,
const int  z,
JMatrix3S S 
)
inlineprivate

Get conjugate of symmetric matrix for given order.

Parameters
x1st index
y2nd index
z3rd index
Smatrix

Definition at line 274 of file JSVD3D.hh.

278  {
279  static const double GAMMA = sqrt(8.0) + 3.0;
280  static const double CSTAR = cos(PI/8.0);
281  static const double SSTAR = sin(PI/8.0);
282 
283  // approximate Givens quaternion
284 
285  double ch = 2.0*(S.a00 - S.a11);
286  double sh = S.a10;
287 
288  if (GAMMA*sh*sh < ch*ch) {
289 
290  const double w = 1.0 / sqrt(ch*ch+sh*sh);
291 
292  ch *= w;
293  sh *= w;
294 
295  } else {
296 
297  ch = CSTAR;
298  sh = SSTAR;
299  }
300 
301  const double scale = ch*ch + sh*sh;
302  const double a = (ch+sh)*(ch-sh) / scale;
303  const double b = (2.0*sh*ch) / scale;
304 
305  // make temporary copy of S
306 
307  double s00 = S.a00;
308  double s10 = S.a10; double s11 = S.a11;
309  double s20 = S.a20; double s21 = S.a21; double s22 = S.a22;
310 
311  // perform conjugation S = Q' * S * Q
312  // where Q is already implicitly solved from a and b
313 
314  S.a00 = a*( a*s00 + b*s10) + b*( a*s10 + b*s11);
315  S.a10 = a*(-b*s00 + a*s10) + b*(-b*s10 + a*s11);
316  S.a11 = -b*(-b*s00 + a*s10) + a*(-b*s10 + a*s11);
317  S.a20 = a*s20 + b*s21;
318  S.a21 = -b*s20 + a*s21;
319  S.a22 = s22;
320 
321  // update cumulative rotation
322 
323  double tmp[] = {
324  (*this)[0]*sh,
325  (*this)[1]*sh,
326  (*this)[2]*sh
327  };
328 
329  sh *= (*this)[3];
330 
331  (*this)[0] *= ch;
332  (*this)[1] *= ch;
333  (*this)[2] *= ch;
334  (*this)[3] *= ch;
335 
336  // (x,y,z) corresponds to {(0,1,2), (1,2,0), (2,0,1)}
337  // for (p,q) = {(0,1), (1,2), (0,2)}, respectively.
338 
339  (*this)[z] += sh;
340  (*this)[3] -= tmp[z]; // w
341  (*this)[x] += tmp[y];
342  (*this)[y] -= tmp[x];
343 
344  // re-arrange matrix for next iteration
345 
346  s00 = S.a11;
347  s10 = S.a21; s11 = S.a22;
348  s20 = S.a10; s21 = S.a20; s22 = S.a00;
349 
350  S.a00 = s00;
351  S.a10 = s10; S.a11 = s11;
352  S.a20 = s20; S.a21 = s21; S.a22 = s22;
353  }
data_type w[N+1][M+1]
Definition: JPolint.hh:778
static const double PI
Mathematical constants.
then JCalibrateToT a
Definition: JTuneHV.sh:116
void scale(vector< double > &v, double c)
scale vector content

The documentation for this struct was generated from the following file: