Navigation

Main Page
Download
Support
Installation
Tutorial
Examples
Reference Manual
   Version 1.0.6dev
      Class Index
      File List
   Version 1.0.6
   Version 1.0.5new_solver
   Version 1.0.5dev
   Version 1.0.5b
   Version 1.0.4dev
   Version 1.0.4
Publications


Hosted by Get Ion Beam Simulator at SourceForge.net. Fast, secure and Free Open Source software downloads
transformation.hpp
Go to the documentation of this file.
1 
5 /* Copyright (c) 2010-2012,2015 Taneli Kalvas. All rights reserved.
6  *
7  * You can redistribute this software and/or modify it under the terms
8  * of the GNU General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * This library is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this library (file "COPYING" included in the package);
19  * if not, write to the Free Software Foundation, Inc., 51 Franklin
20  * Street, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  * If you have questions about your rights to use or distribute this
23  * software, please contact Berkeley Lab's Technology Transfer
24  * Department at TTD@lbl.gov. Other questions, comments and bug
25  * reports should be sent directly to the author via email at
26  * taneli.kalvas@jyu.fi.
27  *
28  * NOTICE. This software was developed under partial funding from the
29  * U.S. Department of Energy. As such, the U.S. Government has been
30  * granted for itself and others acting on its behalf a paid-up,
31  * nonexclusive, irrevocable, worldwide license in the Software to
32  * reproduce, prepare derivative works, and perform publicly and
33  * display publicly. Beginning five (5) years after the date
34  * permission to assert copyright is obtained from the U.S. Department
35  * of Energy, and subject to any subsequent five (5) year renewals,
36  * the U.S. Government is granted for itself and others acting on its
37  * behalf a paid-up, nonexclusive, irrevocable, worldwide license in
38  * the Software to reproduce, prepare derivative works, distribute
39  * copies to the public, perform publicly and display publicly, and to
40  * permit others to do so.
41  */
42 
43 #ifndef TRANSFORMATION_HPP
44 #define TRANSFORMATION_HPP 1
45 
46 
47 #include <string.h>
48 #include "vec3d.hpp"
49 #include "vec4d.hpp"
50 
51 
70 {
71 
72  double x[16];
73 
74 public:
75 
79 
82  Transformation( double x11, double x12, double x13, double x14,
83  double x21, double x22, double x23, double x24,
84  double x31, double x32, double x33, double x34,
85  double x41, double x42, double x43, double x44 );
86 
89  Transformation( const Transformation &m );
90 
93  Transformation( std::istream &is );
94 
98 
101  double &operator[]( int i ) {
102  return( x[i] );
103  }
104 
107  const double &operator[]( int i ) const {
108  return( x[i] );
109  }
110 
113  Transformation transpose( void ) const;
114 
117  double determinant( void ) const;
118 
123  Transformation inverse( void ) const;
124 
127  bool operator!=( const Transformation &m ) const;
128 
131  const Transformation &operator*=( double s );
132 
141  Transformation operator*( const Transformation &m ) const;
142 
147  Vec4D operator*( const Vec4D &v ) const;
148 
154  Vec4D operator%( const Vec4D &v ) const;
155 
158  Vec4D transform( const Vec4D &xin ) const {
159  return( *this * xin );
160  }
161 
166  Vec4D transform_homogenous_point( const Vec3D &xin ) const {
167  return( *this * Vec4D( xin[0], xin[1], xin[2], 1.0 ) );
168  }
169 
175  Vec3D transform_point( const Vec3D &xin ) const {
176  Vec4D r = *this * Vec4D( xin[0], xin[1], xin[2], 1.0 );
177  return( Vec3D( r[0], r[1], r[2] ) );
178  }
179 
189  Vec3D inv_transform_point( const Vec3D &xin ) const;
190 
196  Vec3D transform_vector( const Vec3D &xin ) const {
197  Vec4D r = *this * Vec4D( xin[0], xin[1], xin[2], 0.0 );
198  return( Vec3D( r[0], r[1], r[2] ) );
199  }
200 
210  Vec3D inv_transform_vector( const Vec3D &xin ) const;
211 
216  void reset( void );
217 
223  void translate( const Vec3D &d );
224 
230  void translate_before( const Vec3D &d );
231 
237  void scale( const Vec3D &s );
238 
244  void scale_before( const Vec3D &s );
245 
253  void rotate_x( double a );
254 
262  void rotate_x_before( double a );
263 
271  void rotate_y( double a );
272 
280  void rotate_y_before( double a );
281 
289  void rotate_z( double a );
290 
298  void rotate_z_before( double a );
299 
302  static Transformation unity( void );
303 
306  static Transformation translation( const Vec3D &d );
307 
310  static Transformation scaling( const Vec3D &s );
311 
314  static Transformation rotation_x( double a );
315 
318  static Transformation rotation_y( double a );
319 
322  static Transformation rotation_z( double a );
323 
326  friend std::ostream &operator<<( std::ostream &os, const Transformation &t );
327 
330  void save( const std::string &filename ) const;
331 
334  void save( std::ostream &os ) const;
335 
338  void debug_print( std::ostream &os ) const;
339 };
340 
341 
342 #endif
Transformation for homogenous three dimensional space.
Definition: transformation.hpp:70
void rotate_y(double a)
Rotate transformation around y-axis.
Definition: transformation.cpp:318
Vec4D transform_homogenous_point(const Vec3D &xin) const
Transform point xin to homogenous space.
Definition: transformation.hpp:166
const Transformation & operator*=(double s)
Multiplication of tranformation matrix by scalar.
Definition: transformation.cpp:195
void save(const std::string &filename) const
Saves data to a new file filename.
Definition: transformation.cpp:396
Transformation()
Constructor for identity transformation.
Definition: transformation.cpp:50
static Transformation rotation_z(double a)
Return rotation transformation rotating around z-axis.
Definition: transformation.cpp:387
void translate_before(const Vec3D &d)
Translate transformation.
Definition: transformation.cpp:288
Vec4D operator%(const Vec4D &v) const
Multiplication of the transpose of the tranformation matrix by vector.
Definition: transformation.cpp:244
static Transformation rotation_x(double a)
Return rotation transformation rotating around x-axis.
Definition: transformation.cpp:369
void translate(const Vec3D &d)
Translate transformation.
Definition: transformation.cpp:282
Vec3D transform_point(const Vec3D &xin) const
Transform point xin.
Definition: transformation.hpp:175
Vec3D inv_transform_point(const Vec3D &xin) const
Inverse transform point xin.
Definition: transformation.cpp:257
void rotate_y_before(double a)
Rotate transformation around y-axis.
Definition: transformation.cpp:324
void scale(const Vec3D &s)
Scale transformation.
Definition: transformation.cpp:294
bool operator!=(const Transformation &m) const
Non-equality test.
Definition: transformation.cpp:185
void debug_print(std::ostream &os) const
Print debugging information to stream os.
Definition: transformation.cpp:426
void rotate_z(double a)
Rotate transformation around z-axis.
Definition: transformation.cpp:330
friend std::ostream & operator<<(std::ostream &os, const Transformation &t)
Outputting to stream.
Definition: transformation.cpp:413
static Transformation scaling(const Vec3D &s)
Return scaling transformation.
Definition: transformation.cpp:360
Transformation transpose(void) const
Return transpose matrix.
Definition: transformation.cpp:175
Transformation inverse(void) const
Return inverse matrix.
Definition: transformation.cpp:131
void reset(void)
Reset transformation.
Definition: transformation.cpp:275
const double & operator[](int i) const
Indexing for constant transformation matrix.
Definition: transformation.hpp:107
static Transformation translation(const Vec3D &d)
Return translation transformation.
Definition: transformation.cpp:351
double determinant(void) const
Return determinant of matrix.
Definition: transformation.cpp:102
static Transformation rotation_y(double a)
Return rotation transformation rotating around y-axis.
Definition: transformation.cpp:378
static Transformation unity(void)
Return unity transformation.
Definition: transformation.cpp:342
Vec3D transform_vector(const Vec3D &xin) const
Transform vector xin.
Definition: transformation.hpp:196
void rotate_z_before(double a)
Rotate transformation around z-axis.
Definition: transformation.cpp:336
void rotate_x_before(double a)
Rotate transformation around x-axis.
Definition: transformation.cpp:312
~Transformation()
Destructor.
Definition: transformation.cpp:96
Transformation operator*(const Transformation &m) const
Multiplication of transformation matrices for combining transformations.
Definition: transformation.cpp:203
double & operator[](int i)
Indexing for transformation matrix.
Definition: transformation.hpp:101
void scale_before(const Vec3D &s)
Scale transformation.
Definition: transformation.cpp:300
Vec3D inv_transform_vector(const Vec3D &xin) const
Inverse transform vector xin.
Definition: transformation.cpp:266
void rotate_x(double a)
Rotate transformation around x-axis.
Definition: transformation.cpp:306
Vec4D transform(const Vec4D &xin) const
Transform homogenous vector xin.
Definition: transformation.hpp:158
Three dimensional vector.
Definition: vec3d.hpp:58
Homogenous vector for three dimensional space.
Definition: vec4d.hpp:67
Three dimensional vectors.
Homogenous vectors for three dimensional space.


Reference manual for Ion Beam Simulator 1.0.6dev
Generated by Doxygen 1.9.1 on Thu Sep 11 2025 09:37:24.