casacore
PixelCurve1D.h
Go to the documentation of this file.
1 //# PixelCurve1D.h: Arbitrary 1-dim curve in a lattice plane
2 //# Copyright (C) 2003
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
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
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have receied a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 #ifndef LATTICES_PIXELCURVE1D_H
29 #define LATTICES_PIXELCURVE1D_H
30 
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
34 #include <casacore/scimath/Functionals/Function1D.h>
35 #include <casacore/casa/Arrays/Vector.h>
36 
37 namespace casacore { //# NAMESPACE CASACORE - BEGIN
38 
39 //# Forward Declarations
40 
41 
42 // <summary>
43 // Arbitrary 1-dim curve in a lattice plane.
44 // </summary>
45 
46 // <use visibility=export>
47 
48 // <reviewed reviewer="" date="" tests="tPixelCurve1D.cc">
49 // </reviewed>
50 
51 // <prerequisite>
52 //# Classes you should understand before using this one.
53 // <li> <linkto class=Function1D>Function1D</linkto>
54 // <li> <linkto class=CurvedLattice2D>CurvedLattice2D</linkto>
55 // </prerequisite>
56 
57 // <synopsis>
58 // PixelCurve1D represents a 1-dim curve in a lattice plane to be
59 // used by CurvedLattice2D.
60 // The curve can be any function supported in the
61 // <linkto module=Functionals>Functionals</linkto> module.
62 // <br>A special constructor exists to define a straight line.
63 // <br>Another special constructor exists for a polyline.
64 //
65 // The domain for which the curve is valid is given by the interval
66 // [x1,x2]. The granularity of the domain is given by the number of
67 // points. The number of points also define the length of the new axis
68 // in the CurvedLattice2D object.
69 // </synopsis>
70 
71 // <example>
72 // <srcblock>
73 // // Use function y=cos(2*pi*x) on the interval [0,2] with 5 points.
74 // Sinusoid1D<float> fn;
75 // PixelCurve1D pcurve2(fn, 0., 2., 5);
76 // AlwaysAssertExit (pcurve2.npoints() == 5);
77 // pcurve2.getPixelCoord (x, y, 0, 4);
78 // cout << x << y << endl;
79 // </srcblock>
80 // The result of x is [0, 0.5, 1, 1.5, 2].
81 // The result of y is [1, -1, 1, -1, 1]
82 // </example>
83 
84 // <motivation>
85 // The viewer must be able to show a crosscut through an image using
86 // an arbitrary curve.
87 // </motivation>
88 
89 // <todo asof=2003/10/23>
90 // <li> Maybe it is better to make itsNpoints part of CurvedLattice
91 // <li> If itsNpoint is still part of this class, it is possible to
92 // precompute all possible Y values in the constructors. This may
93 // speed things up for the polyline case.
94 // </todo>
95 
97 {
98 public:
99  // Define a straight line from (x1,y1) to (x2,y2).
100  // The default number of points is the length of the line.
101  explicit PixelCurve1D (double x1=0, double y1=0, double x2=1, double y2=1,
102  uInt npoints=0);
103 
104  // Define a curve with an arbitrary function from x1 to x2.
105  // The default number of points is the length of the curve.
106  // The length of the curve is determined numerically by integration
107  // of sqrt(1+sqr(df/dx)).
109  float x1, float x2, uInt npoints=0);
110 
111  // Define a curve from a polyline with the given points.
112  // Both vectors have to be equally long and at least 2 long.
113  // The argument <src>npoints</src> defines the number of points
114  // (with regular steps) in which the curve is divided.
115  // The default is the length of the polyline.
116  PixelCurve1D (const Vector<Int>& x, const Vector<Int>& y,
117  uInt npoints=0);
119  uInt npoints=0);
121  uInt npoints=0);
122 
123  PixelCurve1D (const PixelCurve1D& that);
124 
126 
128 
129  uInt npoints() const
130  { return itsNpoints; }
131 
132  // Get the pixel coordinates in the original lattice for point start
133  // till end with given step.
135  uInt start, uInt end, uInt incr=1) const;
136 
137 private:
138  // Initialize the object.
139  void init (const Vector<double>& x, const Vector<double>& y, uInt npoints);
140 
144 };
145 
146 
147 
148 } //# NAMESPACE CASACORE - END
149 
150 #endif
PixelCurve1D(double x1=0, double y1=0, double x2=1, double y2=1, uInt npoints=0)
Define a straight line from (x1,y1) to (x2,y2).
PixelCurve1D(const Vector< double > &x, const Vector< double > &y, uInt npoints=0)
Vector< double > itsY
Definition: PixelCurve1D.h:143
PixelCurve1D(const Vector< Int > &x, const Vector< Int > &y, uInt npoints=0)
Define a curve from a polyline with the given points.
PixelCurve1D(const Vector< float > &x, const Vector< float > &y, uInt npoints=0)
PixelCurve1D(const Function1D< float, float > &, float x1, float x2, uInt npoints=0)
Define a curve with an arbitrary function from x1 to x2.
PixelCurve1D & operator=(const PixelCurve1D &that)
void init(const Vector< double > &x, const Vector< double > &y, uInt npoints)
Initialize the object.
Vector< double > itsX
Definition: PixelCurve1D.h:142
void getPixelCoord(Vector< float > &x, Vector< float > &y, uInt start, uInt end, uInt incr=1) const
Get the pixel coordinates in the original lattice for point start till end with given step.
PixelCurve1D(const PixelCurve1D &that)
this file contains all the compiler specific defines
Definition: mainpage.dox:28
unsigned int uInt
Definition: aipstype.h:51