7 #ifndef __GEOMETRY_UTILS_H 8 #define __GEOMETRY_UTILS_H 14 #define EQ_DOUBLE(a, b) \ 15 (std::abs((a) - (b)) < 0.0001) 70 x{x_coord},
y{y_coord} {}
90 return std::pow(x - pt.
x, 2) + std::pow(y - pt.
y, 2);
107 generatePointsWithBresenham(start.
x, start.
y, end.
x, end.
y);
110 const std::vector<Point>&
points()
const {
return _points; }
126 int delta_x(x2 - x1);
128 signed char const ix((delta_x > 0) - (delta_x < 0));
129 delta_x = std::abs(delta_x) * 2;
131 int delta_y(y2 - y1);
133 signed char const iy((delta_y > 0) - (delta_y < 0));
134 delta_y = std::abs(delta_y) * 2;
136 _points.push_back(
Point(x1, y1));
138 if (delta_x >= delta_y) {
140 int error(delta_y - (delta_x >> 1));
142 if ((0 <= error) && (error || (0 < ix))) {
149 _points.push_back(
Point(x1, y1));
154 int error(delta_x - (delta_y >> 1));
157 if ((0 <= error) && (error || (0 < iy))) {
164 _points.push_back(
Point(x1, y1));
double top
The top of a rectangle.
double bot
The bottom of a rectangle.
double right
The right side of a rectangle.
Rectangle(double b, double t, double l, double r)
void generatePointsWithBresenham(int x1, int y1, int x2, int y2)
DiscretePoint2D operator+(const DiscretePoint2D &p) const
Operator of points summation by element-wise addition.
TFSIMD_FORCE_INLINE const tfScalar & y() const
double dist_sq(const DiscretePoint2D &pt) const
DiscretePoint2D operator-() const
Returns additive inverse of the point.
int y
Coordinates of point.
bool does_contain(double x, double y) const
const std::vector< Point > & points() const
Returns the line's component points.
double left
The left side of a rectangle.
TFSIMD_FORCE_INLINE const tfScalar & x() const
Defines an axis-aligned rectangle.
Rectangle()
Creates a rectangle with zero area in point (0,0).
DiscretePoint2D(int x_coord, int y_coord)
Defines a line segment on a plane.
std::vector< Point > _points
DiscreteLine2D(const Point &start, const Point &end)
Defines a point with integer coordinates on a plane.