OpenWalnut  1.5.0dev
WManipulatorRotation.cpp
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 #include <Eigen/Dense>
26 
27 #include "core/common/math/WMath.h"
28 
29 #include "WManipulatorRotation.h"
30 
32  : WObjectNDIP< WManipulatorInterface >( "Rotation", "Rotates the dataset." )
33 {
34  m_axis = m_properties->addProperty( "Rotation axis", "Axis to rotate around in world coordinates.", WPosition( 0.0, 0.0, 1.0 ) );
35  m_angle = m_properties->addProperty( "Rotation angle", "The angle to rotate.", 0.0 );
36  m_angle->setMin( 0.0 );
37  m_angle->setMax( 2.0 * pi() );
38 }
39 
41 {
42 }
43 
45 {
46  WPosition w = m_axis->get( true );
47  Eigen::Vector3d v( w[ 0 ], w[ 1 ], w[ 2 ] );
48 
49  Eigen::AngleAxisd aa( m_angle->get( true ), v );
51  for( std::size_t i = 0; i < 3; ++i )
52  {
53  for( std::size_t j = 0; j < 3; ++j )
54  {
55  mat( i, j ) = aa.toRotationMatrix()( i, j );
56  }
57  }
58 
59  return mat;
60 }
61 
63 {
64  return m_angle->changed() || m_axis->changed();
65 }
66 
68 {
69  m_angle->set( 0.0, false );
70  m_axis->set( WPosition( 0.0, 0.0, 1.0 ), false );
71 }
72 
An interface for dataset transformation manipulators.
virtual void reset()
Reset the transform.
WPropDouble m_angle
The angle to rotate.
WPropPosition m_axis
The axis to rotate around in world coordinates.
WManipulatorRotation()
Constructor.
virtual bool transformationChanged() const
Check if the transform has changed, for example because of a change to properties.
virtual ~WManipulatorRotation()
Destructor.
virtual WMatrixFixed< double, 4, 4 > getTransformationMatrix() const
Get the transformation matrix from this manipulator.
static MatrixType identity()
Returns an identity matrix.
Definition: WMatrixFixed.h:310
This is a base class for everything which has a Name,Description,Icon and Properties (=NDIP).
Definition: WObjectNDIP.h:42
WProperties::SPtr m_properties
the properties of the object.
Definition: WObjectNDIP.h:99
This only is a 3d double vector.