stuff-from-scratch/src/geometry/LineSegment.cpp

29 lines
454 B
C++
Raw Normal View History

2022-08-03 20:05:01 +00:00
#include "LineSegment.h"
LineSegment::LineSegment(PointPtr p0, PointPtr p1)
: mP0(p0),
mP1(p1)
{
}
std::shared_ptr<LineSegment> LineSegment::Create(PointPtr p0, PointPtr p1)
{
return std::make_shared<LineSegment>(p0, p1);
}
double LineSegment::getLength() const
{
return mP0->getDistance(mP1.get());
}
Point* LineSegment::getPoint0() const
{
return mP0.get();
}
Point* LineSegment::getPoint1() const
{
return mP1.get();
}