stuff-from-scratch/src/geometry/LineSegment.cpp
2022-11-14 11:19:51 +00:00

43 lines
703 B
C++

#include "LineSegment.h"
LineSegment::LineSegment(const Point& p0, const Point& p1)
: mP0(p0),
mP1(p1)
{
}
std::unique_ptr<LineSegment> LineSegment::Create(const Point& p0, const Point& p1)
{
return std::make_unique<LineSegment>(p0, p1);
}
double LineSegment::getLength() const
{
return mP0.getDistance(mP1);
}
const Point& LineSegment::getPoint0() const
{
return mP0;
}
const Point& LineSegment::getPoint1() const
{
return mP1;
}
void LineSegment::sample(Grid<unsigned char>* grid) const
{
}
LineSegment::Bounds LineSegment::getSize() const
{
return {mP0.getDeltaX(mP1), mP0.getDeltaY(mP1)};
}
const Point& LineSegment::getLocation() const
{
return mP0;
}