Mobile API Reference  MicroStrategy 2019
Point3D.h
Go to the documentation of this file.
1 //==============================================================================================
2 // FILENAME : Point3D.h
3 // AUTHOR : Liang Liu
4 // CREATION : 2009-05-18
5 // Copyright (C) MicroStrategy Incorporated 2009
6 // All Rights Reserved
7 //==============================================================================================
8 
9 #ifndef MsiChart_Point3D_h
10 #define MsiChart_Point3D_h
11 
12 #include "PDCHeader/PDCvector"
13 #include "PDCHeader/PDCcmath"
14 
15 namespace MsiChart
16 {
20  template <typename T = double>
21  class Point3D
22  {
23  public:
30  Point3D(T iX = T(), T iY = T(), T iZ = T()): x(iX), y(iY), z(iZ){}
35  Point3D(const Point3D<T>& irPoint):x(irPoint.x), y(irPoint.y), z(irPoint.z){}
40  template <typename U>
41  Point3D(const Point3D<U>& irPoint);
42 
49  void Reset(T iX, T iY, T iZ);
50 
56  double DistanceSquared(const Point3D<T>& irPoint) const;
62  double Distance(const Point3D<T>& irPoint) const;
63 
70  bool operator != (const Point3D<T>& irPoint) const;
71 
76  Point3D<T> operator - () const;
77 
83  Point3D<T> MiddleTo(const Point3D<T>& irPoint) const;
84 
90  Point3D<T> Shifted(const Point3D<T>& irOffset) const;
91 
97  void Swap(Point3D<T>& iorPoint);
98 
99  T x;
100  T y;
101  T z;
102  };
103 
104 
105  template<typename T>
106  template<typename U> Point3D<T>::Point3D(const Point3D<U>& iPoint)
107  {
108  x = iPoint.x;
109  y = iPoint.y;
110  z = iPoint.z;
111  }
112 
113  template<typename T>
114  inline void Point3D<T>::Reset(T iX, T iY, T iZ)
115  {
116  x = iX;
117  y = iY;
118  z = iZ;
119  }
120 
121  template<typename T>
122  double Point3D<T>::DistanceSquared(const Point3D<T>& irPoint) const
123  {
124  return (x - irPoint.x) * (x - irPoint.x)
125  + (y - irPoint.y) * (y - irPoint.y)
126  + (z - irPoint.z) * (z - irPoint.z);
127  }
128 
129  template<typename T>
130  double Point3D<T>::Distance(const Point3D<T>& irPoint) const
131  {
132  return std::sqrt(DistanceSquared(irPoint));
133  }
134 
135  template<typename T>
136  bool Point3D<T>::operator != (const Point3D<T>& irPoint) const
137  {
138  return ((x != irPoint.x) || (y != irPoint.y) || (z != irPoint.z));
139  }
140 
141  template<typename T>
143  {
144  return Point3D<T>(-x, -y, -z);
145  }
146 
147  template<typename T>
149  {
150  return Point3D<T>((x + irPoint.x) / 2, (y + irPoint.y) / 2, (z + irPoint.z) / 2);
151  }
152 
153  template<typename T>
155  {
156  return Point3D<T>(x + irOffset.x, y + irOffset.y, z + irOffset.z);
157  }
158 
159  template<typename T>
160  void Point3D<T>::Swap(Point3D<T>& iorPoint)
161  {
162  std::swap(x, iorPoint.x);
163  std::swap(y, iorPoint.y);
164  std::swap(z, iorPoint.z);
165  }
169 }
170 
171 #endif
Point3D(T iX=T(), T iY=T(), T iZ=T())
Definition: Point3D.h:30
Point3D(const Point3D< T > &irPoint)
Definition: Point3D.h:35
Point3D< Int32 > SPoint3D
Definition: Point3D.h:166
void Reset(T iX, T iY, T iZ)
Definition: Point3D.h:114
double Distance(const Point3D< T > &irPoint) const
Definition: Point3D.h:130
Point3D< T > operator-() const
Definition: Point3D.h:142
Point3D< T > Shifted(const Point3D< T > &irOffset) const
Definition: Point3D.h:154
T x
X-coordinate of current Point3D.
Definition: Point3D.h:99
bool operator!=(const Point3D< T > &irPoint) const
Definition: Point3D.h:136
T y
Y-coordinate of current Point3D.
Definition: Point3D.h:100
Definition: Point3D.h:21
double DistanceSquared(const Point3D< T > &irPoint) const
Definition: Point3D.h:122
Definition: ABLPlot.h:21
void Swap(Point3D< T > &iorPoint)
Definition: Point3D.h:160
Point3D< T > MiddleTo(const Point3D< T > &irPoint) const
Definition: Point3D.h:148
T z
Z-coordinate of current Point3D.
Definition: Point3D.h:101
Point3D< double > DPoint3D
Definition: Point3D.h:168
Point3D< float > FPoint3D
Definition: Point3D.h:167