5#include <QtTest/QtTest>
19void TestProjectedPoint::cleanupTestCase ()
24void TestProjectedPoint::initTestCase ()
31 const bool NO_RESET =
false;
57void TestProjectedPoint::testProjectedPoints ()
59 double radiusCircle = 1.0, radiusProjection = 2.0 * radiusCircle;
60 double xToProjectRight = radiusProjection, yToProjectRight = 0.0;
61 double xToProjectUp = 0.0, yToProjectUp = 2.0 * radiusCircle;
62 double xProjectionRight, yProjectionRight, projectedDistanceOutsideLineRight;
63 double xProjectionUp, yProjectionUp, projectedDistanceOutsideLineUp;
64 double distanceToLine;
71 int angleCriticalRight = qFloor (0.5 + qRadiansToDegrees (qAcos (radiusCircle / radiusProjection)));
72 int angleCriticalUp = qFloor (0.5 + qRadiansToDegrees (qAsin (radiusCircle / radiusProjection)));
74 for (
int angle = 0; angle <= 360; angle += angleStep) {
76 double xStart = radiusCircle * cos (qDegreesToRadians ((
double) angle));
77 double yStart = radiusCircle * sin (qDegreesToRadians ((
double) angle));
78 double xStop = -1.0 * xStart;
79 double yStop = -1.0 * yStart;
81 double xMin = qMin (xStart, xStop);
82 double yMin = qMin (yStart, yStop);
83 double xMax = qMax (xStart, xStop);
84 double yMax = qMax (yStart, yStop);
95 &projectedDistanceOutsideLineRight,
100 if ((angleCriticalRight <= angle && angle <= 180 - angleCriticalRight) ||
101 (180 + angleCriticalRight <= angle && angle <= 360 - angleCriticalRight)) {
103 QVERIFY ((projectedDistanceOutsideLineRight == 0));
105 QVERIFY ((projectedDistanceOutsideLineRight != 0));
107 QVERIFY ((xMin <= xProjectionRight));
108 QVERIFY ((yMin <= yProjectionRight));
109 QVERIFY ((xProjectionRight <= xMax));
110 QVERIFY ((yProjectionRight <= yMax));
121 &projectedDistanceOutsideLineUp,
126 if ((angle <= angleCriticalUp) ||
127 (180 - angleCriticalUp <= angle && angle <= 180 + angleCriticalUp) ||
128 (360 - angleCriticalUp <= angle)) {
130 QVERIFY ((projectedDistanceOutsideLineUp == 0));
132 QVERIFY ((projectedDistanceOutsideLineUp != 0));
134 QVERIFY ((xMin <= xProjectionUp));
135 QVERIFY ((yMin <= yProjectionUp));
136 QVERIFY ((xProjectionUp <= xMax));
137 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
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...