00001 #ifndef Impala_Core_Array_Trait_M9N4poFSph_h
00002 #define Impala_Core_Array_Trait_M9N4poFSph_h
00003
00004 #include "Core/Array/Pattern/Categories.h"
00005 #include "Core/Array/Element/E1Sqrt.h"
00006
00007 namespace Impala
00008 {
00009 namespace Core
00010 {
00011 namespace Array
00012 {
00013 namespace Trait
00014 {
00015
00016
00020 template<class DstArrayT, class SrcArrayT>
00021 class M9N4poFSph
00022 {
00023 public:
00025 typedef Pattern::TagTransInVar TransVarianceCategory;
00026
00028 typedef Pattern::TagCallValue CallCategory;
00029
00030 typedef typename DstArrayT::StorType DstStorT;
00031 typedef typename DstArrayT::ArithType DstArithT;
00032 typedef typename SrcArrayT::ArithType SrcArithT;
00033
00035 M9N4poFSph()
00036 {
00037 }
00038
00040 void
00041 DoIt(DstStorT* FThetax, DstStorT* FThetay, DstStorT* FPhix, DstStorT* FPhiy,
00042 const SrcArithT& R, const SrcArithT& G, const SrcArithT& B,
00043 const SrcArithT& Rx, const SrcArithT& Gx, const SrcArithT& Bx,
00044 const SrcArithT& Ry, const SrcArithT& Gy, const SrcArithT& By)
00045 {
00046 SrcArithT I1 = Element::E1Sqrt(R*R + G*G + B*B);
00047 SrcArithT I2 = Element::E1Sqrt(R*R + G*G);
00048 SrcArithT I1I2 = I1*I2;
00049
00050 *FThetax = (I2 > 0) ? (R*Gx - G*Rx) / I2 : I2;
00051 *FThetay = (I2 > 0) ? (R*Gy - G*Ry) / I2 : I2;
00052 *FPhix = (I1I2 > 0) ? (G*(B*Gx - G*Bx) + R*(B*Rx - R*Bx)) / (I1I2) : 0;
00053 *FPhiy = (I1I2 > 0) ? (G*(B*Gy - G*By) + R*(B*Ry - R*By)) / (I1I2) : 0;
00054 }
00055 };
00056
00057 }
00058 }
00059 }
00060 }
00061
00062 #endif