88 lines
1.7 KiB
C++
88 lines
1.7 KiB
C++
#pragma once
|
|
|
|
#include "DiscretePoint.h"
|
|
#include "Vector.h"
|
|
|
|
#include <memory>
|
|
|
|
class Transform;
|
|
|
|
template<std::size_t DIM = 3>
|
|
class Point
|
|
{
|
|
public:
|
|
Point(double x = 0, double y = 0, double z = 0.0);
|
|
|
|
Point(const Vector<double, DIM>& v);
|
|
|
|
Point(const Point<2>& p);
|
|
|
|
Point(const Point<DIM>& p) = default;
|
|
|
|
Point(const DiscretePoint& point);
|
|
|
|
Point(const Point<DIM>& reference, double offSetX, double offSetY, double offSetZ = 0);
|
|
|
|
~Point();
|
|
|
|
void apply(const Transform& transform);
|
|
|
|
double getX() const;
|
|
|
|
double getY() const;
|
|
|
|
double getZ() const;
|
|
|
|
double getDistance(const Point<DIM>& point) const;
|
|
|
|
double getDeltaX(const Point<DIM>& point) const;
|
|
|
|
double getDeltaY(const Point<DIM>& point) const;
|
|
|
|
double getDeltaZ(const Point<DIM>& point) const;
|
|
|
|
Vector<double, DIM> getOriginOffset() const;
|
|
|
|
Vector<double, DIM> getDelta(const Point<DIM>& point) const;
|
|
|
|
bool isAtOrigin() const;
|
|
|
|
bool isEqual(const Point<DIM>& rhs) const;
|
|
|
|
void moveBy(const Vector<double, DIM>& vector);
|
|
|
|
void scale(double x, double y = 0.0, double z = 0.0);
|
|
|
|
void moveBy(double x, double y = 0.0, double z = 0.0);
|
|
|
|
Point<DIM> operator+(const Vector<double, DIM>& vector)
|
|
{
|
|
Point<DIM> p(*this);
|
|
p += vector;
|
|
return p;
|
|
}
|
|
|
|
void operator+=(const Vector<double, DIM>& vector)
|
|
{
|
|
moveBy(vector);
|
|
}
|
|
|
|
bool operator==(const Point<DIM>& rhs) const
|
|
{
|
|
return isEqual(rhs);
|
|
}
|
|
|
|
bool operator!=(const Point<DIM>& rhs) const
|
|
{
|
|
return !operator==(rhs);
|
|
}
|
|
|
|
private:
|
|
std::vector<double> mCoords;
|
|
};
|
|
|
|
using Point3 = Point<3>;
|
|
using Point2 = Point<2>;
|
|
|
|
using PointPtr3 = std::unique_ptr<Point<3> >;
|
|
using PointPtr2 = std::unique_ptr<Point<2> >;
|