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

mitkVis2Vector3.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 _mitkVis2Vector3_h
00011 #define _mitkVis2Vector3_h
00012 
00013 #include "mitkVisualization2Includes.h"
00014 
00015 #include <math.h>
00016 
00017 class MITK_VISUALIZATION2_API mitkVis2Vector3
00018 {
00019 public:
00020     float ele[3];
00021     mitkVis2Vector3();  
00022     mitkVis2Vector3(const mitkVis2Vector3 &v);
00023     mitkVis2Vector3(float x, float y, float z);
00024     mitkVis2Vector3(float srcVector[3]);
00025     operator float* () { return ele; }  
00026     operator const float* () const { return ele; }
00027 
00028     mitkVis2Vector3& operator = (const mitkVis2Vector3 &a)
00029     {
00030         ele[0] = a.ele[0];
00031         ele[1] = a.ele[1];
00032         ele[2] = a.ele[2];
00033         return *this; 
00034     }
00035     mitkVis2Vector3& operator *= (float);
00036     mitkVis2Vector3& operator += (const mitkVis2Vector3 &);
00037     mitkVis2Vector3& operator -= (const mitkVis2Vector3 &);
00038 
00039     void Normalize();
00040     float Length();
00041 };
00042 
00043 inline float operator * (const mitkVis2Vector3& A, const mitkVis2Vector3& B) 
00044 {
00045     return A.ele[0]*B.ele[0] + A.ele[1]*B.ele[1] + A.ele[2]*B.ele[2];
00046 }
00047 //----------------------------------------------------------------------------
00048 inline mitkVis2Vector3 operator % (const mitkVis2Vector3& A, const mitkVis2Vector3& B) 
00049 {
00050     mitkVis2Vector3 Res;
00051     Res.ele[0] = A.ele[1] * B.ele[2] - A.ele[2] * B.ele[1]; 
00052     Res.ele[1] = A.ele[2] * B.ele[0] - A.ele[0] * B.ele[2]; 
00053     Res.ele[2] = A.ele[0] * B.ele[1] - A.ele[1] * B.ele[0]; 
00054     return Res;
00055 }
00056 //----------------------------------------------------------------------------
00057 inline mitkVis2Vector3 operator * (const mitkVis2Vector3 &V, float s) 
00058 {
00059     mitkVis2Vector3 Res;
00060     Res.ele[0] = V.ele[0] * s;
00061     Res.ele[1] = V.ele[1] * s;
00062     Res.ele[2] = V.ele[2] * s;
00063     return Res;
00064 }
00065 //----------------------------------------------------------------------------
00066 inline mitkVis2Vector3 operator * (float s, const mitkVis2Vector3 &V) 
00067 {
00068     mitkVis2Vector3 Res;
00069     Res.ele[0] = V.ele[0] * s;
00070     Res.ele[1] = V.ele[1] * s;
00071     Res.ele[2] = V.ele[2] * s;
00072     return Res;
00073 }
00074 //----------------------------------------------------------------------------
00075 inline mitkVis2Vector3& mitkVis2Vector3::operator *= (float s) 
00076 {
00077     ele[0] *= s;
00078     ele[1] *= s;
00079     ele[2] *= s;
00080     return *this;
00081 }
00082 //----------------------------------------------------------------------------
00083 inline mitkVis2Vector3 operator + (const mitkVis2Vector3& A, const mitkVis2Vector3& B) 
00084 {
00085     mitkVis2Vector3 Res;
00086     Res.ele[0] = A.ele[0] + B.ele[0];
00087     Res.ele[1] = A.ele[1] + B.ele[1];
00088     Res.ele[2] = A.ele[2] + B.ele[2];
00089     return Res;
00090 }
00091 //----------------------------------------------------------------------------
00092 inline mitkVis2Vector3 operator - (const mitkVis2Vector3& A, const mitkVis2Vector3& B) 
00093 {
00094     mitkVis2Vector3 Res;
00095     Res.ele[0] = A.ele[0] - B.ele[0];
00096     Res.ele[1] = A.ele[1] - B.ele[1];
00097     Res.ele[2] = A.ele[2] - B.ele[2];
00098     return Res;
00099 }
00100 //----------------------------------------------------------------------------
00101 inline mitkVis2Vector3 operator - (const mitkVis2Vector3& A)
00102 {
00103     mitkVis2Vector3 Res;
00104     Res.ele[0] = - A.ele[0];
00105     Res.ele[1] = - A.ele[1];
00106     Res.ele[2] = - A.ele[2];
00107     return Res;
00108 }
00109 //----------------------------------------------------------------------------
00110 inline mitkVis2Vector3 & mitkVis2Vector3::operator += (const mitkVis2Vector3 &B) 
00111 {
00112     ele[0] += B.ele[0];
00113     ele[1] += B.ele[1];
00114     ele[2] += B.ele[2];
00115     return *this;
00116 }
00117 //----------------------------------------------------------------------------
00118 inline mitkVis2Vector3 & mitkVis2Vector3::operator -= (const mitkVis2Vector3 &B) 
00119 {
00120     ele[0] -= B.ele[0];
00121     ele[1] -= B.ele[1];
00122     ele[2] -= B.ele[2];
00123     return *this;
00124 }
00125 //----------------------------------------------------------------------------
00126 inline void mitkVis2Vector3::Normalize() 
00127 {
00128     float vecLenInv = 1.0f / sqrtf(ele[0]*ele[0] + ele[1]*ele[1] + ele[2]*ele[2]);
00129     ele[0] *= vecLenInv;
00130     ele[1] *= vecLenInv;
00131     ele[2] *= vecLenInv;
00132 }
00133 //----------------------------------------------------------------------------
00134 inline float mitkVis2Vector3::Length()
00135 {
00136     return sqrtf(ele[0]*ele[0] + ele[1]*ele[1] + ele[2]*ele[2]);
00137 }
00138 
00139 
00140 #endif

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