6#include <QtCore/qdatastream.h>
7#include <QtCore/qdebug.h>
8#include <QtCore/qvariant.h>
9#include <QtGui/qmatrix4x4.h>
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
34
35
36
37
40
41
42
43
44
45
48
49
50
51
52
55
56
57
58
61
62
63
64
69
70
71
72
73
74
75
82
83
84
85
86
87
88
93
94
95
96
97
100
101
102
103
104
105
108
109
110
111
112
113
116
117
118
119
120
121
124
125
126
127
128
129
132
133
134
135
136
137
138
139
142
143
144
145
146
147
148
151
152
153
154
155
156
159
160
161
162
163
164
165
168
169
170
171
172
173
174
175
176
177
180
181
182
183
184
185
186
189
190
191
192
193
194
195
196
199
200
201
202
203
204
205
206
207
208
209
212
213
214
215
216
217
218
221
222
223
224
225
226
227
230
231
232
233
234
235
236
239
240
241
242
243
244
245
246
247
248
251
252
253
254
255
256
257
260
261
262
263
264
265
266
267
268
269
272
273
274
275
278
279
280
281
282
285
286
287
288
289
292
293
294
295
296
297
298
301
302
303
304
305
306
307
310
311
312
313
314
315
318
319
320
321
322
323
326
327
328
329
330
331
332
333
334
335
338
339
340
341
342
343
344
345
348
349
350
351
352
353
354
355
356
359
360
361
362
363
364
365
366
367
368
371
372
373
374
375
378 return qFuzzyCompare(v1.v[0], v2.v[0]) && qFuzzyCompare(v1.v[1], v2.v[1]);
381#ifndef QT_NO_VECTOR3D
383
384
385
386
387
388
391#ifndef QT_NO_VECTOR4D
393
394
395
396
397
398
402
403
404
405
406
407
408
411
412
413
414
415
416
419
420
423 return QVariant::fromValue(*
this);
426#ifndef QT_NO_DEBUG_STREAM
430 QDebugStateSaver saver(dbg);
431 dbg.nospace() <<
"QVector2D(" << vector
.x() <<
", " << vector
.y() <<
')';
437#ifndef QT_NO_DATASTREAM
440
441
442
443
444
445
446
447
456
457
458
459
460
461
462
463
470 Q_ASSERT(qIsFinite(x) && qIsFinite(y));
482#ifndef QT_NO_VECTOR3D
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
502
503
504
505
508
509
510
511
512
513
516
517
518
519
520
523
524
525
526
527
530
531
532
533
534
536#ifndef QT_NO_VECTOR2D
539
540
541
542
543
544
545
548
549
550
551
552
553
554
557#ifndef QT_NO_VECTOR4D
560
561
562
563
564
565
566
571
572
573
574
575
578
579
580
581
582
583
586
587
588
589
590
591
594
595
596
597
598
599
602
603
604
605
606
607
610
611
612
613
614
615
618
619
620
621
622
623
626
627
628
629
630
631
632
633
636
637
638
639
640
641
642
645
646
647
648
649
650
651
652
653
654
657
658
659
660
661
662
663
666
667
668
669
670
671
672
675
676
677
678
679
680
681
684
685
686
687
688
689
690
693
694
695
696
697
698
699
700
701
702
703
704
707
708
709
710
711
712
713
716
717
718
719
720
721
722
723
724
725
728
729
730
731
734
735
736
737
738
739
740
741
744
745
746
747
748
749
750
751
752
753
756
757
758
759
760
761
762
763
764
765
766
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784QVector3D QVector3D::project(
const QMatrix4x4 &modelView,
const QMatrix4x4 &projection,
const QRect &viewport)
const
787 tmp = projection * modelView * tmp;
788 if (qFuzzyIsNull(tmp
.w()))
792 tmp = tmp * 0.5f + QVector4D(0.5f, 0.5f, 0.5f, 0.5f);
793 tmp
.setX(tmp
.x() * viewport.width() + viewport.x()
);
794 tmp
.setY(tmp
.y() * viewport.height() + viewport.y()
);
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815QVector3D QVector3D::unproject(
const QMatrix4x4 &modelView,
const QMatrix4x4 &projection,
const QRect &viewport)
const
817 QMatrix4x4 inverse = QMatrix4x4( projection * modelView ).inverted();
820 tmp
.setX((tmp
.x() -
float(viewport.x())) /
float(viewport.width())
);
821 tmp
.setY((tmp
.y() -
float(viewport.y())) /
float(viewport.height())
);
822 tmp = tmp * 2.0f - QVector4D(1.0f, 1.0f, 1.0f, 1.0f);
825 if (qFuzzyIsNull(obj
.w()))
832
833
834
835
836
837
838
839
840
843
844
845
846
847
848
849
850
851
852
853
856
857
858
859
860
861
862
863
864
865
866
867
868
871
872
873
874
875
876
877
878
879
880
883
884
885
886
887
890
891
892
893
894
897
898
899
900
901
902
903
906
907
908
909
910
911
912
915
916
917
918
919
920
923
924
925
926
927
928
931
932
933
934
935
936
937
938
939
940
943
944
945
946
947
948
949
950
953
954
955
956
957
958
959
960
961
964
965
966
967
968
969
970
971
972
973
976
977
978
979
980
983 return qFuzzyCompare(v1.v[0], v2.v[0]) &&
984 qFuzzyCompare(v1.v[1], v2.v[1]) &&
985 qFuzzyCompare(v1.v[2], v2.v[2]);
988#ifndef QT_NO_VECTOR2D
991
992
993
994
995
996
1000#ifndef QT_NO_VECTOR4D
1003
1004
1005
1006
1007
1008
1013
1014
1015
1016
1017
1018
1019
1022
1023
1024
1025
1026
1027
1028
1031
1032
1035 return QVariant::fromValue(*
this);
1039
1040
1041
1042
1043
1044
1047
1048
1049
1050
1051
1052
1053
1055#ifndef QT_NO_DEBUG_STREAM
1059 QDebugStateSaver saver(dbg);
1060 dbg.nospace() <<
"QVector3D("
1061 << vector
.x() <<
", " << vector
.y() <<
", " << vector
.z() <<
')';
1067#ifndef QT_NO_DATASTREAM
1070
1071
1072
1073
1074
1075
1076
1077
1086
1087
1088
1089
1090
1091
1092
1093
1101 Q_ASSERT(qIsFinite(x) && qIsFinite(y) && qIsFinite(z));
1114#ifndef QT_NO_VECTOR4D
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1134
1135
1136
1137
1140
1141
1142
1143
1144
1145
1148
1149
1150
1151
1152
1155
1156
1157
1158
1159
1162
1163
1164
1165
1166
1168#ifndef QT_NO_VECTOR2D
1171
1172
1173
1174
1175
1176
1177
1180
1181
1182
1183
1184
1185
1186
1187
1191#ifndef QT_NO_VECTOR3D
1194
1195
1196
1197
1198
1199
1200
1203
1204
1205
1206
1207
1208
1209
1214
1215
1216
1217
1218
1221
1222
1223
1224
1225
1226
1229
1230
1231
1232
1233
1234
1237
1238
1239
1240
1241
1242
1245
1246
1247
1248
1249
1250
1253
1254
1255
1256
1257
1258
1261
1262
1263
1264
1265
1266
1269
1270
1271
1272
1273
1274
1277
1278
1279
1280
1281
1282
1285
1286
1287
1288
1289
1290
1291
1292
1295
1296
1297
1298
1299
1300
1301
1304
1305
1306
1307
1308
1309
1312
1313
1314
1315
1316
1317
1318
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1333
1334
1335
1336
1337
1338
1339
1343
1344
1345
1346
1347
1348
1349
1352
1353
1354
1355
1356
1357
1358
1361
1362
1363
1364
1365
1366
1367
1370
1371
1372
1373
1374
1375
1376
1379
1380
1381
1382
1383
1384
1385
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1400
1401
1402
1403
1406
1407
1408
1409
1410
1413
1414
1415
1416
1417
1420
1421
1422
1423
1424
1425
1426
1429
1430
1431
1432
1433
1434
1435
1438
1439
1440
1441
1442
1443
1446
1447
1448
1449
1450
1451
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1466
1467
1468
1469
1470
1471
1472
1473
1476
1477
1478
1479
1480
1481
1482
1483
1484
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1499
1500
1501
1502
1503
1506 return qFuzzyCompare(v1.v[0], v2.v[0]) &&
1507 qFuzzyCompare(v1.v[1], v2.v[1]) &&
1508 qFuzzyCompare(v1.v[2], v2.v[2]) &&
1509 qFuzzyCompare(v1.v[3], v2.v[3]);
1512#ifndef QT_NO_VECTOR2D
1515
1516
1517
1518
1519
1520
1523
1524
1525
1526
1527
1528
1529
1530
1534#ifndef QT_NO_VECTOR3D
1537
1538
1539
1540
1541
1542
1545
1546
1547
1548
1549
1550
1551
1556
1557
1558
1559
1560
1561
1562
1565
1566
1567
1568
1569
1570
1571
1574
1575
1578 return QVariant::fromValue(*
this);
1581#ifndef QT_NO_DEBUG_STREAM
1585 QDebugStateSaver saver(dbg);
1586 dbg.nospace() <<
"QVector4D("
1587 << vector
.x() <<
", " << vector
.y() <<
", "
1588 << vector
.z() <<
", " << vector
.w() <<
')';
1594#ifndef QT_NO_DATASTREAM
1597
1598
1599
1600
1601
1602
1603
1604
1614
1615
1616
1617
1618
1619
1620
1621
1630 Q_ASSERT(qIsFinite(x) && qIsFinite(y) && qIsFinite(z) && qIsFinite(w));
The QVector2D class represents a vector or vertex in 2D space.
constexpr float y() const noexcept
Returns the y coordinate of this point.
constexpr float x() const noexcept
Returns the x coordinate of this point.
constexpr void setY(float y) noexcept
Sets the y coordinate of this point to the given finite y coordinate.
constexpr void setX(float x) noexcept
Sets the x coordinate of this point to the given finite x coordinate.
The QVector3D class represents a vector or vertex in 3D space.
constexpr void setX(float x) noexcept
Sets the x coordinate of this point to the given finite x coordinate.
constexpr void setY(float y) noexcept
Sets the y coordinate of this point to the given finite y coordinate.
constexpr float y() const noexcept
Returns the y coordinate of this point.
constexpr float x() const noexcept
Returns the x coordinate of this point.
constexpr void setZ(float z) noexcept
Sets the z coordinate of this point to the given finite z coordinate.
constexpr float z() const noexcept
Returns the z coordinate of this point.
The QVector4D class represents a vector or vertex in 4D space.
constexpr void setZ(float z) noexcept
Sets the z coordinate of this point to the given finite z coordinate.
constexpr float x() const noexcept
Returns the x coordinate of this point.
constexpr void setY(float y) noexcept
Sets the y coordinate of this point to the given finite y coordinate.
constexpr float w() const noexcept
Returns the w coordinate of this point.
constexpr void setX(float x) noexcept
Sets the x coordinate of this point to the given finite x coordinate.
constexpr QVector4D & operator/=(float divisor)
Divides this vector's coordinates by the given divisor, and returns a reference to this vector.
constexpr QVector4D(QVector3D vector, float wpos) noexcept
Constructs a 4D vector from the specified 3D vector.
constexpr float y() const noexcept
Returns the y coordinate of this point.
constexpr QVector3D toVector3D() const noexcept
Returns the 3D vector form of this 4D vector, dropping the w coordinate.
constexpr float z() const noexcept
Returns the z coordinate of this point.
constexpr void setW(float w) noexcept
Sets the w coordinate of this point to the given finite w coordinate.
QDataStream & operator<<(QDataStream &stream, QVector2D vector)
QDataStream & operator<<(QDataStream &stream, QVector3D vector)
QDataStream & operator>>(QDataStream &stream, QVector2D &vector)
QDataStream & operator<<(QDataStream &stream, QVector4D vector)
QDebug operator<<(QDebug dbg, QVector2D vector)
bool qFuzzyCompare(QVector4D v1, QVector4D v2) noexcept
bool qFuzzyCompare(QVector3D v1, QVector3D v2) noexcept
QDebug operator<<(QDebug dbg, QVector4D vector)
QDebug operator<<(QDebug dbg, QVector3D vector)
QDataStream & operator>>(QDataStream &stream, QVector3D &vector)
QDataStream & operator>>(QDataStream &stream, QVector4D &vector)
bool qFuzzyCompare(QVector2D v1, QVector2D v2) noexcept