summaryrefslogtreecommitdiff
path: root/src/positioning/qdoublevector3d.cpp
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@digia.com>2013-11-14 16:01:26 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-20 11:22:40 +0100
commit9e1a01b2050cf844027df670cedeab1423a10db8 (patch)
tree8c6aa842383a245c8d0db7589bd39e54363280f4 /src/positioning/qdoublevector3d.cpp
parentb066db2208c976a66f08fbae33e37de94da9c89b (diff)
downloadqtlocation-9e1a01b2050cf844027df670cedeab1423a10db8.tar.gz
Add constexpr to Vector classes
This turns code like QDoublVector2D(1,1) into a compile-time expression when using a C++11 compiler. Since these classes are private some member functions were converted into inlines to make maximum use of constexpr. Keyword inline was added where function declaration was not exhibiting the keyword but the declaration was using it. Under certain circumstances this can prevent potential export/import issues on some compilers. Change-Id: I1b35b03942c5939fbafe2819fc875ef96eacaf02 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
Diffstat (limited to 'src/positioning/qdoublevector3d.cpp')
-rw-r--r--src/positioning/qdoublevector3d.cpp43
1 files changed, 0 insertions, 43 deletions
diff --git a/src/positioning/qdoublevector3d.cpp b/src/positioning/qdoublevector3d.cpp
index c4e2cf61..621a2ec5 100644
--- a/src/positioning/qdoublevector3d.cpp
+++ b/src/positioning/qdoublevector3d.cpp
@@ -40,27 +40,12 @@
****************************************************************************/
#include "qdoublevector3d_p.h"
-#include "qdoublevector2d_p.h"
#include <QtCore/qdatastream.h>
#include <QtCore/qmath.h>
#include <QtCore/qdebug.h>
QT_BEGIN_NAMESPACE
-QDoubleVector3D::QDoubleVector3D(const QDoubleVector2D &vector)
-{
- xp = vector.xp;
- yp = vector.yp;
- zp = 0.0;
-}
-
-QDoubleVector3D::QDoubleVector3D(const QDoubleVector2D &vector, double zpos)
-{
- xp = vector.xp;
- yp = vector.yp;
- zp = zpos;
-}
-
QDoubleVector3D QDoubleVector3D::normalized() const
{
// Need some extra precision if the length is very small.
@@ -91,18 +76,6 @@ void QDoubleVector3D::normalize()
zp /= len;
}
-double QDoubleVector3D::dotProduct(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
-{
- return v1.xp * v2.xp + v1.yp * v2.yp + v1.zp * v2.zp;
-}
-
-QDoubleVector3D QDoubleVector3D::crossProduct(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
-{
- return QDoubleVector3D(v1.yp * v2.zp - v1.zp * v2.yp,
- v1.zp * v2.xp - v1.xp * v2.zp,
- v1.xp * v2.yp - v1.yp * v2.xp);
-}
-
QDoubleVector3D QDoubleVector3D::normal(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
{
return crossProduct(v1, v2).normalized();
@@ -115,12 +88,6 @@ QDoubleVector3D QDoubleVector3D::normal
}
double QDoubleVector3D::distanceToPlane
- (const QDoubleVector3D &plane, const QDoubleVector3D &normal) const
-{
- return dotProduct(*this - plane, normal);
-}
-
-double QDoubleVector3D::distanceToPlane
(const QDoubleVector3D &plane1, const QDoubleVector3D &plane2, const QDoubleVector3D &plane3) const
{
QDoubleVector3D n = normal(plane2 - plane1, plane3 - plane1);
@@ -136,21 +103,11 @@ double QDoubleVector3D::distanceToLine
return (*this - p).length();
}
-QDoubleVector2D QDoubleVector3D::toVector2D() const
-{
- return QDoubleVector2D(xp, yp);
-}
-
double QDoubleVector3D::length() const
{
return qSqrt(xp * xp + yp * yp + zp * zp);
}
-double QDoubleVector3D::lengthSquared() const
-{
- return xp * xp + yp * yp + zp * zp;
-}
-
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QDoubleVector3D &vector)