stuff-from-scratch/src/geometry/Point.cpp

69 lines
1.1 KiB
C++
Raw Normal View History

2020-05-02 07:31:03 +00:00
#include "Point.h"
2022-11-16 09:39:05 +00:00
Point::Point(double x, double y, double z)
2022-08-03 20:05:01 +00:00
: mX(x),
2022-11-16 09:39:05 +00:00
mY(y),
mZ(z)
2020-05-02 07:31:03 +00:00
{
}
2022-11-14 13:07:11 +00:00
Point::Point(const DiscretePoint& point)
: mX(point.GetX()),
2022-11-16 09:39:05 +00:00
mY(point.GetY()),
mZ(0)
2022-11-14 13:07:11 +00:00
{
}
2022-11-16 09:39:05 +00:00
Point::Point(const Point& reference, double offSetX, double offSetY, double offSetZ)
2022-11-13 17:02:09 +00:00
: mX(reference.getX() + offSetX),
2022-11-16 09:39:05 +00:00
mY(reference.getY() + offSetY),
mZ(reference.getZ() + offSetZ)
2022-11-13 17:02:09 +00:00
{
}
2020-05-02 07:31:03 +00:00
Point::~Point()
{
};
2022-11-16 09:39:05 +00:00
std::shared_ptr<Point> Point::Create(double x, double y, double z)
2020-05-02 07:31:03 +00:00
{
2022-11-16 09:39:05 +00:00
return std::make_shared<Point>(x, y, z);
2022-08-03 20:05:01 +00:00
}
double Point::getX() const
{
return mX;
}
double Point::getY() const
{
return mY;
}
2022-11-16 09:39:05 +00:00
double Point::getZ() const
{
return mZ;
}
2022-08-03 20:05:01 +00:00
double Point::getDistance(const Point& point) const
{
2022-11-16 09:39:05 +00:00
return std::sqrt(mX*point.getX() + mY*point.getY() + mZ*point.getZ());
2022-08-03 20:05:01 +00:00
}
double Point::getDistance(Point* point) const
{
2022-11-16 09:39:05 +00:00
return std::sqrt(mX*point->getX() + mY*point->getY() + mZ*point->getZ());
2022-08-03 20:05:01 +00:00
}
double Point::getDeltaX(const Point& point) const
{
return point.getX() - mX;
}
double Point::getDeltaY(const Point& point) const
{
return point.getY() - mY;
2020-05-02 07:31:03 +00:00
}