casacore
Loading...
Searching...
No Matches
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: casa-feedback@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#ifndef LATTICES_PIXELCURVE1D_H
27#define LATTICES_PIXELCURVE1D_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/scimath/Functionals/Function1D.h>
32#include <casacore/casa/Arrays/Vector.h>
33
34namespace casacore { // # NAMESPACE CASACORE - BEGIN
35
36// # Forward Declarations
37
38// <summary>
39// Arbitrary 1-dim curve in a lattice plane.
40// </summary>
41
42// <use visibility=export>
43
44// <reviewed reviewer="" date="" tests="tPixelCurve1D.cc">
45// </reviewed>
46
47// <prerequisite>
48// # Classes you should understand before using this one.
49// <li> <linkto class=Function1D>Function1D</linkto>
50// <li> <linkto class=CurvedLattice2D>CurvedLattice2D</linkto>
51// </prerequisite>
52
53// <synopsis>
54// PixelCurve1D represents a 1-dim curve in a lattice plane to be
55// used by CurvedLattice2D.
56// The curve can be any function supported in the
57// <linkto module=Functionals>Functionals</linkto> module.
58// <br>A special constructor exists to define a straight line.
59// <br>Another special constructor exists for a polyline.
60//
61// The domain for which the curve is valid is given by the interval
62// [x1,x2]. The granularity of the domain is given by the number of
63// points. The number of points also define the length of the new axis
64// in the CurvedLattice2D object.
65// </synopsis>
66
67// <example>
68// <srcblock>
69// // Use function y=cos(2*pi*x) on the interval [0,2] with 5 points.
70// Sinusoid1D<float> fn;
71// PixelCurve1D pcurve2(fn, 0., 2., 5);
72// AlwaysAssertExit (pcurve2.npoints() == 5);
73// pcurve2.getPixelCoord (x, y, 0, 4);
74// cout << x << y << endl;
75// </srcblock>
76// The result of x is [0, 0.5, 1, 1.5, 2].
77// The result of y is [1, -1, 1, -1, 1]
78// </example>
79
80// <motivation>
81// The viewer must be able to show a crosscut through an image using
82// an arbitrary curve.
83// </motivation>
84
85// <todo asof=2003/10/23>
86// <li> Maybe it is better to make itsNpoints part of CurvedLattice
87// <li> If itsNpoint is still part of this class, it is possible to
88// precompute all possible Y values in the constructors. This may
89// speed things up for the polyline case.
90// </todo>
91
93 public:
94 // Define a straight line from (x1,y1) to (x2,y2).
95 // The default number of points is the length of the line.
96 explicit PixelCurve1D(double x1 = 0, double y1 = 0, double x2 = 1, double y2 = 1,
97 uInt npoints = 0);
98
99 // Define a curve with an arbitrary function from x1 to x2.
100 // The default number of points is the length of the curve.
101 // The length of the curve is determined numerically by integration
102 // of sqrt(1+sqr(df/dx)).
103 PixelCurve1D(const Function1D<float, float>&, float x1, float x2, uInt npoints = 0);
104
105 // Define a curve from a polyline with the given points.
106 // Both vectors have to be equally long and at least 2 long.
107 // The argument <src>npoints</src> defines the number of points
108 // (with regular steps) in which the curve is divided.
109 // The default is the length of the polyline.
113
115
117
119
120 uInt npoints() const { return itsNpoints; }
121
122 // Get the pixel coordinates in the original lattice for point start
123 // till end with given step.
124 void getPixelCoord(Vector<float>& x, Vector<float>& y, uInt start, uInt end, uInt incr = 1) const;
125
126 private:
127 // Initialize the object.
128 void init(const Vector<double>& x, const Vector<double>& y, uInt npoints);
129
133};
134
135} // namespace casacore
136
137#endif
PixelCurve1D & operator=(const PixelCurve1D &that)
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
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.
void init(const Vector< double > &x, const Vector< double > &y, uInt npoints)
Initialize the object.
Vector< double > itsX
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)
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
iterator end()
Definition Block.h:601