Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qdoublevector2d.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
"qdoublevector2d_p.h"
6
#
include
"qdoublevector3d_p.h"
7
#
include
<
QtCore
/
qdatastream
.
h
>
8
#
include
<
QtCore
/
qdebug
.
h
>
9
#
include
<
QtCore
/
qmath
.
h
>
10
11
QT_BEGIN_NAMESPACE
12
13
QDoubleVector2D::QDoubleVector2D(
const
QDoubleVector3D &vector) :
14
xp(vector.xp), yp(vector.yp)
15
{
16
}
17
18
double
QDoubleVector2D::length()
const
19
{
20
return
qHypot(xp, yp);
21
}
22
23
QDoubleVector2D QDoubleVector2D::normalized()
const
24
{
25
const
double
len = length();
26
if
(qFuzzyIsNull(len - 1.0))
27
return
*
this
;
28
else
if
(!qFuzzyIsNull(len))
29
return
*
this
/ len;
30
else
31
return
QDoubleVector2D();
32
}
33
34
void
QDoubleVector2D::normalize()
35
{
36
double
len = length();
37
if
(qFuzzyIsNull(len - 1.0) || qFuzzyIsNull(len))
38
return
;
39
40
xp /= len;
41
yp /= len;
42
}
43
44
QDoubleVector3D QDoubleVector2D::toVector3D()
const
45
{
46
return
QDoubleVector3D(xp, yp, 0.0);
47
}
48
49
#
ifndef
QT_NO_DEBUG_STREAM
50
51
QDebug
operator
<<(QDebug dbg,
const
QDoubleVector2D &vector)
52
{
53
QDebugStateSaver saver(dbg);
54
dbg.nospace() <<
"QDoubleVector2D("
<< vector.x() <<
", "
<< vector.y() <<
')'
;
55
return
dbg;
56
}
57
58
#
endif
59
60
#
ifndef
QT_NO_DATASTREAM
61
62
QDataStream
&
operator
<<(QDataStream &stream,
const
QDoubleVector2D &vector)
63
{
64
stream <<
double
(vector.x()) <<
double
(vector.y());
65
return
stream;
66
}
67
68
QDataStream
&
operator
>>(QDataStream &stream, QDoubleVector2D &vector)
69
{
70
double
x, y;
71
stream >> x;
72
stream >> y;
73
vector.setX(
double
(x));
74
vector.setY(
double
(y));
75
return
stream;
76
}
77
78
#
endif
// QT_NO_DATASTREAM
79
80
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
operator<<
QDebug operator<<(QDebug dbg, const QFileInfo &fi)
Definition
qfileinfo.cpp:1830
operator<<
QDataStream & operator<<(QDataStream &stream, const QImage &image)
[0]
Definition
qimage.cpp:4045
operator>>
QDataStream & operator>>(QDataStream &stream, QImage &image)
Definition
qimage.cpp:4071
qtpositioning
src
positioning
qdoublevector2d.cpp
Generated on
for Qt by
1.18.0