Switch to template types for vectors
This commit is contained in:
parent
9f036d6438
commit
8192ef78e8
105 changed files with 1614 additions and 1424 deletions
|
@ -7,14 +7,19 @@
|
|||
|
||||
class Transform;
|
||||
|
||||
template<std::size_t DIM = 3>
|
||||
class Point
|
||||
{
|
||||
public:
|
||||
Point(double x = 0, double y = 0, double z = 0);
|
||||
Point(double x = 0, double y = 0, double z = 0.0);
|
||||
|
||||
Point(const Vector<double, DIM>& v);
|
||||
|
||||
Point(const Point<2>& p);
|
||||
|
||||
Point(const DiscretePoint& point);
|
||||
|
||||
Point(const Point& reference, double offSetX, double offSetY, double offSetZ = 0);
|
||||
Point(const Point<DIM>& reference, double offSetX, double offSetY, double offSetZ = 0);
|
||||
|
||||
~Point();
|
||||
|
||||
|
@ -26,43 +31,56 @@ public:
|
|||
|
||||
double getZ() const;
|
||||
|
||||
double getDistance(const Point& point) const;
|
||||
double getDistance(const Point<DIM>& point) const;
|
||||
|
||||
double getDeltaX(const Point& point) const;
|
||||
double getDeltaX(const Point<DIM>& point) const;
|
||||
|
||||
double getDeltaY(const Point& point) const;
|
||||
double getDeltaY(const Point<DIM>& point) const;
|
||||
|
||||
double getDeltaZ(const Point& point) const;
|
||||
double getDeltaZ(const Point<DIM>& point) const;
|
||||
|
||||
Vector getDelta(const Point& point) const;
|
||||
Vector<double, DIM> getOriginOffset() const;
|
||||
|
||||
Vector<double, DIM> getDelta(const Point<DIM>& point) const;
|
||||
|
||||
bool isAtOrigin() const;
|
||||
|
||||
void move(const Vector& vector);
|
||||
bool isEqual(const Point<DIM>& rhs) const;
|
||||
|
||||
void move(double x, double y = 0.0, double z = 0.0);
|
||||
void moveBy(const Vector<double, DIM>& vector);
|
||||
|
||||
void operator+=(const Vector& 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)
|
||||
{
|
||||
move(vector);
|
||||
Point<DIM> p(*this);
|
||||
p += vector;
|
||||
return p;
|
||||
}
|
||||
|
||||
bool operator==(const Point& rhs) const
|
||||
void operator+=(const Vector<double, DIM>& vector)
|
||||
{
|
||||
return (mX == rhs.mX)
|
||||
&& (mY == rhs.mY)
|
||||
&& (mZ == rhs.mZ);
|
||||
moveBy(vector);
|
||||
}
|
||||
|
||||
bool operator!=(const Point& rhs) const
|
||||
bool operator==(const Point<DIM>& rhs) const
|
||||
{
|
||||
return isEqual(rhs);
|
||||
}
|
||||
|
||||
bool operator!=(const Point<DIM>& rhs) const
|
||||
{
|
||||
return !operator==(rhs);
|
||||
}
|
||||
|
||||
private:
|
||||
double mX{0};
|
||||
double mY{0};
|
||||
double mZ{0};
|
||||
std::vector<double> mCoords;
|
||||
};
|
||||
|
||||
using PointPtr = std::unique_ptr<Point>;
|
||||
using Point3 = Point<3>;
|
||||
using Point2 = Point<2>;
|
||||
|
||||
using PointPtr3 = std::unique_ptr<Point<3> >;
|
||||
using PointPtr2 = std::unique_ptr<Point<2> >;
|
Loading…
Add table
Add a link
Reference in a new issue