Clean project structure.

This commit is contained in:
jmsgrogan 2023-01-17 10:13:25 +00:00
parent 78a4fa99ff
commit 947bf937fd
496 changed files with 206 additions and 137 deletions

View file

@ -0,0 +1,28 @@
#include "DiscretePoint.h"
DiscretePoint::DiscretePoint(unsigned x, unsigned y)
: mX(x),
mY(y)
{
}
DiscretePoint::~DiscretePoint()
{
};
std::shared_ptr<DiscretePoint> DiscretePoint::Create(unsigned x, unsigned y)
{
return std::make_shared<DiscretePoint>(x, y);
}
unsigned DiscretePoint::getX() const
{
return mX;
}
unsigned DiscretePoint::getY() const
{
return mY;
}

View file

@ -0,0 +1,35 @@
#pragma once
#include <memory>
class DiscretePoint
{
public:
DiscretePoint(unsigned x = 0, unsigned y = 0);
~DiscretePoint();
std::shared_ptr<DiscretePoint> Create(unsigned x, unsigned y);
unsigned getX() const;
unsigned getY() const;
bool operator==(const DiscretePoint& rhs) const
{
return (mX == rhs.mX)
&& (mY == rhs.mY);
}
bool operator!=(const DiscretePoint& rhs) const
{
return !operator==(rhs);
}
private:
unsigned mX{ 0 };
unsigned mY{ 0 };
};
using Pixel = DiscretePoint;
using DiscretePointPtr = std::shared_ptr<DiscretePoint>;
using PixelPtr = DiscretePointPtr;

View file

@ -0,0 +1,91 @@
#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();
}

View file

@ -0,0 +1,60 @@
#pragma once
#include "DiscretePoint.h"
#include "Vector.h"
#include <memory>
#include <vector>
class Transform;
class Point
{
public:
Point(double x = 0, double y = 0, double z = 0);
Point(const DiscretePoint& point);
Point(const Point& reference, double offSetX, double offSetY, double offSetZ = 0);
~Point();
static std::shared_ptr<Point> Create(double x, double y, double z = 0);
void apply(const Transform& transform);
double getX() const;
double getY() const;
double getZ() const;
double getDistance(const Point& point) const;
double getDeltaX(const Point& point) const;
double getDeltaY(const Point& point) const;
double getDeltaZ(const Point& point) const;
Vector getDelta(const Point& point) const;
bool operator==(const Point& rhs) const
{
return (mX == rhs.mX)
&& (mY == rhs.mY)
&& (mZ == rhs.mZ);
}
bool operator!=(const Point& rhs) const
{
return !operator==(rhs);
}
private:
double mX{0};
double mY{0};
double mZ{0};
};
using PointPtr = std::unique_ptr<Point>;

View file

@ -0,0 +1,32 @@
#include "PointCollection.h"
PointCollection::PointCollection(const std::vector<Point> points)
: mPoints(points)
{
}
void PointCollection::apply(const Transform& transform)
{
for (auto& point : mPoints)
{
point.apply(transform);
}
}
Bounds PointCollection::getBounds() const
{
Bounds bounds{0.0, 0.0, 0.0, 0.0};
if (mPoints.size() == 0)
{
return bounds;
}
bounds.intialize(mPoints[0].getX(), mPoints[0].getY(), mPoints[0].getZ());
for(const auto& point : mPoints)
{
bounds.includePoint(point.getX(), point.getY(), point.getZ());
}
return bounds;
}

View file

@ -0,0 +1,18 @@
#pragma once
#include "Point.h"
#include "Transform.h"
#include "Bounds.h"
class PointCollection
{
public:
PointCollection(const std::vector<Point> points = {});
void apply(const Transform& transform);
Bounds getBounds() const;
private:
std::vector<Point> mPoints;
};