Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkCrossHelper.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkCrossHelper.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-03-27 14:51:44 $
00007   Version:   $Revision: 1.6 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 #ifndef __itkCrossHelper_h
00018 #define __itkCrossHelper_h
00019 
00020 #include "itkNumericTraits.h"
00021 
00022 namespace itk
00023 {
00033 template< typename TVector >
00034 class CrossHelper
00035 {
00036 public:
00037   typedef TVector                           VectorType;
00038   typedef typename VectorType::ValueType    ValueType;
00039 
00040   itkStaticConstMacro ( Dimension, unsigned int, VectorType::Dimension );
00041 
00047   VectorType operator ( ) ( const VectorType& iU,
00048                             const VectorType& iV ) const
00049     {
00050     VectorType oCross;
00051 
00052     if( Dimension > 2 )
00053       {
00054       oCross[0] = iU[1] * iV[2] - iV[1] * iU[2];
00055       oCross[1] = iV[0] * iU[2] - iU[0] * iV[2];
00056       oCross[2] = iU[0] * iV[1] - iV[0] * iU[1];
00057 
00058       for( unsigned int dim = 3; dim < Dimension; dim++ )
00059         {
00060         oCross[dim] = 0.0;
00061         }
00062       }
00063     else
00064       {
00065       oCross.Fill( 0. );
00066       }
00067 
00068     return oCross;
00069     }
00070 };
00071 }
00072 
00073 #endif
00074 

Generated at Fri Apr 16 18:11:29 2010 for ITK by doxygen 1.6.1 written by Dimitri van Heesch, © 1997-2000