stuff-from-scratch/src/geometry/Point.cpp
2022-11-16 09:39:05 +00:00

68 lines
1.1 KiB
C++

#include "Point.h"
Point::Point(double x, double y, double z)
: mX(x),
mY(y),
mZ(z)
{
}
Point::Point(const DiscretePoint& point)
: mX(point.GetX()),
mY(point.GetY()),
mZ(0)
{
}
Point::Point(const Point& reference, double offSetX, double offSetY, double offSetZ)
: mX(reference.getX() + offSetX),
mY(reference.getY() + offSetY),
mZ(reference.getZ() + offSetZ)
{
}
Point::~Point()
{
};
std::shared_ptr<Point> Point::Create(double x, double y, double z)
{
return std::make_shared<Point>(x, y, z);
}
double Point::getX() const
{
return mX;
}
double Point::getY() const
{
return mY;
}
double Point::getZ() const
{
return mZ;
}
double Point::getDistance(const Point& point) const
{
return std::sqrt(mX*point.getX() + mY*point.getY() + mZ*point.getZ());
}
double Point::getDistance(Point* point) const
{
return std::sqrt(mX*point->getX() + mY*point->getY() + mZ*point->getZ());
}
double Point::getDeltaX(const Point& point) const
{
return point.getX() - mX;
}
double Point::getDeltaY(const Point& point) const
{
return point.getY() - mY;
}