OpenWalnut  1.5.0dev
WCoordConverter.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WCOORDCONVERTER_H
26 #define WCOORDCONVERTER_H
27 
28 #include <memory>
29 #include <utility>
30 
31 #include "WTalairachConverter.h"
32 #include "core/common/WBoundingBox.h"
33 #include "core/common/math/WMatrix.h"
34 #include "core/common/math/linearAlgebra/WPosition.h"
35 
36 
37 typedef enum
38 {
39  CS_WORLD = 0,
40  CS_CANONICAL,
41  CS_TALAIRACH
42 }
43 coordinateSystemMode;
44 
45 /**
46  * Class to provide conversion for a given coordinate in 3D space
47  */
49 {
50 public:
51  /**
52  * standard constructor
53  *
54  * \param rotMat rotation matrix
55  * \param origin offset to point of origin
56  * \param scale voxel size
57  */
58  WCoordConverter( WMatrix<double> rotMat, WVector3d origin = WVector3d( 0, 0 , 0 ), WVector3d scale = WVector3d( 1.0, 1.0 , 1.0 ) );
59 
60  /**
61  * destructor
62  */
63  virtual ~WCoordConverter();
64 
65  /**
66  * Operator ()
67  *
68  * \param in vector to convert
69  *
70  * \return converted vector
71  */
73 
74  /**
75  * Transforms world coordinates.
76  * \param point The point which will be transformed.
77  *
78  * \return the transformed world coordinate
79  */
81 
82  /**
83  * Gets the bounding box
84  *
85  * \return The axis aligned bounding box
86  */
88 
89  /**
90  * Sets the bounding box of the volume.
91  *
92  * \param boundingBox The axis aligned bounding box.
93  */
94  void setBoundingBox( WBoundingBox boundingBox );
95 
96  /**
97  * setter for coordinate system mode
98  *
99  * \param mode
100  */
101  void setCoordinateSystemMode( coordinateSystemMode mode );
102 
103  /**
104  * getter for coordinate system mode
105  *
106  * \return the mode
107  */
108  coordinateSystemMode getCoordinateSystemMode();
109 
110  /**
111  * converts a number on the x axis according to the currently selected coordinate system
112  * \param number
113  * \return the number transformed
114  */
115  int numberToCsX( int number );
116 
117  /**
118  * converts a number on the y axis according to the currently selected coordinate system
119  * \param number
120  * \return the number transformed
121  */
122  int numberToCsY( int number );
123 
124  /**
125  * converts a number on the z axis according to the currently selected coordinate system
126  * \param number
127  * \return the number transformed
128  */
129  int numberToCsZ( int number );
130 
131  /**
132  * transforms a vector from the world coordinate system to the canonical system
133  * \param in vector to transform
134  * \return WVector3d the transformed vector
135  */
136  WVector3d w2c( WVector3d in );
137 
138  /**
139  * transforms a vector from the canonical to the world coordinate system system
140  * \param in vector to transform
141  * \return WVector3d the transformed vector
142  */
143  WVector3d c2w( WVector3d in );
144 
145  /**
146  * transforms a vector from the world coordinate system to the talairach system
147  * \param in vector to transform
148  * \return WVector3d the transformed vector
149  */
150  WVector3d w2t( WVector3d in );
151 
152  /**
153  * transforms a vector from the canonical system to the world coordinate system
154  * \param in vector to transform
155  * \return WVector3d the transformed vector
156  */
157  WVector3d t2w( WVector3d in );
158 
159  /**
160  * setter for the talairach converter pointer
161  * \param tc
162  */
163  void setTalairachConverter( std::shared_ptr<WTalairachConverter> tc );
164 
165  /**
166  * getter for the talairach converter pointer
167  * \return pointer
168  */
169  std::shared_ptr<WTalairachConverter> getTalairachConverter();
170 
171 protected:
172 private:
173  WMatrix<double> m_rotMat; //!< the rotation matrix to use
174 
175  WVector3d m_origin; //!< the offset to the point of origin
176 
177  WVector3d m_scale; //!< scaling of voxels
178 
179  WBoundingBox m_boundingBox; //!< bounding box of the wholy volume as provided by the dataset
180 
181  coordinateSystemMode m_coordinateSystemMode; //!< the currently selected coordinate system mode
182 
183  std::shared_ptr<WTalairachConverter>m_talairachConverter; //!< pointer to talairach convert for easy access
184 };
185 
186 #endif // WCOORDCONVERTER_H
Class to provide conversion for a given coordinate in 3D space.
std::shared_ptr< WTalairachConverter > getTalairachConverter()
getter for the talairach converter pointer
WVector3d worldCoordTransformed(WPosition point)
Transforms world coordinates.
int numberToCsZ(int number)
converts a number on the z axis according to the currently selected coordinate system
WVector3d w2t(WVector3d in)
transforms a vector from the world coordinate system to the talairach system
WVector3d operator()(WVector3d in)
Operator ()
WMatrix< double > m_rotMat
the rotation matrix to use
WBoundingBox m_boundingBox
bounding box of the wholy volume as provided by the dataset
int numberToCsX(int number)
converts a number on the x axis according to the currently selected coordinate system
std::shared_ptr< WTalairachConverter > m_talairachConverter
pointer to talairach convert for easy access
void setBoundingBox(WBoundingBox boundingBox)
Sets the bounding box of the volume.
coordinateSystemMode getCoordinateSystemMode()
getter for coordinate system mode
WVector3d m_scale
scaling of voxels
WVector3d c2w(WVector3d in)
transforms a vector from the canonical to the world coordinate system system
WVector3d w2c(WVector3d in)
transforms a vector from the world coordinate system to the canonical system
void setTalairachConverter(std::shared_ptr< WTalairachConverter > tc)
setter for the talairach converter pointer
WVector3d m_origin
the offset to the point of origin
int numberToCsY(int number)
converts a number on the y axis according to the currently selected coordinate system
void setCoordinateSystemMode(coordinateSystemMode mode)
setter for coordinate system mode
WBoundingBox getBoundingBox()
Gets the bounding box.
WVector3d t2w(WVector3d in)
transforms a vector from the canonical system to the world coordinate system
coordinateSystemMode m_coordinateSystemMode
the currently selected coordinate system mode
WCoordConverter(WMatrix< double > rotMat, WVector3d origin=WVector3d(0, 0, 0), WVector3d scale=WVector3d(1.0, 1.0, 1.0))
standard constructor
virtual ~WCoordConverter()
destructor
This only is a 3d double vector.