2022-08-03 20:05:01 +00:00
|
|
|
#include "LineSegment.h"
|
|
|
|
|
2022-11-14 11:19:51 +00:00
|
|
|
LineSegment::LineSegment(const Point& p0, const Point& p1)
|
2022-08-03 20:05:01 +00:00
|
|
|
: mP0(p0),
|
|
|
|
mP1(p1)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-11-14 11:19:51 +00:00
|
|
|
std::unique_ptr<LineSegment> LineSegment::Create(const Point& p0, const Point& p1)
|
2022-08-03 20:05:01 +00:00
|
|
|
{
|
2022-11-14 11:19:51 +00:00
|
|
|
return std::make_unique<LineSegment>(p0, p1);
|
2022-08-03 20:05:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
double LineSegment::getLength() const
|
|
|
|
{
|
2022-11-14 11:19:51 +00:00
|
|
|
return mP0.getDistance(mP1);
|
2022-08-03 20:05:01 +00:00
|
|
|
}
|
|
|
|
|
2022-11-14 11:19:51 +00:00
|
|
|
const Point& LineSegment::getPoint0() const
|
2022-08-03 20:05:01 +00:00
|
|
|
{
|
2022-11-14 11:19:51 +00:00
|
|
|
return mP0;
|
2022-08-03 20:05:01 +00:00
|
|
|
}
|
|
|
|
|
2022-11-14 11:19:51 +00:00
|
|
|
const Point& LineSegment::getPoint1() const
|
2022-08-03 20:05:01 +00:00
|
|
|
{
|
2022-11-14 11:19:51 +00:00
|
|
|
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;
|
2022-08-03 20:05:01 +00:00
|
|
|
}
|