SpikeStream Library
0.2
|
00001 //SpikeStream includes 00002 #include "Point3D.h" 00003 using namespace spikestream; 00004 00005 //Qt includes 00006 #include <QDebug> 00007 00008 //Other includes 00009 #include <math.h> 00010 00011 00013 Point3D::Point3D(){ 00014 xPos = 0.0f; 00015 yPos = 0.0f; 00016 zPos = 0.0f; 00017 } 00018 00019 00021 Point3D::Point3D(float xPos, float yPos, float zPos){ 00022 this->xPos = xPos; 00023 this->yPos = yPos; 00024 this->zPos = zPos; 00025 } 00026 00027 00029 Point3D::Point3D(const Point3D& point){ 00030 this->xPos = point.xPos; 00031 this->yPos = point.yPos; 00032 this->zPos = point.zPos; 00033 } 00034 00035 00037 Point3D::~Point3D(){ 00038 } 00039 00040 00041 /*--------------------------------------------------------- */ 00042 /*----- PUBLIC METHODS ----- */ 00043 /*--------------------------------------------------------- */ 00044 00046 Point3D& Point3D::operator =(const Point3D& point){ 00047 if(&point == this) 00048 return *this; 00049 00050 this->xPos = point.xPos; 00051 this->yPos = point.yPos; 00052 this->zPos = point.zPos; 00053 return *this; 00054 } 00055 00056 00058 bool Point3D::operator ==(const Point3D& point) const{ 00059 if(this->xPos == point.xPos && this->yPos == point.yPos && this->zPos == point.zPos) 00060 return true; 00061 return false; 00062 } 00063 00064 00066 bool Point3D::operator !=(const Point3D& point) const{ 00067 if(this->xPos == point.xPos && this->yPos == point.yPos && this->zPos == point.zPos) 00068 return false; 00069 return true; 00070 } 00071 00072 00074 float Point3D::distance(const Point3D& point) const{ 00075 float result = (xPos - point.xPos) * (xPos - point.xPos); 00076 result += (yPos - point.yPos) * (yPos - point.yPos); 00077 result += (zPos - point.zPos) * (zPos - point.zPos); 00078 return sqrt(result); 00079 } 00080 00081 00083 QString Point3D::toString() const{ 00084 QString tmpStr = "("; 00085 tmpStr += QString::number(xPos) + ", "; 00086 tmpStr += QString::number(yPos) + ", "; 00087 tmpStr += QString::number(zPos) + ")"; 00088 return tmpStr; 00089 } 00090 00091 00093 void Point3D::translate(float dx, float dy, float dz){ 00094 xPos += dx; 00095 yPos += dy; 00096 zPos += dz; 00097 } 00098