| 1 |
|
/*========================================================================= |
| 2 |
|
|
| 3 |
|
Program: Insight Segmentation & Registration Toolkit |
| 4 |
|
Module: $RCSfile: itkAzimuthElevationToCartesianTransform.h.html,v $ |
| 5 |
|
Language: C++ |
| 6 |
|
Date: $Date: 2006/01/17 19:15:33 $ |
| 7 |
|
Version: $Revision: 1.4 $ |
| 8 |
|
|
| 9 |
|
Copyright (c) Insight Software Consortium. All rights reserved. |
| 10 |
|
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. |
| 11 |
|
|
| 12 |
|
This software is distributed WITHOUT ANY WARRANTY; without even |
| 13 |
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 14 |
|
PURPOSE. See the above copyright notices for more information. |
| 15 |
|
|
| 16 |
|
=========================================================================*/ |
| 17 |
|
|
| 18 |
|
#ifndef __itkAzimuthElevationToCartesianTransform_h |
| 19 |
|
#define __itkAzimuthElevationToCartesianTransform_h |
| 20 |
|
|
| 21 |
|
#include "itkAffineTransform.h" |
| 22 |
|
#include "vnl/vnl_math.h" |
| 23 |
|
|
| 24 |
|
namespace itk |
| 25 |
|
{ |
| 26 |
|
|
| 27 |
|
/** \class AzimuthElevationToCartesianTransform |
| 28 |
|
* \brief Transforms from an azimuth, elevation, radius coordinate system to |
| 29 |
|
* a Cartesian coordinate system, or vice versa. |
| 30 |
|
* |
| 31 |
|
* The three coordinate axis are azimuth, elevation, and range. |
| 32 |
|
* |
| 33 |
|
* The azimuth elevation coordinate system is defined similarly to spherical |
| 34 |
|
* coordinates but is slightly different in that the azimuth and elevation are |
| 35 |
|
* measured in degrees between the r-axis (i.e z axis) and the projection on |
| 36 |
|
* the x-z and y-z planes, respectively. Range, or r, is the distance from |
| 37 |
|
* the origin. |
| 38 |
|
* |
| 39 |
|
* The equations form performing the conversion from azimuth-elevation |
| 40 |
|
* coordinates to cartesian coordinates are as follows: |
| 41 |
|
* z = sqrt((r^2*(cos(azimuth))^2)/(1 + (cos(azimuth))^2 * (tan(elevation))^2); |
| 42 |
|
* x = z * tan(azimuth) |
| 43 |
|
* y = z * tan(elevation) |
| 44 |
|
* |
| 45 |
|
* The reversed transforms are: |
| 46 |
|
* azimuth = arctan(x/y) |
| 47 |
|
* elevation = arctan(y/z) |
| 48 |
|
* r = sqrt(x^2 + y^2 + z^2) |
| 49 |
|
* |
| 50 |
|
* In this class, we can also set what a "forward" transform means. If we call |
| 51 |
|
* SetForwardAzimuthElevationToCartesian(), a forward transform will return |
| 52 |
|
* cartesian coordinates when passed azimuth,elevation,r coordinates. Calling |
| 53 |
|
* SetForwardCartesianToAzimuthElevation() will cause the forward transform |
| 54 |
|
* to return azimuth,elevation,r coordinates from cartesian coordinates. |
| 55 |
|
* |
| 56 |
|
* Setting the FirstSampleDistance to a non-zero value means that a r value |
| 57 |
|
* of 12 is actually (12 + FirstSampleDistance) distance from the origin. |
| 58 |
|
* |
| 59 |
|
* There are two template parameters for this class: |
| 60 |
|
* |
| 61 |
|
* ScalarT The type to be used for scalar numeric values. Either |
| 62 |
|
* float or double. |
| 63 |
|
* |
| 64 |
|
* NDimensions The number of dimensions of the vector space (must be >=3). |
| 65 |
|
* |
| 66 |
|
* \ingroup Transforms |
| 67 |
|
* |
| 68 |
|
* \todo Is there any real value in allowing the user to template |
| 69 |
|
* over the scalar type? Perhaps it should always be double, unless |
| 70 |
|
* there's a compatibility problem with the Point class. |
| 71 |
|
* |
| 72 |
|
* \todo Derive this class from a yet undefined TransformBase class. |
| 73 |
|
* Currently, this class derives from AffineTransform, although |
| 74 |
|
* it is not an affine transform. |
| 75 |
|
**/ |
| 76 |
LEN,IND |
*template < class TScalarType=float, // Data type for scalars (e.g. float or double) |
| 77 |
|
unsigned int NDimensions=3 > |
| 78 |
|
class ITK_EXPORT AzimuthElevationToCartesianTransform : |
| 79 |
IND |
****************************public AffineTransform< TScalarType, NDimensions > |
| 80 |
|
{ |
| 81 |
|
public: |
| 82 |
|
/** Standard class typedefs. */ |
| 83 |
|
typedef AzimuthElevationToCartesianTransform Self; |
| 84 |
TDA |
typedef AffineTransform< TScalarType, NDimensions > Superclass; |
| 85 |
TDA |
typedef SmartPointer<Self> Pointer; |
| 86 |
TDA |
typedef SmartPointer<const Self> ConstPointer; |
| 87 |
|
|
| 88 |
|
/** Dimension of the domain space. */ |
| 89 |
|
itkStaticConstMacro(SpaceDimension, unsigned int, NDimensions); |
| 90 |
|
itkStaticConstMacro(ParametersDimension, unsigned int, |
| 91 |
|
NDimensions * (NDimensions+1) ); |
| 92 |
|
|
| 93 |
|
/** Run-time type information (and related methods). */ |
| 94 |
|
itkTypeMacro( AzimuthElevationToCartesianTransform, AffineTransform); |
| 95 |
|
|
| 96 |
|
/** New macro for creation of through a Smart Pointer. */ |
| 97 |
|
itkNewMacro( Self ); |
| 98 |
|
|
| 99 |
|
/** Parameters type. */ |
| 100 |
|
typedef typename Superclass::ParametersType ParametersType; |
| 101 |
|
|
| 102 |
|
/** Jacobian type. */ |
| 103 |
|
typedef typename Superclass::JacobianType JacobianType; |
| 104 |
|
|
| 105 |
|
/** Standard scalar type for this class. */ |
| 106 |
|
typedef typename Superclass::ScalarType ScalarType; |
| 107 |
|
|
| 108 |
|
/** Standard coordinate point type for this class */ |
| 109 |
|
typedef typename Superclass::InputPointType InputPointType; |
| 110 |
|
typedef typename Superclass::OutputPointType OutputPointType; |
| 111 |
|
|
| 112 |
|
/** Standard matrix type for this class. */ |
| 113 |
|
typedef Matrix<TScalarType, itkGetStaticConstMacro(SpaceDimension), |
| 114 |
|
itkGetStaticConstMacro(SpaceDimension)> MatrixType; |
| 115 |
|
|
| 116 |
|
/** Set the transformation parameters. **/ |
| 117 |
|
void SetAzimuthElevationToCartesianParameters( const double sampleSize, |
| 118 |
|
const double blanking, |
| 119 |
|
const long maxAzimuth, |
| 120 |
|
const long maxElevation, |
| 121 |
LEN |
const double azimuthAngleSeparation, |
| 122 |
LEN |
const double elevationAngleSeparation); |
| 123 |
|
|
| 124 |
|
void SetAzimuthElevationToCartesianParameters( const double sampleSize, |
| 125 |
|
const double blanking, |
| 126 |
|
const long maxAzimuth, |
| 127 |
|
const long maxElevation); |
| 128 |
|
|
| 129 |
|
/** Transform from azimuth-elevation to cartesian. **/ |
| 130 |
|
OutputPointType TransformPoint (const InputPointType &point ) const; |
| 131 |
|
|
| 132 |
|
/** Back transform from cartesian to azimuth-elevation. **/ |
| 133 |
LEN |
inline InputPointType BackTransform(const OutputPointType &point ) const; |
| 134 |
|
InputPointType BackTransformPoint(const OutputPointType &point) const; |
| 135 |
|
|
| 136 |
LEN |
/** Defines that the forward transform goes from azimuth,elevation to cartesian. **/ |
| 137 |
|
void SetForwardAzimuthElevationToCartesian(); |
| 138 |
|
|
| 139 |
LEN |
/** Defines that the forward transform goes from cartesian to azimuth,elevation. **/ |
| 140 |
|
void SetForwardCartesianToAzimuthElevation(); |
| 141 |
|
|
| 142 |
LEN |
/** Perform conversion from Azimuth Elevation coordinates to Cartesian Coordinates. **/ |
| 143 |
|
OutputPointType TransformAzElToCartesian(const InputPointType &point) const; |
| 144 |
|
|
| 145 |
LEN |
/** Perform conversion from Cartesian Coordinates to Azimuth Elevation coordinates. **/ |
| 146 |
|
OutputPointType TransformCartesianToAzEl(const OutputPointType &point) const; |
| 147 |
|
|
| 148 |
|
/** Set the maximum azimuth. |
| 149 |
|
* The maximum azimuth and elevation can be set so that the resulting |
| 150 |
|
* cartesian space is symmetric about the z axis. Therefore, the line |
| 151 |
|
* defined by azimuth/2,elevation/2 = z-axis. **/ |
| 152 |
|
itkSetMacro(MaxAzimuth, long); |
| 153 |
|
|
| 154 |
|
/** Set the maximum elevation |
| 155 |
|
* The maximum azimuth and elevation can be set so that the resulting |
| 156 |
|
* cartesian space is symmetric about the z axis. Therefore, the line |
| 157 |
|
* defined by azimuth/2,elevation/2 = z-axis. **/ |
| 158 |
|
itkSetMacro(MaxElevation, long); |
| 159 |
|
|
| 160 |
|
/** Set the number of cartesian units between each unit along the R . **/ |
| 161 |
|
itkSetMacro(RadiusSampleSize, double); |
| 162 |
|
|
| 163 |
|
/** Set the number of degrees between each azimuth unit. **/ |
| 164 |
|
itkSetMacro(AzimuthAngularSeparation, double); |
| 165 |
|
|
| 166 |
|
/** Set the number of degrees between each elevation unit. **/ |
| 167 |
|
itkSetMacro(ElevationAngularSeparation, double); |
| 168 |
|
|
| 169 |
|
/** Set the distance to add to the radius. */ |
| 170 |
|
itkSetMacro(FirstSampleDistance, double); |
| 171 |
|
|
| 172 |
|
protected: |
| 173 |
|
/** Create an AzimuthElevationToCartesianTransform object. **/ |
| 174 |
|
AzimuthElevationToCartesianTransform(); |
| 175 |
|
|
| 176 |
|
/** Destroy an AzimuthElevationToCartesianTransform object. **/ |
| 177 |
|
virtual ~AzimuthElevationToCartesianTransform(); |
| 178 |
|
|
| 179 |
|
/** Print contents of an AzimuthElevationTransform. **/ |
| 180 |
|
void PrintSelf(std::ostream &s, Indent indent) const; |
| 181 |
|
|
| 182 |
|
private: |
| 183 |
|
AzimuthElevationToCartesianTransform(const Self&); //purposely not implemented |
| 184 |
|
void operator=(const Self&); //purposely not implemented |
| 185 |
|
|
| 186 |
|
long m_MaxAzimuth; |
| 187 |
|
long m_MaxElevation; |
| 188 |
|
double m_RadiusSampleSize; |
| 189 |
|
double m_AzimuthAngularSeparation; |
| 190 |
|
double m_ElevationAngularSeparation; |
| 191 |
|
double m_FirstSampleDistance; |
| 192 |
|
bool m_ForwardAzimuthElevationToPhysical; |
| 193 |
|
|
| 194 |
|
}; //class AzimuthElevationToCartesianTransform |
| 195 |
|
|
| 196 |
|
|
| 197 |
|
} // namespace itk |
| 198 |
|
|
| 199 |
|
|
| 200 |
|
#ifndef ITK_MANUAL_INSTANTIATION |
| 201 |
|
#include "itkAzimuthElevationToCartesianTransform.txx" |
| 202 |
|
#endif |
| 203 |
|
|
| 204 |
|
#endif /* __itkAzimuthElevationToCartesianTransform_h */ |
| 205 |
|
|
| 206 |
EOF |
|
| 207 |
EOF,EML |
|