15static std::vector<fvec<int, 2>> bresenham(fvec<int, 2> origin, fvec<int, 2> destination) {
17 bool flip = std::abs(destination.y() - origin.y()) >= std::abs(destination.x() - origin.x());
20 std::swap(origin.x(), origin.y());
21 std::swap(destination.x(), destination.y());
24 if(origin.x() > destination.x())
25 std::swap(origin, destination);
27 fvec<int, 2> d = destination - origin;
34 int D = (2 * d.y()) - d.x();
37 std::vector<fvec<int, 2>> points;
39 for(
int x = origin.x(); x <= destination.x(); ++x) {
40 flip ? points.emplace_back(y, x) : points.emplace_back(x, y);
43 D = D + (2 * (d.y() - d.x()));
70 if(origin_ == destination_)
73 dx = std::abs(destination_.
x() - origin_.
x());
74 sx = origin_.
x() < destination_.
x() ? 1 : -1;
75 dy = -std::abs(destination_.
y() - origin_.
y());
76 sy = origin_.
y() < destination_.
y() ? 1 : -1;
114 if(position_ == destination_)
A vector with zero based index.