7#include <QtCore/qdatastream.h>
8#include <QtCore/qdebug.h>
9#include <QtCore/qvariant.h>
10#include <QtGui/qmatrix4x4.h>
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
35
36
37
38
41
42
43
44
45
46
49
50
51
52
53
56
57
58
59
62
63
64
65
70
71
72
73
74
75
76
83
84
85
86
87
88
89
94
95
96
97
98
101
102
103
104
105
106
109
110
111
112
113
114
117
118
119
120
121
122
125
126
127
128
129
130
133
134
135
136
137
138
139
140
143
144
145
146
147
148
149
152
153
154
155
156
157
160
161
162
163
164
165
166
169
170
171
172
173
174
175
176
177
178
181
182
183
184
185
186
187
190
191
192
193
194
195
196
197
200
201
202
203
204
205
206
207
208
209
210
213
214
215
216
217
218
219
222
223
224
225
226
227
228
231
232
233
234
235
236
237
240
241
242
243
244
245
246
247
248
249
252
253
254
255
256
257
258
261
262
263
264
265
266
267
268
269
270
273
274
275
276
279
280
281
282
283
286
287
288
289
290
293
294
295
296
297
298
299
302
303
304
305
306
307
308
311
312
313
314
315
316
319
320
321
322
323
324
327
328
329
330
331
332
333
334
335
336
339
340
341
342
343
344
345
346
349
350
351
352
353
354
355
356
357
360
361
362
363
364
365
366
367
368
369
372
373
374
375
376
379 return QtPrivate::fuzzyCompare(v1.v[0], v2.v[0])
380 && QtPrivate::fuzzyCompare(v1.v[1], v2.v[1]);
383#ifndef QT_NO_VECTOR3D
385
386
387
388
389
390
393#ifndef QT_NO_VECTOR4D
395
396
397
398
399
400
404
405
406
407
408
409
410
413
414
415
416
417
418
421
422
425 return QVariant::fromValue(*
this);
428#ifndef QT_NO_DEBUG_STREAM
432 QDebugStateSaver saver(dbg);
433 dbg.nospace() <<
"QVector2D(" << vector
.x() <<
", " << vector
.y() <<
')';
439#ifndef QT_NO_DATASTREAM
442
443
444
445
446
447
448
449
458
459
460
461
462
463
464
465
483#ifndef QT_NO_VECTOR3D
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
503
504
505
506
509
510
511
512
513
514
517
518
519
520
521
524
525
526
527
528
531
532
533
534
535
537#ifndef QT_NO_VECTOR2D
540
541
542
543
544
545
546
549
550
551
552
553
554
555
558#ifndef QT_NO_VECTOR4D
561
562
563
564
565
566
567
572
573
574
575
576
579
580
581
582
583
584
587
588
589
590
591
592
595
596
597
598
599
600
603
604
605
606
607
608
611
612
613
614
615
616
619
620
621
622
623
624
627
628
629
630
631
632
633
634
637
638
639
640
641
642
643
646
647
648
649
650
651
652
653
654
655
658
659
660
661
662
663
664
667
668
669
670
671
672
673
676
677
678
679
680
681
682
685
686
687
688
689
690
691
694
695
696
697
698
699
700
701
702
703
704
705
708
709
710
711
712
713
714
717
718
719
720
721
722
723
724
725
726
729
730
731
732
735
736
737
738
739
740
741
742
745
746
747
748
749
750
751
752
753
754
757
758
759
760
761
762
763
764
765
766
767
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785QVector3D QVector3D::project(
const QMatrix4x4 &modelView,
const QMatrix4x4 &projection,
const QRect &viewport)
const
788 tmp = projection * modelView * tmp;
789 if (qFuzzyIsNull(tmp
.w()))
793 tmp = tmp * 0.5f + QVector4D(0.5f, 0.5f, 0.5f, 0.5f);
794 tmp
.setX(tmp
.x() * viewport.width() + viewport.x()
);
795 tmp
.setY(tmp
.y() * viewport.height() + viewport.y()
);
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816QVector3D QVector3D::unproject(
const QMatrix4x4 &modelView,
const QMatrix4x4 &projection,
const QRect &viewport)
const
818 QMatrix4x4 inverse = QMatrix4x4( projection * modelView ).inverted();
821 tmp
.setX((tmp
.x() -
float(viewport.x())) /
float(viewport.width())
);
822 tmp
.setY((tmp
.y() -
float(viewport.y())) /
float(viewport.height())
);
823 tmp = tmp * 2.0f - QVector4D(1.0f, 1.0f, 1.0f, 1.0f);
826 if (qFuzzyIsNull(obj
.w()))
833
834
835
836
837
838
839
840
841
844
845
846
847
848
849
850
851
852
853
854
857
858
859
860
861
862
863
864
865
866
867
868
869
872
873
874
875
876
877
878
879
880
881
884
885
886
887
888
891
892
893
894
895
898
899
900
901
902
903
904
907
908
909
910
911
912
913
916
917
918
919
920
921
924
925
926
927
928
929
932
933
934
935
936
937
938
939
940
941
944
945
946
947
948
949
950
951
954
955
956
957
958
959
960
961
962
965
966
967
968
969
970
971
972
973
974
977
978
979
980
981
984 return QtPrivate::fuzzyCompare(v1.v[0], v2.v[0])
985 && QtPrivate::fuzzyCompare(v1.v[1], v2.v[1])
986 && QtPrivate::fuzzyCompare(v1.v[2], v2.v[2]);
989#ifndef QT_NO_VECTOR2D
992
993
994
995
996
997
1001#ifndef QT_NO_VECTOR4D
1004
1005
1006
1007
1008
1009
1014
1015
1016
1017
1018
1019
1020
1023
1024
1025
1026
1027
1028
1029
1032
1033
1036 return QVariant::fromValue(*
this);
1040
1041
1042
1043
1044
1045
1048
1049
1050
1051
1052
1053
1054
1056#ifndef QT_NO_DEBUG_STREAM
1060 QDebugStateSaver saver(dbg);
1061 dbg.nospace() <<
"QVector3D("
1062 << vector
.x() <<
", " << vector
.y() <<
", " << vector
.z() <<
')';
1068#ifndef QT_NO_DATASTREAM
1071
1072
1073
1074
1075
1076
1077
1078
1087
1088
1089
1090
1091
1092
1093
1094
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 QtPrivate::fuzzyCompare(v1.v[0], v2.v[0])
1507 && QtPrivate::fuzzyCompare(v1.v[1], v2.v[1])
1508 && QtPrivate::fuzzyCompare(v1.v[2], v2.v[2])
1509 && QtPrivate::fuzzyCompare(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
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