Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkQuaternionAveraging.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
14 //#include "bussvrmath/Quaternion.h"
15 //#include "SphereMean.h"
16 
18 {
19 
20 
21 }
22 
24 {
25 
26 }
27 
28 mitk::Quaternion mitk::QuaternionAveraging::CalcAverage(const std::vector<Quaternion>& quaternions, Mode mode)
29 {
30 mitk::Quaternion result;
31 switch (mode)
32  {
33  case SimpleMean:
34  for (std::vector<Quaternion>::size_type i=0; i<quaternions.size(); i++)
35  {
36  result[0] += quaternions.at(i)[0];
37  result[1] += quaternions.at(i)[1];
38  result[2] += quaternions.at(i)[2];
39  result[3] += quaternions.at(i)[3];
40  }
41  result[0] /= quaternions.size();
42  result[1] /= quaternions.size();
43  result[2] /= quaternions.size();
44  result[3] /= quaternions.size();
45  result.normalize();
46  break;
47 
48  case Slerp:
49  MITK_WARN << "SLERP is not implemented yet!";
50  /* To avtivate this code, the vrMath classes from Sam Buss need to be included
51  BussQuaternion* bussQuaternions = new BussQuaternion[quaternions.size()];
52  double* wheights = new double[quaternions.size()];
53  for (int i=0; i < quaternions.size(); i++) {
54  bussQuaternions[i] = BussQuaternion(quaternions.at(i).x(), quaternions.at(i).y(), quaternions.at(i).z(), quaternions.at(i).r());
55  wheights[i]=1;
56  }
57  BussQuaternion bussResult = ComputeMeanQuat(5,bussQuaternions, wheights);
58  mitk::Quaternion resultSlerp(bussResult.x,bussResult.y,bussResult.z,bussResult.w);
59  result = resultSlerp;
60  */
61  break;
62  }
63 
64  return result;
65 }
#define MITK_WARN
Definition: mitkLogMacros.h:19
vnl_quaternion< ScalarType > Quaternion
static mitk::Quaternion CalcAverage(const std::vector< Quaternion > &quaternions, Mode mode=SimpleMean)