OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
transform.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2011 by the OpenStructure authors
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License as published by the Free
8 // Software Foundation; either version 3.0 of the License, or (at your option)
9 // any later version.
10 // This library is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //------------------------------------------------------------------------------
19 #ifndef OST_MOL_BASE_TRANSFORM_HH
20 #define OST_MOL_BASE_TRANSFORM_HH
21 
22 /*
23  Author: Ansgar Philippsen
24 */
25 
26 #include <ost/config.hh>
27 #include <ost/geom/geom.hh>
28 #if(OST_INFO_ENABLED)
29 #include <ost/info/info_fw.hh>
30 #endif
31 #include <ost/mol/module_config.hh>
32 
33 namespace ost { namespace mol {
34 
38 public:
39  Transform();
40 
41  geom::Mat4 GetMatrix() const;
42  geom::Mat4 GetTransposedMatrix() const;
43 
44  void SetCenter(const geom::Vec3& c);
45  geom::Vec3 GetCenter() const;
46 
47  // directly set tm, messing up rot/trans/cen !
48  void SetMatrix(const geom::Mat4& m);
49 
51 
52 
53  void ApplyXAxisRotation(float delta);
54  void ApplyYAxisRotation(float delta);
55  void ApplyZAxisRotation(float delta);
56  void ApplyAxisRotation(float delta, const geom::Vec3& axis);
57 
58  geom::Mat3 GetXAxisRotation(float delta);
59  geom::Mat3 GetYAxisRotation(float delta);
60  geom::Mat3 GetZAxisRotation(float delta);
61 
62  geom::Mat3 GetRot() const;
63  void SetRot(const geom::Mat3& r);
65 
66 
67  void ApplyXAxisTranslation(float delta);
68  void ApplyYAxisTranslation(float delta);
69  void ApplyZAxisTranslation(float delta);
70  void SetTrans(const geom::Vec3& t);
71  geom::Vec3 GetTrans() const;
73 
74  geom::Vec3 Apply(const geom::Vec3& v) const;
75  geom::Vec4 Apply(const geom::Vec4& v) const;
76 
77 private:
78  geom::Mat3 rot_;
79  geom::Vec3 trans_;
80  geom::Vec3 cen_;
81  geom::Mat4 tm_;
82  geom::Mat4 ttm_;
83 
84  void update_tm();
85  void update_components();
86 };
87 
88 #if(OST_INFO_ENABLED)
89 
90 
91 Transform DLLEXPORT_OST_MOL TransformFromInfo(const info::InfoGroup& group);
94 void DLLEXPORT_OST_MOL TransformToInfo(const Transform& transform,
95  info::InfoGroup& group);
96 #endif
97 }} // ns
98 
99 #endif