casa
$Rev:20696$
|
00001 //# PixelCurve1D.h: Arbitrary 1-dim curve in a lattice plane 00002 //# Copyright (C) 2003 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU Library General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library is distributed in the hope that it will be useful, but WITHOUT 00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 //# License for more details. 00014 //# 00015 //# You should have receied a copy of the GNU Library General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be addressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 //# $Id: PixelCurve1D.h 18093 2004-11-30 17:51:10Z ddebonis $ 00027 00028 #ifndef LATTICES_PIXELCURVE1D_H 00029 #define LATTICES_PIXELCURVE1D_H 00030 00031 00032 //# Includes 00033 #include <scimath/Functionals/Function1D.h> 00034 #include <casa/Arrays/Vector.h> 00035 00036 namespace casa { //# NAMESPACE CASA - BEGIN 00037 00038 //# Forward Declarations 00039 00040 00041 // <summary> 00042 // Arbitrary 1-dim curve in a lattice plane. 00043 // </summary> 00044 00045 // <use visibility=export> 00046 00047 // <reviewed reviewer="" date="" tests="tPixelCurve1D.cc"> 00048 // </reviewed> 00049 00050 // <prerequisite> 00051 //# Classes you should understand before using this one. 00052 // <li> <linkto class=Function1D>Function1D</linkto> 00053 // <li> <linkto class=CurvedLattice2D>CurvedLattice2D</linkto> 00054 // </prerequisite> 00055 00056 // <synopsis> 00057 // PixelCurve1D represents a 1-dim curve in a lattice plane to be 00058 // used by CurvedLattice2D. 00059 // The curve can be any function supported in the 00060 // <linkto module=Functionals>Functionals</linkto> module. 00061 // <br>A special constructor exists to define a straight line. 00062 // <br>Another special constructor exists for a polyline. 00063 // 00064 // The domain for which the curve is valid is given by the interval 00065 // [x1,x2]. The granularity of the domain is given by the number of 00066 // points. The number of points also define the length of the new axis 00067 // in the CurvedLattice2D object. 00068 // </synopsis> 00069 00070 // <example> 00071 // <srcblock> 00072 // // Use function y=cos(2*pi*x) on the interval [0,2] with 5 points. 00073 // Sinusoid1D<float> fn; 00074 // PixelCurve1D pcurve2(fn, 0., 2., 5); 00075 // AlwaysAssertExit (pcurve2.npoints() == 5); 00076 // pcurve2.getPixelCoord (x, y, 0, 4); 00077 // cout << x << y << endl; 00078 // </srcblock> 00079 // The result of x is [0, 0.5, 1, 1.5, 2]. 00080 // The result of y is [1, -1, 1, -1, 1] 00081 // </example> 00082 00083 // <motivation> 00084 // The viewer must be able to show a crosscut through an image using 00085 // an arbitrary curve. 00086 // </motivation> 00087 00088 // <todo asof=2003/10/23> 00089 // <li> Maybe it is better to make itsNpoints part of CurvedLattice 00090 // <li> If itsNpoint is still part of this class, it is possible to 00091 // precompute all possible Y values in the constructors. This may 00092 // speed things up for the polyline case. 00093 // </todo> 00094 00095 class PixelCurve1D 00096 { 00097 public: 00098 // Define a straight line from (x1,y1) to (x2,y2). 00099 // The default number of points is the length of the line. 00100 explicit PixelCurve1D (double x1=0, double y1=0, double x2=1, double y2=1, 00101 uInt npoints=0); 00102 00103 // Define a curve with an arbitrary function from x1 to x2. 00104 // The default number of points is the length of the curve. 00105 // The length of the curve is determined numerically by integration 00106 // of sqrt(1+sqr(df/dx)). 00107 PixelCurve1D (const Function1D<float,float>&, 00108 float x1, float x2, uInt npoints=0); 00109 00110 // Define a curve from a polyline with the given points. 00111 // Both vectors have to be equally long and at least 2 long. 00112 // The argument <src>npoints</src> defines the number of points 00113 // (with regular steps) in which the curve is divided. 00114 // The default is the length of the polyline. 00115 PixelCurve1D (const Vector<Int>& x, const Vector<Int>& y, 00116 uInt npoints=0); 00117 PixelCurve1D (const Vector<float>& x, const Vector<float>& y, 00118 uInt npoints=0); 00119 PixelCurve1D (const Vector<double>& x, const Vector<double>& y, 00120 uInt npoints=0); 00121 00122 PixelCurve1D (const PixelCurve1D& that); 00123 00124 ~PixelCurve1D(); 00125 00126 PixelCurve1D& operator= (const PixelCurve1D& that); 00127 00128 uInt npoints() const 00129 { return itsNpoints; } 00130 00131 // Get the pixel coordinates in the original lattice for point start 00132 // till end with given step. 00133 void getPixelCoord (Vector<float>& x, Vector<float>& y, 00134 uInt start, uInt end, uInt incr=1) const; 00135 00136 private: 00137 // Initialize the object. 00138 void init (const Vector<double>& x, const Vector<double>& y, uInt npoints); 00139 00140 uInt itsNpoints; 00141 Vector<double> itsX; 00142 Vector<double> itsY; 00143 }; 00144 00145 00146 00147 } //# NAMESPACE CASA - END 00148 00149 #endif