91 lines
1.6 KiB
C++
91 lines
1.6 KiB
C++
#include "Point.h"
|
|
|
|
#include "Transform.h"
|
|
|
|
#include <cmath>
|
|
|
|
Point::Point(double x, double y, double z)
|
|
: mX(x),
|
|
mY(y),
|
|
mZ(z)
|
|
{
|
|
}
|
|
|
|
Point::Point(const DiscretePoint& point)
|
|
: mX(static_cast<double>(point.getX())),
|
|
mY(static_cast<double>(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
|
|
{
|
|
const auto deltaX = getDeltaX(point);
|
|
const auto deltaY = getDeltaY(point);
|
|
const auto deltaZ = getDeltaZ(point);
|
|
return std::sqrt(deltaX* deltaX + deltaY* deltaY + deltaZ* deltaZ);
|
|
}
|
|
|
|
Vector Point::getDelta(const Point& point) const
|
|
{
|
|
return Vector(point.mX - mX, point.mY - mY, point.mZ - mZ);
|
|
}
|
|
|
|
double Point::getDeltaX(const Point& point) const
|
|
{
|
|
return point.getX() - mX;
|
|
}
|
|
|
|
double Point::getDeltaY(const Point& point) const
|
|
{
|
|
return point.getY() - mY;
|
|
}
|
|
|
|
double Point::getDeltaZ(const Point& point) const
|
|
{
|
|
return point.getZ() - mZ;
|
|
}
|
|
|
|
void Point::apply(const Transform& transform)
|
|
{
|
|
mX -= transform.getLocation().getX();
|
|
mY -= transform.getLocation().getY();
|
|
mZ -= transform.getLocation().getZ();
|
|
|
|
mX *= transform.getScaleX();
|
|
mY *= transform.getScaleY();
|
|
mZ *= transform.getScaleZ();
|
|
}
|