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

32 lines
587 B
C
Raw Normal View History

2022-08-03 20:05:01 +00:00
#pragma once
#include "AbstractGeometricItem.h"
#include "Point.h"
2022-11-14 11:19:51 +00:00
template<class T>
class Grid;
2022-08-03 20:05:01 +00:00
class LineSegment : public AbstractGeometricItem
{
public:
2022-11-14 11:19:51 +00:00
LineSegment(const Point& p0, const Point& p1);
2022-08-03 20:05:01 +00:00
2022-11-14 11:19:51 +00:00
static std::unique_ptr<LineSegment> Create(const Point& p0, const Point& p1);
2022-08-03 20:05:01 +00:00
double getLength() const;
2022-11-14 11:19:51 +00:00
const Point& getPoint0() const;
const Point& getPoint1() const;
2022-08-03 20:05:01 +00:00
2022-11-14 11:19:51 +00:00
void sample(Grid<unsigned char>* grid) const override;
2022-08-03 20:05:01 +00:00
2022-11-14 11:19:51 +00:00
Bounds getSize() const override;
2022-08-03 20:05:01 +00:00
2022-11-14 11:19:51 +00:00
const Point& getLocation() const override;
2022-08-03 20:05:01 +00:00
private:
2022-11-14 11:19:51 +00:00
Point mP0;
Point mP1;
2022-08-03 20:05:01 +00:00
};