Kstars

rectangleoverlap.h
1/*
2 SPDX-FileCopyrightText: 2023 Hy Murveit <hy@murveit.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5
6 Based on https://github.com/lennig/rectangleOverlap
7 with permission from Matt Lennig
8*/
9
10#pragma once
11
12#include <QVector>
13#include <QPoint>
14
15/**
16 * @class RectangleOverlap
17 *
18 * This class checks if two rectangles overlap. It is more general that QRect::intersects
19 * in that the rectangles are not necessarily aligned to the axes (that is they can be
20 * specified as rotated around their center points).
21 *
22 * @short Checks if two potentially rotated rectangles intersect.
23 * @author Hy Murveit
24 */
25
27{
28public:
29 /** Constructor specifying reference rectangle
30 * @param center the center of the rectangle
31 * @param width its width
32 * @param height its height
33 * @param rotationDegrees amount in degrees the rectangle is rotated counter-clockwise
34 */
35 RectangleOverlap(const QPointF &center, int width, int height, double rotationDegrees = 0.0);
36
37 /**
38 * @brief Check if the input rectangle overlaps the reference rectangle
39 *
40 * @param center the center of the input rectangle
41 * @param width its width
42 * @param height its height
43 * @param rotationDegrees amount in degrees the rectangle is rotated counter-clockwise
44 * @return true if the rectangles overlap
45 **/
46 bool intersects(const QPointF &center, int width, int height, double rotationDegrees = 0.0) const;
47
48private:
49 // The coordinates of the reference triangle's vertices, counter-clockwise.
50 QVector<QPointF> m_Vertices;
51};
52
53
This class checks if two rectangles overlap.
bool intersects(const QPointF &center, int width, int height, double rotationDegrees=0.0) const
Check if the input rectangle overlaps the reference rectangle.
RectangleOverlap(const QPointF &center, int width, int height, double rotationDegrees=0.0)
Constructor specifying reference rectangle.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 3 2024 11:49:50 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.