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