103 lines
1.8 KiB
C++
103 lines
1.8 KiB
C++
#ifndef _ENGINE_POINT3D_HPP_
|
|
#define _ENGINE_POINT3D_HPP_
|
|
#ifndef _COMMON_POINT_HPP_
|
|
#include <common/point.hpp>
|
|
#endif
|
|
#ifndef _COMMON_MATH_HPP_
|
|
#include <common/math.hpp>
|
|
#endif
|
|
|
|
// do not make changes to this class that will alter its size
|
|
|
|
class Point3D : public Point
|
|
{
|
|
public:
|
|
Point3D(void);
|
|
Point3D(short x,short y,short z=0);
|
|
Point3D(const Point3D &somePoint3D);
|
|
~Point3D();
|
|
WORD operator==(const Point3D &somePoint3D)const;
|
|
const Point3D &operator=(const Point3D &somePoint3D);
|
|
const Point3D &operator-=(const Point3D &somePoint3D);
|
|
int operator*(const Point3D &somePoint3D)const;
|
|
int distance(const Point3D &somePoint3D)const;
|
|
short z(void)const;
|
|
void z(short newz);
|
|
private:
|
|
short mZ;
|
|
};
|
|
|
|
inline
|
|
Point3D::Point3D(void)
|
|
: mZ(0)
|
|
{
|
|
}
|
|
|
|
inline
|
|
Point3D::Point3D(short x,short y,short z)
|
|
: Point(x,y), mZ(z)
|
|
{
|
|
}
|
|
|
|
inline
|
|
Point3D::Point3D(const Point3D &somePoint3D)
|
|
: mZ(somePoint3D.z())
|
|
{
|
|
x(somePoint3D.x());
|
|
y(somePoint3D.y());
|
|
}
|
|
|
|
inline
|
|
short Point3D::z(void)const
|
|
{
|
|
return mZ;
|
|
}
|
|
|
|
inline
|
|
void Point3D::z(short newz)
|
|
{
|
|
mZ=newz;
|
|
}
|
|
|
|
inline
|
|
Point3D::~Point3D()
|
|
{
|
|
}
|
|
|
|
inline
|
|
WORD Point3D::operator==(const Point3D &somePoint3D)const
|
|
{
|
|
return (mZ==somePoint3D.mZ && (Point&)(*this)==(Point&)somePoint3D);
|
|
}
|
|
|
|
inline
|
|
const Point3D &Point3D::operator=(const Point3D &somePoint3D)
|
|
{
|
|
mZ=somePoint3D.mZ;
|
|
(Point&)(*this)=(Point&)somePoint3D;
|
|
return *this;
|
|
}
|
|
|
|
inline
|
|
const Point3D &Point3D::operator-=(const Point3D &somePoint3D)
|
|
{
|
|
mZ-=somePoint3D.mZ;
|
|
(Point&)(*this)-=(Point&)somePoint3D;
|
|
return *this;
|
|
}
|
|
|
|
inline
|
|
int Point3D::operator*(const Point3D &somePoint3D)const
|
|
{
|
|
return ((int)x()*(int)somePoint3D.x())+((int)y()*(int)somePoint3D.y())+((int)z()*(int)somePoint3D.z());
|
|
}
|
|
|
|
inline
|
|
int Point3D::distance(const Point3D &somePoint3D)const
|
|
{
|
|
int xDiff(somePoint3D.x()-x());
|
|
int yDiff(somePoint3D.y()-y());
|
|
return (xDiff*xDiff)+(yDiff*yDiff);
|
|
}
|
|
#endif
|