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
coordmapper.hpp
Go to the documentation of this file.
1 
5 /* Copyright (c) 2005-2010 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 COORDMAPPER_HPP
44 #define COORDMAPPER_HPP 1
45 
46 
47 #include <iostream>
48 
49 
58  double _xx, _x0;
60 public:
61 
65  : _xx(1.0), _x0(0.0) {}
66 
69  Coordmapper1D( double xx, double x0 )
70  : _xx(xx), _x0(x0) {}
71 
74  void set_transformation( double xx, double x0 ) {
75  _xx = xx;
76  _x0 = x0;
77  }
78 
82  void transform( double &xout, const double &xin ) const {
83  xout = _xx * xin + _x0;
84  }
85 
89  void transform( double &x ) const {
90  x = _xx * x + _x0;
91  }
92 
95  void inv_transform( double &xout, const double &xin ) const {
96  xout = (xin-_x0) / _xx;
97  }
98 
101  void inv_transform( double &x ) const {
102  x = (x-_x0) / _xx;
103  }
104 
107  void debug_print( std::ostream &os ) const {
108  os << "**Coordmapper1D\n";
109  os << "_xx = " << _xx << "\n";
110  os << "_x0 = " << _x0 << "\n";
111  }
112 };
113 
114 
115 
119 class Coordmapper {
120  Coordmapper1D _cmx;
121  Coordmapper1D _cmy;
123 public:
124 
128 
133  : _cmx(cmx), _cmy(cmy) {}
134 
137  Coordmapper( double xx, double x0, double yy, double y0 )
138  : _cmx(xx,x0), _cmy(yy,y0) {}
139 
142  void set_transformation( double xx, double x0, double yy, double y0 ) {
143  _cmx.set_transformation( xx, x0 );
144  _cmy.set_transformation( yy, y0 );
145  }
146 
149  void transform( double &x, double &y ) const {
150  _cmx.transform( x );
151  _cmy.transform( y );
152  }
153 
157  void transform( double *xout, const double *xin ) const {
158  _cmx.transform( xout[0], xin[0] );
159  _cmy.transform( xout[1], xin[1] );
160  }
161 
164  void inv_transform( double &x, double &y ) const {
165  _cmx.inv_transform( x );
166  _cmy.inv_transform( y );
167  }
168 
172  void inv_transform( double *xout, const double *xin ) const {
173  _cmx.inv_transform( xout[0], xin[0] );
174  _cmy.inv_transform( xout[1], xin[1] );
175  }
176 
177 
180  void debug_print( std::ostream &os ) const {
181  os << "**Coordmapper x:\n";
182  _cmx.debug_print( os );
183  os << "**Coordmapper y:\n";
184  _cmy.debug_print( os );
185  }
186 };
187 
188 
189 #endif
190 
191 
192 
193 
194 
195 
196 
197 
198 
199 
200 
201 
202 
203 
204 
205 
206 
207 
208 
209 
210 
Linear 1D coordinate mapper.
Definition: coordmapper.hpp:57
Coordmapper1D(double xx, double x0)
Constructor for fully defined transformation.
Definition: coordmapper.hpp:69
void inv_transform(double &xout, const double &xin) const
Make inverse transformation for coordinate x.
Definition: coordmapper.hpp:95
void set_transformation(double xx, double x0)
Set transformation coefficients.
Definition: coordmapper.hpp:74
Coordmapper1D()
Default constructor for unitary transformation.
Definition: coordmapper.hpp:64
void debug_print(std::ostream &os) const
Debug print to stream.
Definition: coordmapper.hpp:107
void transform(double &xout, const double &xin) const
Make transformation from coordinates xin to coordinates xout.
Definition: coordmapper.hpp:82
void transform(double &x) const
Make transformation from coordinates xin to coordinates xout.
Definition: coordmapper.hpp:89
void inv_transform(double &x) const
Make inverse transformation for coordinate x.
Definition: coordmapper.hpp:101
Linear-linear 2D coordinate mapper.
Definition: coordmapper.hpp:119
void debug_print(std::ostream &os) const
Debug print to stream.
Definition: coordmapper.hpp:180
Coordmapper(double xx, double x0, double yy, double y0)
Constructor for fully defined transformation.
Definition: coordmapper.hpp:137
void transform(double *xout, const double *xin) const
Make transformation from coordinates xin to coordinates xout.
Definition: coordmapper.hpp:157
void inv_transform(double *xout, const double *xin) const
Make inverse transformation from coordinates xin to coordinates xout.
Definition: coordmapper.hpp:172
void inv_transform(double &x, double &y) const
Make inverse transformation for coordinates x, y.
Definition: coordmapper.hpp:164
Coordmapper(Coordmapper1D cmx, Coordmapper1D cmy)
Constructor for fully defined transformation using 1D coordinate mappers.
Definition: coordmapper.hpp:132
void transform(double &x, double &y) const
Make transformation for coordinates x, y.
Definition: coordmapper.hpp:149
void set_transformation(double xx, double x0, double yy, double y0)
Set transformation matrix coefficients.
Definition: coordmapper.hpp:142
Coordmapper()
Default constructor for unitary transformation.
Definition: coordmapper.hpp:127


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