Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #ifndef __CXUTILS_MATH_POINT_3D_H
00041 #define __CXUTILS_MATH_POINT_3D_H
00042
00043 #include "cxutils/cxbase.h"
00044 #include <vector>
00045 #include <string>
00046
00047 namespace CxUtils
00048 {
00055 class CX_UTILS_DLL Point3D
00056 {
00057 public:
00058 typedef std::vector<Point3D> List;
00059
00060
00061
00062
00063
00064
00065 enum Axis
00066 {
00067 X = 0,
00068 Y,
00069 Z
00070 };
00071 Point3D(const Point3D& p);
00072 Point3D(const double x = 0,
00073 const double y = 0,
00074 const double z = 0);
00075 int Set(const double x, const double y, const double z);
00076 int Get(double& x, double& y, double &z) const;
00077 void Clear();
00078 void Floor(const double thresh);
00079 void Print() const;
00080 bool IsParallel(const Point3D& p) const;
00081 bool IsCoplanar(const Point3D& p1, const Point3D& p2, const Point3D& p3) const;
00082 bool IsCollinear(const Point3D& p1, const Point3D& p2) const;
00083 bool IsInside(const Point3D& p1, const Point3D& p2, const Point3D& p3) const;
00084 double Distance() const;
00085 double Magnitude() const;
00086 double SumOfSquares() const;
00087 double Distance(const Point3D& p) const;
00088 double Dot(const Point3D& p) const;
00089 Point3D& Normalize();
00090 Point3D GetUnitVector() const;
00091 Point3D Rotate(const double angle,
00092 const unsigned int axis,
00093 const bool angleInDegrees = false) const;
00094 Point3D Rotate(const Point3D& origin,
00095 const double angle,
00096 const unsigned int axis,
00097 const bool angleInDegrees = false) const;
00098 Point3D Midpoint(const Point3D& p) const;
00099 Point3D& operator()(const double x, const double y, const double z);
00100 Point3D& operator=(const Point3D& p);
00101 Point3D& operator+=(const Point3D& p);
00102 Point3D& operator-=(const Point3D& p);
00103 Point3D& operator*=(const double val);
00104 Point3D& operator/=(const double val);
00105 Point3D& operator/=(const Point3D& p) { mX/=p.mX; mY/=p.mY; mZ/=p.mZ; return *this; }
00106 Point3D operator+(const Point3D& p) const;
00107 Point3D operator-(const Point3D& p) const;
00108 Point3D operator*(const double scaler) const;
00109 Point3D operator/(const double scaler) const;
00110 Point3D operator*(const Point3D& p) const;
00111 Point3D operator/(const Point3D& p) const { return Point3D(mX/p.mX, mY/p.mY, mZ/p.mZ); }
00112 static double Distance(const Point3D& p1, const Point3D& p2);
00113 static Point3D Midpoint(const Point3D& p1, const Point3D& p2);
00114 static double Dot(const Point3D& p1, const Point3D& p2) { return p1.Dot(p2); }
00115 static bool IsCoplanar(const Point3D& p1,
00116 const Point3D& p2,
00117 const Point3D& p3,
00118 const Point3D& p4);
00119
00120 static double LinearRegressionSlope(const Point3D::List& points);
00121
00122 static double GetLinearRegressionAngle(const Point3D::List& points);
00123 double mX;
00124 double mY;
00125 double mZ;
00126 };
00127 }
00128
00129 #endif
00130