Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members

mitkVis2Vector4.h

00001 /*=========================================================================
00002 
00003   Program:   3DMed
00004   Date:      $Date: 2014-02-25 18:30:00 +0800 $
00005   Version:   $Version: 4.6.0 $
00006   Copyright: MIPG, Institute of Automation, Chinese Academy of Sciences
00007 
00008 =========================================================================*/
00009 
00010 #ifndef _mitkVis2Vector4_h
00011 #define _mitkVis2Vector4_h
00012 
00013 #include "mitkVisualization2Includes.h"
00014 
00015 #include <math.h>
00016 
00017 class MITK_VISUALIZATION2_API mitkVis2Vector4
00018 {
00019 public:
00020     float ele[4];
00021     mitkVis2Vector4();  
00022     mitkVis2Vector4(const mitkVis2Vector4 &v);
00023     mitkVis2Vector4(float x, float y, float z, float w = 1.0f);
00024     mitkVis2Vector4(float srcVector[4]);
00025     operator float* () { return ele; }  
00026     operator const float* () const { return ele; }
00027 
00028     mitkVis2Vector4& operator = (const mitkVis2Vector4 &a)
00029     {
00030         ele[0] = a.ele[0];
00031         ele[1] = a.ele[1];
00032         ele[2] = a.ele[2];
00033         ele[3] = a.ele[3];
00034         return *this; 
00035     }
00036     mitkVis2Vector4& operator *= (float);
00037     mitkVis2Vector4& operator += (const mitkVis2Vector4 &);
00038     mitkVis2Vector4& operator -= (const mitkVis2Vector4 &);
00039 
00040     void Normalize();
00041     float Length();
00042 };
00043 
00044 inline float operator * (const mitkVis2Vector4& A, const mitkVis2Vector4& B) 
00045 {
00046     return A.ele[0]*B.ele[0] + A.ele[1]*B.ele[1] + A.ele[2]*B.ele[2];
00047 }
00048 //----------------------------------------------------------------------------
00049 inline mitkVis2Vector4 operator % (const mitkVis2Vector4& A, const mitkVis2Vector4& B) 
00050 {
00051     mitkVis2Vector4 Res;
00052     Res.ele[0] = A.ele[1] * B.ele[2] - A.ele[2] * B.ele[1]; 
00053     Res.ele[1] = A.ele[2] * B.ele[0] - A.ele[0] * B.ele[2]; 
00054     Res.ele[2] = A.ele[0] * B.ele[1] - A.ele[1] * B.ele[0]; 
00055     Res.ele[3] = 0.0f;
00056     return Res;
00057 }
00058 //----------------------------------------------------------------------------
00059 inline mitkVis2Vector4 operator * (const mitkVis2Vector4 &V, float s) 
00060 {
00061     mitkVis2Vector4 Res;
00062     Res.ele[0] = V.ele[0] * s;
00063     Res.ele[1] = V.ele[1] * s;
00064     Res.ele[2] = V.ele[2] * s;
00065     Res.ele[3] = V.ele[3] * s;  
00066     return Res;
00067 }
00068 //----------------------------------------------------------------------------
00069 inline mitkVis2Vector4 operator * (float s, const mitkVis2Vector4 &V) 
00070 {
00071     mitkVis2Vector4 Res;
00072     Res.ele[0] = V.ele[0] * s;
00073     Res.ele[1] = V.ele[1] * s;
00074     Res.ele[2] = V.ele[2] * s;
00075     Res.ele[3] = V.ele[3] * s;  
00076     return Res;
00077 }
00078 //----------------------------------------------------------------------------
00079 inline mitkVis2Vector4& mitkVis2Vector4::operator *= (float s) 
00080 {
00081     ele[0] *= s;
00082     ele[1] *= s;
00083     ele[2] *= s;
00084     ele[3] *= s;    
00085     return *this;
00086 }
00087 //----------------------------------------------------------------------------
00088 inline mitkVis2Vector4 operator + (const mitkVis2Vector4& A, const mitkVis2Vector4& B) 
00089 {
00090     mitkVis2Vector4 Res;
00091     Res.ele[0] = A.ele[0] + B.ele[0];
00092     Res.ele[1] = A.ele[1] + B.ele[1];
00093     Res.ele[2] = A.ele[2] + B.ele[2];
00094     Res.ele[3] = A.ele[3] + B.ele[3];
00095     return Res;
00096 }
00097 //----------------------------------------------------------------------------
00098 inline mitkVis2Vector4 operator - (const mitkVis2Vector4& A, const mitkVis2Vector4& B) 
00099 {
00100     mitkVis2Vector4 Res;
00101     Res.ele[0] = A.ele[0] - B.ele[0];
00102     Res.ele[1] = A.ele[1] - B.ele[1];
00103     Res.ele[2] = A.ele[2] - B.ele[2];
00104     Res.ele[3] = A.ele[3] - B.ele[3];
00105     return Res;
00106 }
00107 //----------------------------------------------------------------------------
00108 inline mitkVis2Vector4 operator - (const mitkVis2Vector4& A)
00109 {
00110     mitkVis2Vector4 Res;
00111     Res.ele[0] = - A.ele[0];
00112     Res.ele[1] = - A.ele[1];
00113     Res.ele[2] = - A.ele[2];
00114     Res.ele[3] = - A.ele[3];
00115     return Res;
00116 }
00117 //----------------------------------------------------------------------------
00118 inline mitkVis2Vector4 & mitkVis2Vector4::operator += (const mitkVis2Vector4 &B) 
00119 {
00120     ele[0] += B.ele[0];
00121     ele[1] += B.ele[1];
00122     ele[2] += B.ele[2];
00123     ele[3] += B.ele[3];
00124     return *this;
00125 }
00126 //----------------------------------------------------------------------------
00127 inline mitkVis2Vector4 & mitkVis2Vector4::operator -= (const mitkVis2Vector4 &B) 
00128 {
00129     ele[0] -= B.ele[0];
00130     ele[1] -= B.ele[1];
00131     ele[2] -= B.ele[2];
00132     ele[3] -= B.ele[3];
00133     return *this;
00134 }
00135 //----------------------------------------------------------------------------
00136 inline void mitkVis2Vector4::Normalize() 
00137 {
00138     float vecLenInv = 1.0f / sqrtf(ele[0]*ele[0] + ele[1]*ele[1] + ele[2]*ele[2]);
00139     ele[0] *= vecLenInv;
00140     ele[1] *= vecLenInv;
00141     ele[2] *= vecLenInv;
00142 }
00143 //----------------------------------------------------------------------------
00144 inline float mitkVis2Vector4::Length()
00145 {
00146     return sqrtf(ele[0]*ele[0] + ele[1]*ele[1] + ele[2]*ele[2]);
00147 }
00148 
00149 
00150 #endif

Generated on Tue Feb 25 15:00:37 2014 for MITK (Medical Imaging ToolKit) by  doxygen 1.4.3