swift
Loading...
Searching...
No Matches
coordinategeodetic.cpp
1// SPDX-FileCopyrightText: Copyright (C) 2013 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
5
6#include <cmath>
7
8#include <QStringBuilder>
9#include <QtGlobal>
10
11#include "misc/logmessage.h"
12#include "misc/verify.h"
13
14using namespace swift::misc::aviation;
15using namespace swift::misc::physical_quantities;
16using namespace swift::misc::math;
17
18SWIFT_DEFINE_VALUEOBJECT_MIXINS(swift::misc::geo, CCoordinateGeodetic)
19
20namespace swift::misc::geo
21{
26
27 CCoordinateGeodetic CCoordinateGeodetic::fromWgs84(const QString &latitudeWgs84, const QString &longitudeWgs84,
29 {
30 const CLatitude lat = CLatitude::fromWgs84(latitudeWgs84);
31 const CLongitude lon = CLongitude::fromWgs84(longitudeWgs84);
32 return { lat, lon, geodeticHeight };
33 }
34
36 {
37 static const CCoordinateGeodetic n;
38 return n;
39 }
40
41 CLength calculateGreatCircleDistance(const ICoordinateGeodetic &coordinate1, const ICoordinateGeodetic &coordinate2)
42 {
43 if (coordinate1.isNull() || coordinate2.isNull())
44 {
45 return CLength::null();
46 }
47 // if (coordinate1.equalNormalVectorDouble(coordinate2)) { return CLength(0, CLengthUnit::defaultUnit()); }
48 constexpr float earthRadiusMeters = 6371000.8f;
49
50 const QVector3D v1 = coordinate1.normalVector();
51 const QVector3D v2 = coordinate2.normalVector();
52 Q_ASSERT_X(std::isfinite(v1.x()) && std::isfinite(v1.y()) && std::isfinite(v1.z()), Q_FUNC_INFO,
53 "Distance calculation: v1 non-finite argument");
54 Q_ASSERT_X(std::isfinite(v2.x()) && std::isfinite(v2.y()) && std::isfinite(v2.z()), Q_FUNC_INFO,
55 "Distance calculation: v2 non-finite argument");
56
57 const float d =
58 earthRadiusMeters * std::atan2(QVector3D::crossProduct(v1, v2).length(), QVector3D::dotProduct(v1, v2));
59
60 SWIFT_VERIFY_X(!std::isnan(d), Q_FUNC_INFO, "Distance calculation: NaN in result");
61 if (std::isnan(d))
62 {
63 CLogMessage().debug(u"Distance calculation: NaN in result (given arguments %1 %2 %3; %4 %5 %6)")
64 << static_cast<double>(v1.x()) << static_cast<double>(v1.y()) << static_cast<double>(v1.z())
65 << static_cast<double>(v2.x()) << static_cast<double>(v2.y()) << static_cast<double>(v2.z());
66 return CLength::null();
67 }
68 return { static_cast<double>(d), CLengthUnit::m() };
69 }
70
71 CAngle calculateBearing(const ICoordinateGeodetic &coordinate1, const ICoordinateGeodetic &coordinate2)
72 {
73 if (coordinate1.isNull() || coordinate2.isNull())
74 {
75 return CAngle::null();
76 }
77 // if (coordinate1.equalNormalVectorDouble(coordinate2)) { return CAngle(0, CAngleUnit::defaultUnit()); } //
78 // null or 0?
79 static const QVector3D northPole { 0, 0, 1 };
80 const QVector3D c1 = QVector3D::crossProduct(coordinate1.normalVector(), coordinate2.normalVector());
81 const QVector3D c2 = QVector3D::crossProduct(coordinate1.normalVector(), northPole);
82 const QVector3D cross = QVector3D::crossProduct(c1, c2);
83 const float sinTheta = std::copysign(cross.length(), QVector3D::dotProduct(cross, coordinate1.normalVector()));
84 const float cosTheta = QVector3D::dotProduct(c1, c2);
85 const float theta = std::atan2(sinTheta, cosTheta);
86 return { static_cast<double>(theta), CAngleUnit::rad() };
87 }
88
89 double calculateEuclideanDistance(const ICoordinateGeodetic &coordinate1, const ICoordinateGeodetic &coordinate2)
90 {
91 return static_cast<double>(coordinate1.normalVector().distanceToPoint(coordinate2.normalVector()));
92 }
93
94 double calculateEuclideanDistanceSquared(const ICoordinateGeodetic &coordinate1,
95 const ICoordinateGeodetic &coordinate2)
96 {
97 return static_cast<double>((coordinate1.normalVector() - coordinate2.normalVector()).lengthSquared());
98 }
99
100 bool ICoordinateGeodetic::equalNormalVectorDouble(const std::array<double, 3> &otherVector) const
101 {
102 static const double epsilon = std::numeric_limits<double>::epsilon();
103 const std::array<double, 3> thisVector = this->normalVectorDouble();
104 for (unsigned int i = 0; i < otherVector.size(); i++)
105 {
106 const double d = thisVector[i] - otherVector[i];
107 if (qAbs(d) > epsilon)
108 {
109 return false;
110 }
111 }
112 return true;
113 }
114
116 {
117 return this->equalNormalVectorDouble(otherCoordinate.normalVectorDouble());
118 }
119
121 {
122 return geo::calculateGreatCircleDistance((*this), otherCoordinate);
123 }
124
125 bool ICoordinateGeodetic::isWithinRange(const ICoordinateGeodetic &otherCoordinate, const CLength &range) const
126 {
127 if (range.isNull())
128 {
129 return false;
130 }
131 const CLength distance = this->calculateGreatCircleDistance(otherCoordinate);
132 if (distance.isNull())
133 {
134 return false;
135 }
136 return distance <= range;
137 }
138
140 {
141 return geo::calculateBearing((*this), otherCoordinate);
142 }
143
145 {
146 const int i = index.frontCasted<int>();
147 return (i >= static_cast<int>(IndexLatitude)) && (i <= static_cast<int>(IndexNormalVector));
148 }
149
151 {
152 if (!index.isMyself())
153 {
154 const auto i = index.frontCasted<ColumnIndex>();
155 switch (i)
156 {
157 case IndexLatitude: return this->latitude().propertyByIndex(index.copyFrontRemoved());
158 case IndexLongitude: return this->longitude().propertyByIndex(index.copyFrontRemoved());
159 case IndexLatitudeAsString: return { this->latitudeAsString() };
160 case IndexLongitudeAsString: return { this->longitudeAsString() };
161 case IndexGeodeticHeight: return this->geodeticHeight().propertyByIndex(index.copyFrontRemoved());
162 case IndexGeodeticHeightAsString: return { this->geodeticHeightAsString() };
163 case IndexNormalVector: return QVariant::fromValue(this->normalVector());
164 default: break;
165 }
166 }
167
168 const QString m = QString("no property, index ").append(index.toQString());
169 SWIFT_VERIFY_X(false, Q_FUNC_INFO, qUtf8Printable(m));
170 return QVariant::fromValue(m);
171 }
172
174 const ICoordinateGeodetic &compareValue) const
175 {
176 if (!index.isMyself())
177 {
178 const auto i = index.frontCasted<ColumnIndex>();
179 switch (i)
180 {
181 case IndexLatitude:
182 return this->latitude().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.latitude());
183 case IndexLongitude:
184 return this->longitude().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.longitude());
185 case IndexLatitudeAsString: return this->latitudeAsString().compare(compareValue.latitudeAsString());
186 case IndexLongitudeAsString: return this->longitudeAsString().compare(compareValue.longitudeAsString());
187 case IndexGeodeticHeight:
189 compareValue.geodeticHeight());
190 case IndexGeodeticHeightAsString:
191 return this->geodeticHeightAsString().compare(compareValue.geodeticHeightAsString());
192 default: break;
193 }
194 }
195
196 const QString m = QString("no property, index ").append(index.toQString());
197 SWIFT_VERIFY_X(false, Q_FUNC_INFO, qUtf8Printable(m));
198 return 0;
199 }
200
202 {
203 const CLatitude lat = this->latitude();
204 const CLongitude lng = this->longitude();
205 return QStringLiteral("Geodetic: {%1/%2, %3/%4, %5}")
206 .arg(lat.valueRoundedWithUnit(CAngleUnit::deg(), 6, i18n),
210 this->geodeticHeight().valueRoundedWithUnit(CLengthUnit::ft(), 2, i18n));
211 }
212
214 {
215 const QVector3D v = this->normalVector();
216 return std::isnan(v.x()) || std::isnan(v.y()) || std::isnan(v.z());
217 }
218
220 {
221 const std::array<double, 3> v = this->normalVectorDouble();
222 return std::isnan(v[0]) || std::isnan(v[1]) || std::isnan(v[2]);
223 }
224
226 {
227 const QVector3D v = this->normalVector();
228 return std::isinf(v.x()) || std::isinf(v.y()) || std::isinf(v.z());
229 }
230
232 {
233 const std::array<double, 3> v = this->normalVectorDouble();
234 return std::isinf(v[0]) || std::isinf(v[1]) || std::isinf(v[2]);
235 }
236
238 {
239 // inf is out of range, comparing nans is always false
240 const std::array<double, 3> v = this->normalVectorDouble();
241 return isValidVector(v);
242 }
243
244 bool ICoordinateGeodetic::isValidVector(const std::array<double, 3> &v)
245 {
246 constexpr double l = 1.00001; // because of interpolation
247 return v[0] <= l && v[1] <= l && v[2] <= l && v[0] >= -l && v[1] >= -l && v[2] >= -l;
248 }
249
251 {
252 int c = 0;
253 if (m_x < -1.0)
255 m_x = -1.0;
256 c++;
258 else if (m_x > 1.0)
259 {
260 m_x = 1.0;
261 c++;
262 }
263 if (m_y < -1.0)
264 {
265 m_y = -1.0;
266 c++;
267 }
268 else if (m_y > 1.0)
269 {
270 m_y = 1.0;
271 c++;
272 }
273 if (m_z < -1.0)
274 {
275 m_z = -1.0;
276 c++;
277 }
278 else if (m_z > 1.0)
279 {
280 m_z = 1.0;
281 c++;
282 }
283 return c;
284 }
285
295
297 {
298 if (index.isMyself())
299 {
300 (*this) = variant.value<CCoordinateGeodetic>();
301 return;
302 }
303 const auto i = index.frontCasted<ICoordinateGeodetic::ColumnIndex>();
304 switch (i)
305 {
306 case IndexGeodeticHeight: m_geodeticHeight.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
307 case IndexLatitude: this->setLatitude(variant.value<CLatitude>()); break;
308 case IndexLongitude: this->setLongitude(variant.value<CLongitude>()); break;
309 case IndexLatitudeAsString: this->setLatitude(CLatitude::fromWgs84(variant.toString())); break;
310 case IndexLongitudeAsString: this->setLongitude(CLongitude::fromWgs84(variant.toString())); break;
311 case IndexGeodeticHeightAsString: m_geodeticHeight.parseFromString(variant.toString()); break;
312 case IndexNormalVector: this->setNormalVector(variant.value<QVector3D>()); break;
313 default: CValueObject::setPropertyByIndex(index, variant); break;
314 }
315 }
316
318 const CCoordinateGeodetic &compareValue) const
319 {
322 CValueObject::comparePropertyByIndex(index, compareValue);
323 }
324
326 {
327 this->setNormalVector(normalVector);
328 }
329
335
338 : m_x(latitude.cos() * longitude.cos()), m_y(latitude.cos() * longitude.sin()), m_z(latitude.sin()),
339 m_geodeticHeight(geodeticHeight)
340 {}
341
342 CCoordinateGeodetic::CCoordinateGeodetic(double latitudeDegrees, double longitudeDegrees)
343 : CCoordinateGeodetic({ latitudeDegrees, CAngleUnit::deg() }, { longitudeDegrees, CAngleUnit::deg() },
344 { 0, nullptr })
345 {}
346
347 CCoordinateGeodetic::CCoordinateGeodetic(double latitudeDegrees, double longitudeDegrees, double heightFeet)
348 : CCoordinateGeodetic({ latitudeDegrees, CAngleUnit::deg() }, { longitudeDegrees, CAngleUnit::deg() },
349 { heightFeet, CLengthUnit::ft() })
350 {}
351
353 : m_geodeticHeight(coordinate.geodeticHeight())
354 {
355 this->setNormalVector(coordinate.normalVectorDouble());
356 }
357
359 {
360 if (this->isNull())
361 {
363 }
364 if (distance.isNull() || distance.isNegativeWithEpsilonConsidered() || relBearing.isNull())
365 {
367 }
368 if (distance.isZeroEpsilonConsidered())
369 {
370 return *this;
371 }
372
373 // http://www.movable-type.co.uk/scripts/latlong.html#destPoint
374 // https://stackoverflow.com/a/879531/356726
375 // https://www.cosmocode.de/en/blog/gohr/2010-06/29-calculate-a-destination-coordinate-based-on-distance-and-bearing-in-php
376 constexpr double earthRadiusMeters = 6371000.8;
377 const double startLatRad = this->latitude().value(CAngleUnit::rad());
378 const double startLngRad = this->longitude().value(CAngleUnit::rad());
379 const double bearingRad = relBearing.value(CAngleUnit::rad());
380 const double distRatio = distance.value(CLengthUnit::m()) / earthRadiusMeters;
381
382 const double newLatRad =
383 asin(sin(startLatRad) * cos(distRatio) + cos(startLatRad) * sin(distRatio) * cos(bearingRad));
384 double newLngRad = 0;
385
386 constexpr double epsilon = 1E-06;
387 if (cos(newLatRad) == 0 || qAbs(cos(newLatRad)) < epsilon)
388 newLngRad = startLngRad;
389 else
390 {
391 // λ1 + Math.atan2(Math.sin(brng)*Math.sin(d/R)*Math.cos(φ1), Math.cos(d/R)-Math.sin(φ1)*Math.sin(φ2));
392 newLngRad = startLngRad + atan2(sin(bearingRad) * sin(distRatio) * cos(startLatRad),
393 cos(distRatio) - sin(startLatRad) * sin(newLatRad));
394 newLngRad = fmod(newLngRad + 3 * M_PI, 2 * M_PI) - M_PI; // normalize +-180deg
395 }
396
397 CCoordinateGeodetic copy = *this;
398 const CLatitude lat(newLatRad, CAngleUnit::rad());
399 const CLongitude lng(newLngRad, CAngleUnit::rad());
400 copy.setLatLong(lat, lng);
401 return copy;
402 }
403
405 {
406 return { std::atan2(m_z, std::hypot(m_x, m_y)), CAngleUnit::rad() };
407 }
408
410 {
411 // in mathematics atan2 of 0,0 is undefined, with IEEE floating-point atan2(0,0) is either 0 or ±180°
412 return { std::atan2(m_y, m_x), CAngleUnit::rad() };
413 }
414
416 {
417 return { static_cast<float>(m_x), static_cast<float>(m_y), static_cast<float>(m_z) };
418 }
419
420 std::array<double, 3> CCoordinateGeodetic::normalVectorDouble() const { return { { m_x, m_y, m_z } }; }
421
422 void CCoordinateGeodetic::setLatitude(const CLatitude &latitude) { this->setLatLong(latitude, this->longitude()); }
423
425
427 {
428 this->setLatLong(this->latitude(), longitude);
429 }
430
435
437 {
438 m_x = latitude.cos() * longitude.cos();
439 m_y = latitude.cos() * longitude.sin();
440 m_z = latitude.sin();
441 }
442
444 {
445 this->setLatitudeFromWgs84(latitude);
446 this->setLongitudeFromWgs84(longitude);
447 }
448
450
451 void CCoordinateGeodetic::setNormalVector(const std::array<double, 3> &normalVector)
452 {
453 Q_ASSERT_X(normalVector.size() == 3, Q_FUNC_INFO, "Wrong vector size");
454 m_x = normalVector[0];
455 m_y = normalVector[1];
456 m_z = normalVector[2];
457 }
458
460 {
461 m_geodeticHeight.switchUnit(unit);
462 return *this;
463 }
464
466 {
467 m_relativeDistance = geo::calculateGreatCircleDistance(*this, position);
468 return m_relativeDistance;
469 }
470
471 CLength
473 {
474 m_relativeDistance = geo::calculateGreatCircleDistance(*this, position);
475 m_relativeBearing = geo::calculateBearing(*this, position);
476 return m_relativeDistance;
477 }
478
480 {
482 {
484 }
485 if (!index.isMyself())
486 {
487 const auto i = index.frontCasted<ColumnIndex>();
488 switch (i)
489 {
490 case IndexRelativeBearing: return this->getRelativeBearing().propertyByIndex(index.copyFrontRemoved());
491 case IndexRelativeDistance: return this->getRelativeDistance().propertyByIndex(index.copyFrontRemoved());
492 default: break;
493 }
494 }
495 const QString m = QString("no property, index ").append(index.toQString());
496 SWIFT_VERIFY_X(false, Q_FUNC_INFO, qUtf8Printable(m));
497 return QVariant::fromValue(m);
498 }
499
501 {
503 {
504 return;
505 }
506 if (!index.isMyself())
507 {
508 const auto i = index.frontCasted<ColumnIndex>();
509 switch (i)
510 {
511 case IndexRelativeBearing: m_relativeBearing.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
512 case IndexRelativeDistance: m_relativeDistance.setPropertyByIndex(index.copyFrontRemoved(), variant); break;
513 default:
514 const QString m = QString("no property, index ").append(index.toQString());
515 SWIFT_VERIFY_X(false, Q_FUNC_INFO, qUtf8Printable(m));
516 break;
517 }
518 }
519 }
520
521 int
523 const ICoordinateWithRelativePosition &compareValue) const
524 {
526 {
527 return ICoordinateGeodetic::comparePropertyByIndex(index, compareValue);
528 }
529 if (!index.isMyself())
530 {
531 const auto i = index.frontCasted<ColumnIndex>();
532 switch (i)
533 {
534 case IndexRelativeBearing:
535 return m_relativeBearing.comparePropertyByIndex(index.copyFrontRemoved(),
536 compareValue.getRelativeBearing());
537 case IndexRelativeDistance:
538 return m_relativeDistance.comparePropertyByIndex(index.copyFrontRemoved(),
539 compareValue.getRelativeDistance());
540 default:
541 const QString m = QString("no property, index ").append(index.toQString());
542 Q_ASSERT_X(false, Q_FUNC_INFO, m.toLocal8Bit().constData());
543 Q_UNUSED(m)
544 break;
545 }
546 }
547 return 0;
548 }
549
551 {
552 return m_relativeBearing.toQString(i18n) % u' ' % m_relativeDistance.toQString(i18n) % u' ' %
554 }
555
557 {
559 {
560 return true;
561 }
562 const int i = index.frontCasted<int>();
563 return (i >= static_cast<int>(IndexRelativeDistance)) && (i <= static_cast<int>(IndexRelativeBearing));
564 }
565} // namespace swift::misc::geo
static CAngleUnit rad()
Radians.
Definition units.h:268
static CAngleUnit deg()
Degrees.
Definition units.h:276
Class for emitting a log message.
Definition logmessage.h:27
Derived & debug()
Set the severity to debug.
Non-owning reference to a CPropertyIndex with a subset of its features.
Q_REQUIRED_RESULT CPropertyIndexRef copyFrontRemoved() const
Copy with first element removed.
QString toQString(bool i18n=false) const
Cast as QString.
CastType frontCasted() const
First element casted to given type, usually the PropertIndex enum.
bool isMyself() const
Myself index, used with nesting.
Altitude as used in aviation, can be AGL or MSL altitude.
Definition altitude.h:52
int comparePropertyByIndex(CPropertyIndexRef index, const CAltitude &compareValue) const
Set property by index.
Definition altitude.cpp:117
static const CAltitude & null()
Null altitude (MSL).
Definition altitude.cpp:511
int comparePropertyByIndex(CPropertyIndexRef index, const CCoordinateGeodetic &compareValue) const
Set property by index.
void setLatLongFromWgs84(const QString &latitude, const QString &longitude)
Set latitude and longitude.
void setLatitude(const CLatitude &latitude)
Set latitude.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
static const CCoordinateGeodetic & null()
null coordinate
int clampVector()
Clamp vector values if out [-1, 1].
std::array< double, 3 > normalVectorDouble() const
Normal vector with double precision.
CCoordinateGeodetic()=default
Default constructor (null coordinate).
CCoordinateGeodetic calculatePosition(const physical_quantities::CLength &distance, const physical_quantities::CAngle &relBearing) const
Calculate a position in distance/bearing.
CCoordinateGeodetic & switchUnit(const physical_quantities::CLengthUnit &unit)
Switch unit of height.
QString convertToQString(bool i18n=false) const
Cast as QString.
static CCoordinateGeodetic fromWgs84(const QString &latitudeWgs84, const QString &longitudeWgs84, const aviation::CAltitude &geodeticHeight={})
Coordinate by WGS84 position data.
void setGeodeticHeightToNull()
Set height to NULL.
void setGeodeticHeight(const aviation::CAltitude &height)
Set height (ellipsoidal or geodetic height).
const aviation::CAltitude & geodeticHeight() const
Height, ellipsoidal or geodetic height (used in GPS).
void setLatLong(const CLatitude &latitude, const CLongitude &longitude)
Set latitude and longitude.
QVector3D normalVector() const
Normal vector.
void setNormalVector(const QVector3D &normal)
Set normal vector.
void setLatitudeFromWgs84(const QString &wgs)
Set latitude.
void setLongitudeFromWgs84(const QString &wgs)
Set longitude.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
void setLongitude(const CLongitude &longitude)
Set longitude.
static CLatitude fromWgs84(const QString &wgsCoordinate)
Geodetic coordinate, a position in 3D space relative to the reference geoid.
static bool isValidVector(const std::array< double, 3 > &v)
Check values.
virtual QVector3D normalVector() const =0
Normal vector.
int comparePropertyByIndex(CPropertyIndexRef index, const ICoordinateGeodetic &compareValue) const
Compare for index.
physical_quantities::CLength calculateGreatCircleDistance(const ICoordinateGeodetic &otherCoordinate) const
Great circle distance.
QString convertToQString(bool i18n=false) const
Cast as QString.
virtual CLongitude longitude() const =0
Longitude.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
bool equalNormalVectorDouble(const std::array< double, 3 > &otherVector) const
Is equal? Epsilon considered.
virtual const aviation::CAltitude & geodeticHeight() const =0
Height, ellipsoidal or geodetic height (used in GPS).
physical_quantities::CAngle calculateBearing(const ICoordinateGeodetic &otherCoordinate) const
Initial bearing.
static bool canHandleIndex(CPropertyIndexRef index)
Can given index be handled?
QString longitudeAsString() const
Longitude as string.
virtual bool isNull() const
Is null, means vector x, y, z == 0.
bool isWithinRange(const ICoordinateGeodetic &otherCoordinate, const physical_quantities::CLength &range) const
Object within range?
virtual std::array< double, 3 > normalVectorDouble() const =0
Normal vector with double precision.
QString latitudeAsString() const
Latitude as string.
QString geodeticHeightAsString() const
Height as string.
virtual CLatitude latitude() const =0
Latitude.
static bool canHandleIndex(CPropertyIndexRef index)
Can given index be handled?
const physical_quantities::CLength & getRelativeDistance() const
Get the distance.
physical_quantities::CAngle m_relativeBearing
temporary stored value
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
physical_quantities::CLength calculcateAndUpdateRelativeDistance(const geo::ICoordinateGeodetic &position)
Calculcate distance, set it, and return distance.
physical_quantities::CLength m_relativeDistance
temporary stored value
physical_quantities::CLength calculcateAndUpdateRelativeDistanceAndBearing(const geo::ICoordinateGeodetic &position)
Calculcate distance and bearing to plane, set it, and return distance.
int comparePropertyByIndex(CPropertyIndexRef index, const ICoordinateWithRelativePosition &compareValue) const
Compare for index.
QString convertToQString(bool i18n=false) const
Cast as QString.
const physical_quantities::CAngle & getRelativeBearing() const
Get the relative bearing.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
int comparePropertyByIndex(CPropertyIndexRef index, const Derived &compareValue) const
Compare for index.
Definition mixinindex.h:203
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
Definition mixinindex.h:167
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
Definition mixinindex.h:180
Physical unit angle (radians, degrees).
Definition angle.h:23
Physical unit length (length).
Definition length.h:18
Specialized class for distance units (meter, foot, nautical miles).
Definition units.h:95
static CLengthUnit m()
Meter m.
Definition units.h:140
static CLengthUnit ft()
Foot ft.
Definition units.h:157
bool isNegativeWithEpsilonConsidered() const
Value <= 0 epsilon considered.
double value(MU unit) const
Value in given unit.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
QString valueRoundedWithUnit(const MU &unit, int digits=-1, bool withGroupSeparator=false, bool i18n=false) const
Value to QString with the given unit, e.g. "5.00m".
bool isZeroEpsilonConsidered() const
Quantity value <= epsilon.
const char * constData() const const
QString & append(QChar ch)
int compare(QLatin1StringView s1, const QString &s2, Qt::CaseSensitivity cs)
QByteArray toLocal8Bit() const const
QVariant fromValue(T &&value)
QString toString() const const
T value() const &const
QVector3D crossProduct(QVector3D v1, QVector3D v2)
float dotProduct(QVector3D v1, QVector3D v2)
float length() const const
float x() const const
float y() const const
float z() const const
#define SWIFT_DEFINE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template definition of mixins for a CValueObject subclass.
Definition valueobject.h:67
#define SWIFT_VERIFY_X(COND, WHERE, WHAT)
A weaker kind of assert.
Definition verify.h:26