18 #ifndef __itkPhasedArray3DSpecialCoordinatesImage_h
19 #define __itkPhasedArray3DSpecialCoordinatesImage_h
23 #include "vnl/vnl_math.h"
92 template<
class TPixel >
138 itkStaticConstMacro(ImageDimension,
unsigned int, 3);
181 template<
class TCoordRep >
182 bool TransformPhysicalPointToContinuousIndex(
186 RegionType region = this->GetLargestPossibleRegion();
187 double maxAzimuth = region.
GetSize(0) - 1;
188 double maxElevation = region.
GetSize(1) - 1;
191 TCoordRep azimuth = vcl_atan(point[0] / point[2]);
192 TCoordRep elevation = vcl_atan(point[1] / point[2]);
193 TCoordRep radius = vcl_sqrt(point[0] * point[0]
194 + point[1] * point[1]
195 + point[2] * point[2]);
198 index[0] =
static_cast< TCoordRep
>( ( azimuth / m_AzimuthAngularSeparation )
199 + ( maxAzimuth / 2.0 ) );
200 index[1] =
static_cast< TCoordRep
>( ( elevation / m_ElevationAngularSeparation )
201 + ( maxElevation / 2.0 ) );
202 index[2] =
static_cast< TCoordRep
>( ( ( radius - m_FirstSampleDistance )
203 / m_RadiusSampleSize ) );
206 const bool isInside = region.
IsInside(index);
215 template<
class TCoordRep >
216 bool TransformPhysicalPointToIndex(
220 RegionType region = this->GetLargestPossibleRegion();
221 double maxAzimuth = region.
GetSize(0) - 1;
222 double maxElevation = region.
GetSize(1) - 1;
226 TCoordRep azimuth = vcl_atan(point[0] / point[2]);
227 TCoordRep elevation = vcl_atan(point[1] / point[2]);
228 TCoordRep radius = vcl_sqrt(point[0] * point[0]
229 + point[1] * point[1]
230 + point[2] * point[2]);
234 ( azimuth / m_AzimuthAngularSeparation )
235 + ( maxAzimuth / 2.0 ) );
237 ( elevation / m_ElevationAngularSeparation )
238 + ( maxElevation / 2.0 ) );
240 ( ( radius - m_FirstSampleDistance )
241 / m_RadiusSampleSize ) );
244 const bool isInside = region.
IsInside(index);
253 template<
class TCoordRep >
254 void TransformContinuousIndexToPhysicalPoint(
258 RegionType region = this->GetLargestPossibleRegion();
259 double maxAzimuth = region.
GetSize(0) - 1;
260 double maxElevation = region.
GetSize(1) - 1;
264 TCoordRep azimuth = ( index[0] - ( maxAzimuth / 2.0 ) )
265 * m_AzimuthAngularSeparation;
266 TCoordRep elevation = ( index[1] - ( maxElevation / 2.0 ) )
267 * m_ElevationAngularSeparation;
268 TCoordRep radius = ( index[2] * m_RadiusSampleSize ) + m_FirstSampleDistance;
271 TCoordRep tanOfAzimuth = vcl_tan(azimuth);
272 TCoordRep tanOfElevation = vcl_tan(elevation);
274 point[2] =
static_cast< TCoordRep
>( radius
276 + tanOfAzimuth * tanOfAzimuth
277 + tanOfElevation * tanOfElevation) );
278 point[1] =
static_cast< TCoordRep
>( point[2] * tanOfElevation );
279 point[0] =
static_cast< TCoordRep
>( point[2] * tanOfAzimuth );
287 template<
class TCoordRep >
288 void TransformIndexToPhysicalPoint(
292 RegionType region = this->GetLargestPossibleRegion();
293 double maxAzimuth = region.
GetSize(0) - 1;
294 double maxElevation = region.
GetSize(1) - 1;
299 (
static_cast< double >( index[0] ) - ( maxAzimuth / 2.0 ) )
300 * m_AzimuthAngularSeparation;
301 TCoordRep elevation =
302 (
static_cast< double >( index[1] ) - ( maxElevation / 2.0 ) )
303 * m_ElevationAngularSeparation;
305 (
static_cast< double >( index[2] ) * m_RadiusSampleSize )
306 + m_FirstSampleDistance;
309 TCoordRep tanOfAzimuth = vcl_tan(azimuth);
310 TCoordRep tanOfElevation = vcl_tan(elevation);
312 point[2] =
static_cast< TCoordRep
>(
314 1.0 + tanOfAzimuth * tanOfAzimuth + tanOfElevation * tanOfElevation) );
315 point[1] =
static_cast< TCoordRep
>( point[2] * tanOfElevation );
316 point[0] =
static_cast< TCoordRep
>( point[2] * tanOfAzimuth );
320 itkSetMacro(AzimuthAngularSeparation,
double);
323 itkSetMacro(ElevationAngularSeparation,
double);
326 itkSetMacro(RadiusSampleSize,
double);
329 itkSetMacro(FirstSampleDistance,
double);
331 template<
class TCoordRep >
332 void TransformLocalVectorToPhysicalVector(
336 template<
class TCoordRep >
337 void TransformPhysicalVectorToLocalVector(
345 m_RadiusSampleSize = 1;
346 m_AzimuthAngularSeparation = 1 * ( 2.0 *
vnl_math::pi / 360.0 );
348 m_ElevationAngularSeparation = 1 * ( 2.0 *
vnl_math::pi / 360.0 );
350 m_FirstSampleDistance = 0;
354 void PrintSelf(std::ostream & os,
Indent indent)
const;
359 void operator=(
const Self &);
370 #define ITK_TEMPLATE_PhasedArray3DSpecialCoordinatesImage(_, EXPORT, TypeX, TypeY) \
373 _( 1 ( class EXPORT PhasedArray3DSpecialCoordinatesImage< ITK_TEMPLATE_1 TypeX > ) ) \
374 namespace Templates \
376 typedef PhasedArray3DSpecialCoordinatesImage< ITK_TEMPLATE_1 TypeX > \
377 PhasedArray3DSpecialCoordinatesImage##TypeY; \
381 #if ITK_TEMPLATE_EXPLICIT
382 #include "Templates/itkPhasedArray3DSpecialCoordinatesImage+-.h"
386 #include "itkPhasedArray3DSpecialCoordinatesImage.hxx"