5#include <QtTest/QtTest>
14const double PI = 3.1415926535;
22void TestProjectedPoint::cleanupTestCase ()
27void TestProjectedPoint::initTestCase ()
34 const bool NO_RESET =
false;
60void TestProjectedPoint::testProjectedPoints ()
62 double radiusCircle = 1.0, radiusProjection = 2.0 * radiusCircle;
63 double xToProjectRight = radiusProjection, yToProjectRight = 0.0;
64 double xToProjectUp = 0.0, yToProjectUp = 2.0 * radiusCircle;
65 double xProjectionRight, yProjectionRight, projectedDistanceOutsideLineRight;
66 double xProjectionUp, yProjectionUp, projectedDistanceOutsideLineUp;
67 double distanceToLine;
74 int angleCriticalRight = qFloor (0.5 + qAcos (radiusCircle / radiusProjection) *
RADIANS_TO_DEGREES);
75 int angleCriticalUp = qFloor (0.5 + qAsin (radiusCircle / radiusProjection) *
RADIANS_TO_DEGREES);
77 for (
int angle = 0; angle <= 360; angle += angleStep) {
79 double xStart = radiusCircle * cos (angle *
PI / 180.0);
80 double yStart = radiusCircle * sin (angle *
PI / 180.0);
81 double xStop = -1.0 * xStart;
82 double yStop = -1.0 * yStart;
84 double xMin = qMin (xStart, xStop);
85 double yMin = qMin (yStart, yStop);
86 double xMax = qMax (xStart, xStop);
87 double yMax = qMax (yStart, yStop);
98 &projectedDistanceOutsideLineRight,
103 if ((angleCriticalRight <= angle && angle <= 180 - angleCriticalRight) ||
104 (180 + angleCriticalRight <= angle && angle <= 360 - angleCriticalRight)) {
106 QVERIFY ((projectedDistanceOutsideLineRight == 0));
108 QVERIFY ((projectedDistanceOutsideLineRight != 0));
110 QVERIFY ((xMin <= xProjectionRight));
111 QVERIFY ((yMin <= yProjectionRight));
112 QVERIFY ((xProjectionRight <= xMax));
113 QVERIFY ((yProjectionRight <= yMax));
124 &projectedDistanceOutsideLineUp,
129 if ((angle <= angleCriticalUp) ||
130 (180 - angleCriticalUp <= angle && angle <= 180 + angleCriticalUp) ||
131 (360 - angleCriticalUp <= angle)) {
133 QVERIFY ((projectedDistanceOutsideLineUp == 0));
135 QVERIFY ((projectedDistanceOutsideLineUp != 0));
137 QVERIFY ((xMin <= xProjectionUp));
138 QVERIFY ((yMin <= yProjectionUp));
139 QVERIFY ((xProjectionUp <= xMax));
140 QVERIFY ((yProjectionUp <= yMax));
void initializeLogging(const QString &name, const QString &filename, bool isDebug)
const bool NO_EXPORT_ONLY
const QStringList NO_COMMAND_LINE
const QString NO_EXTRACT_IMAGE_EXTENSION
const QString NO_ERROR_REPORT_LOG_FILE
const bool NO_GNUPLOT_LOG_FILES
const QString NO_REGRESSION_OPEN_FILE
const QStringList NO_LOAD_STARTUP_FILES
const bool NO_REGRESSION_IMPORT
const bool NO_EXTRACT_IMAGE_ONLY
const bool NO_DROP_REGRESSION
const double RADIANS_TO_DEGREES
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Unit test of spline library.
TestProjectedPoint(QObject *parent=0)
Single constructor.
void projectPointOntoLine(double xToProject, double yToProject, double xStart, double yStart, double xStop, double yStop, double *xProjection, double *yProjection, double *projectedDistanceOutsideLine, double *distanceToLine)
Find the projection of a point onto a line segment such that the line through the point and its proje...