Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qdoublevector3d.cpp
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
#
include
"qdoublevector3d_p.h"
6
#
include
<
QtCore
/
qdatastream
.
h
>
7
#
include
<
QtCore
/
qmath
.
h
>
8
#
include
<
QtCore
/
qdebug
.
h
>
9
10
QT_BEGIN_NAMESPACE
11
12
QDoubleVector3D QDoubleVector3D::normalized()
const
13
{
14
const
double
len = length();
15
if
(qFuzzyIsNull(len - 1.0))
16
return
*
this
;
17
else
if
(!qFuzzyIsNull(len))
18
return
*
this
/ len;
19
else
20
return
QDoubleVector3D();
21
}
22
23
void
QDoubleVector3D::normalize()
24
{
25
double
len = length();
26
if
(qFuzzyIsNull(len) || qFuzzyIsNull(len - 1.0))
27
return
;
28
29
xp /= len;
30
yp /= len;
31
zp /= len;
32
}
33
34
QDoubleVector3D QDoubleVector3D::normal(
const
QDoubleVector3D &v1,
const
QDoubleVector3D &v2)
35
{
36
return
crossProduct(v1, v2).normalized();
37
}
38
39
QDoubleVector3D QDoubleVector3D::normal
40
(
const
QDoubleVector3D &v1,
const
QDoubleVector3D &v2,
const
QDoubleVector3D &v3)
41
{
42
return
crossProduct((v2 - v1), (v3 - v1)).normalized();
43
}
44
45
double
QDoubleVector3D::distanceToPlane
46
(
const
QDoubleVector3D &plane1,
const
QDoubleVector3D &plane2,
const
QDoubleVector3D &plane3)
const
47
{
48
QDoubleVector3D n = normal(plane2 - plane1, plane3 - plane1);
49
return
dotProduct(*
this
- plane1, n);
50
}
51
52
double
QDoubleVector3D::distanceToLine
53
(
const
QDoubleVector3D &point,
const
QDoubleVector3D &direction)
const
54
{
55
if
(direction.isNull())
56
return
(*
this
- point).length();
57
QDoubleVector3D p = point + dotProduct(*
this
- point, direction) * direction;
58
return
(*
this
- p).length();
59
}
60
61
double
QDoubleVector3D::length()
const
62
{
63
return
qHypot(xp, yp, zp);
64
}
65
66
#
ifndef
QT_NO_DEBUG_STREAM
67
68
QDebug
operator
<<(QDebug dbg,
const
QDoubleVector3D &vector)
69
{
70
QDebugStateSaver saver(dbg);
71
dbg.nospace() <<
"QDoubleVector3D("
72
<< vector.x() <<
", "
<< vector.y() <<
", "
<< vector.z() <<
')'
;
73
return
dbg;
74
}
75
76
#
endif
77
78
#
ifndef
QT_NO_DATASTREAM
79
80
QDataStream
&
operator
<<(QDataStream &stream,
const
QDoubleVector3D &vector)
81
{
82
stream <<
double
(vector.x()) <<
double
(vector.y())
83
<<
double
(vector.z());
84
return
stream;
85
}
86
87
QDataStream
&
operator
>>(QDataStream &stream, QDoubleVector3D &vector)
88
{
89
double
x, y, z;
90
stream >> x;
91
stream >> y;
92
stream >> z;
93
vector.setX(
double
(x));
94
vector.setY(
double
(y));
95
vector.setZ(
double
(z));
96
return
stream;
97
}
98
99
#
endif
// QT_NO_DATASTREAM
100
101
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qrandomaccessasyncfile_darwin.mm:17
operator<<
QDataStream & operator<<(QDataStream &stream, const QDoubleVector3D &vector)
Definition
qdoublevector3d.cpp:80
operator<<
QDebug operator<<(QDebug dbg, const QDoubleVector3D &vector)
Definition
qdoublevector3d.cpp:68
operator>>
QDataStream & operator>>(QDataStream &stream, QDoubleVector3D &vector)
Definition
qdoublevector3d.cpp:87
qtpositioning
src
positioning
qdoublevector3d.cpp
Generated on
for Qt by
1.16.1