NifTK  16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
niftkBasicVec3D.h
Go to the documentation of this file.
1 /*=============================================================================
2 
3  NifTK: A software platform for medical image computing.
4 
5  Copyright (c) University College London (UCL). All rights reserved.
6 
7  This software is distributed WITHOUT ANY WARRANTY; without even
8  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
9  PURPOSE.
10 
11  See LICENSE.txt in the top level directory for details.
12 
13 =============================================================================*/
14 
15 #ifndef niftkBasicVec3D_h
16 #define niftkBasicVec3D_h
17 
18 #include <math.h>
19 #include <iostream>
20 
21 #include "niftkCoreExports.h"
22 
23 namespace niftk
24 {
25 
29 
30 class NIFTKCORE_EXPORT BasicVec3D
31 {
32 public:
34  BasicVec3D();
36  BasicVec3D(float x1, float y1, float z1);
38  BasicVec3D(float av[3]);
40  BasicVec3D(const BasicVec3D& v);
42  virtual ~BasicVec3D() { };
43 
45  BasicVec3D& operator=(const BasicVec3D& v);
46 
48  bool operator==(const BasicVec3D& v);
50  bool operator!=(const BasicVec3D& v);
51 
53 
54  BasicVec3D operator+(float f) const;
55  BasicVec3D operator-(float f) const;
56  BasicVec3D operator*(float f) const;
57  BasicVec3D operator/(float f) const;
58 
59  BasicVec3D& operator+=(float f);
60  BasicVec3D& operator-=(float f);
61  BasicVec3D& operator*=(float f);
62  BasicVec3D& operator/=(float f);
64 
66 
67  BasicVec3D operator+ (const BasicVec3D& v) const;
68  BasicVec3D& operator+=(const BasicVec3D& v);
69  BasicVec3D operator- (const BasicVec3D& v) const;
70  BasicVec3D& operator-=(const BasicVec3D& v);
72 
74  BasicVec3D operator-() const;
75 
77 
78  friend BasicVec3D operator*(float a, const BasicVec3D& v) { return BasicVec3D (a * v.GetX(), a * v.GetY(), a * v.GetZ()); }
79  friend std::ostream& operator<<(std::ostream& os, const BasicVec3D& vo);
81 
83 
84  float Dot(const BasicVec3D& v) const;
85  BasicVec3D Cross(const BasicVec3D& v) const;
86  BasicVec3D NormalizedCross(const BasicVec3D& v) const;
87 
88  float Dot(const BasicVec3D& v1, const BasicVec3D& v2);
89  BasicVec3D Cross(const BasicVec3D& v1, const BasicVec3D& v2);
90  BasicVec3D NormalizedCross(const BasicVec3D& v1, const BasicVec3D& v2);
92 
94  void Normalize();
96  void SetZero();
98  float SelfDot();
100  float Length();
101 
103  float Distance(const BasicVec3D& v) const;
105  float DistanceSquared(const BasicVec3D& v) const;
106 
108  float Distance(const BasicVec3D& v1, const BasicVec3D& v2);
110  float DistanceSquared(const BasicVec3D& v1, const BasicVec3D& v2);
111 
113  void SetX(float x) { m_X = x; }
115  float GetX() const { return m_X; }
116 
118  void SetY(float y) { m_Y = y; }
120  float GetY() const { return m_Y; }
121 
123  void SetZ(float z) { m_Z = z; }
125  float GetZ() const { return m_Z; }
126 
127 private:
129 
130  float m_X;
131  float m_Y;
132  float m_Z;
134 };
135 
136 }
137 
138 #endif
GLdouble GLdouble z
Definition: glew.h:1543
std::vector< mitk::WorldPoint > operator*(const cv::Mat &M, const std::vector< mitk::WorldPoint > &p)
multiplies a set of points and corresponding scalar values by a 4x4 transformation matrix ...
Definition: mitkOpenCVMaths.cxx:354
bool operator==(niftk::BasicVertex const &x, niftk::BasicVertex const &y)
Definition: niftkMeshSmoother.cxx:31
float GetY() const
Returns the Y coordinate of the vector.
Definition: niftkBasicVec3D.h:120
GLfloat GLfloat v1
Definition: glew.h:1836
GLfloat GLfloat GLfloat v2
Definition: glew.h:1840
double Length(mitk::Point3D &vector)
Given a vector, will calculate the length.
Definition: niftkPointUtils.cxx:133
GLint GLint GLint GLint GLint GLint y
Definition: glew.h:1236
void SetZ(float z)
Sets the Z coordinate of the vector.
Definition: niftkBasicVec3D.h:123
std::ostream & operator<<(std::ostream &os, const CSVRow &data)
Definition: niftkCSVRow.h:89
void SetX(float x)
Sets the X coordinate of the vector.
Definition: niftkBasicVec3D.h:113
void SetY(float y)
Sets the Y coordinate of the vector.
Definition: niftkBasicVec3D.h:118
friend BasicVec3D operator*(float a, const BasicVec3D &v)
Definition: niftkBasicVec3D.h:78
const GLdouble * v
Definition: glew.h:1375
GLboolean GLboolean GLboolean GLboolean a
Definition: glew.h:8272
void Normalize(std::vector< double > &x)
Definition: niftiImageToMitk.cxx:34
virtual ~BasicVec3D()
Destructor that intentionally does nothing.
Definition: niftkBasicVec3D.h:42
float GetZ() const
Returns the Z coordinate of the vector.
Definition: niftkBasicVec3D.h:125
GLint GLint GLint GLint GLint x
Definition: glew.h:1236
float GetX() const
Returns the X coordinate of the vector.
Definition: niftkBasicVec3D.h:115
Simple 3D Vector implementation that is used in the Surface Extraction and surface smoothing and deci...
Definition: niftkBasicVec3D.h:30
Definition: niftkExceptionObject.h:21
cv::Point2d operator/(const cv::Point2d &p1, const int &n)
Divides a 2d point by an integer (x=x1/n, y=y1/2)
Definition: mitkOpenCVMaths.cxx:595
GLclampf f
Definition: glew.h:3136