Medical Imaging Interaction Toolkit  2016.11.0
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
18 //#include "bussvrmath/Quaternion.h"
19 //#include "SphereMean.h"
20 
22 {
23 
24 
25 }
26 
28 {
29 
30 }
31 
32 mitk::Quaternion mitk::QuaternionAveraging::CalcAverage(const std::vector<Quaternion>& quaternions, Mode mode)
33 {
34 mitk::Quaternion result;
35 switch (mode)
36  {
37  case SimpleMean:
38  for (std::vector<Quaternion>::size_type i=0; i<quaternions.size(); i++)
39  {
40  result[0] += quaternions.at(i)[0];
41  result[1] += quaternions.at(i)[1];
42  result[2] += quaternions.at(i)[2];
43  result[3] += quaternions.at(i)[3];
44  }
45  result[0] /= quaternions.size();
46  result[1] /= quaternions.size();
47  result[2] /= quaternions.size();
48  result[3] /= quaternions.size();
49  result.normalize();
50  break;
51 
52  case Slerp:
53  MITK_WARN << "SLERP is not implemented yet!";
54  /* To avtivate this code, the vrMath classes from Sam Buss need to be included
55  BussQuaternion* bussQuaternions = new BussQuaternion[quaternions.size()];
56  double* wheights = new double[quaternions.size()];
57  for (int i=0; i < quaternions.size(); i++) {
58  bussQuaternions[i] = BussQuaternion(quaternions.at(i).x(), quaternions.at(i).y(), quaternions.at(i).z(), quaternions.at(i).r());
59  wheights[i]=1;
60  }
61  BussQuaternion bussResult = ComputeMeanQuat(5,bussQuaternions, wheights);
62  mitk::Quaternion resultSlerp(bussResult.x,bussResult.y,bussResult.z,bussResult.w);
63  result = resultSlerp;
64  */
65  break;
66  }
67 
68  return result;
69 }
#define MITK_WARN
Definition: mitkLogMacros.h:23
vnl_quaternion< ScalarType > Quaternion
static mitk::Quaternion CalcAverage(const std::vector< Quaternion > &quaternions, Mode mode=SimpleMean)