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
299
300
301
302
303
304
305
308
309
310
311
312
313
314
317
318
319
320
321
322
325
326
327
328
329
330
333
334
335
336
337
338
339
340
341
342
345
346
347
348
349
350
351
352
355
356
357
358
359
360
361
362
363
366
367
368
369
370
371
372
373
374
375
378
379
380
381
382
385 return QtPrivate::fuzzyCompare(v1.v[0], v2.v[0])
386 && QtPrivate::fuzzyCompare(v1.v[1], v2.v[1]);
389#ifndef QT_NO_VECTOR3D
391
392
393
394
395
396
399#ifndef QT_NO_VECTOR4D
401
402
403
404
405
406
410
411
412
413
414
415
416
419
420
421
422
423
424
427
428
431 return QVariant::fromValue(*
this);
434#ifndef QT_NO_DEBUG_STREAM
438 QDebugStateSaver saver(dbg);
439 dbg.nospace() <<
"QVector2D(" << vector
.x() <<
", " << vector
.y() <<
')';
445#ifndef QT_NO_DATASTREAM
448
449
450
451
452
453
454
455
464
465
466
467
468
469
470
471
489#ifndef QT_NO_VECTOR3D
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
509
510
511
512
515
516
517
518
519
520
523
524
525
526
527
530
531
532
533
534
537
538
539
540
541
543#ifndef QT_NO_VECTOR2D
546
547
548
549
550
551
552
555
556
557
558
559
560
561
564#ifndef QT_NO_VECTOR4D
567
568
569
570
571
572
573
578
579
580
581
582
585
586
587
588
589
590
593
594
595
596
597
598
601
602
603
604
605
606
609
610
611
612
613
614
617
618
619
620
621
622
625
626
627
628
629
630
633
634
635
636
637
638
639
640
643
644
645
646
647
648
649
652
653
654
655
656
657
658
659
660
661
664
665
666
667
668
669
670
673
674
675
676
677
678
679
682
683
684
685
686
687
688
691
692
693
694
695
696
697
700
701
702
703
704
705
706
707
708
709
710
711
714
715
716
717
718
719
720
723
724
725
726
727
728
729
730
731
732
735
736
737
738
741
742
743
744
745
746
747
748
751
752
753
754
755
756
757
758
759
760
763
764
765
766
767
768
769
770
771
772
773
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791QVector3D QVector3D::project(
const QMatrix4x4 &modelView,
const QMatrix4x4 &projection,
const QRect &viewport)
const
794 tmp = projection * modelView * tmp;
795 if (qFuzzyIsNull(tmp
.w()))
799 tmp = tmp * 0.5f + QVector4D(0.5f, 0.5f, 0.5f, 0.5f);
800 tmp
.setX(tmp
.x() * viewport.width() + viewport.x()
);
801 tmp
.setY(tmp
.y() * viewport.height() + viewport.y()
);
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822QVector3D QVector3D::unproject(
const QMatrix4x4 &modelView,
const QMatrix4x4 &projection,
const QRect &viewport)
const
824 QMatrix4x4 inverse = QMatrix4x4( projection * modelView ).inverted();
827 tmp
.setX((tmp
.x() -
float(viewport.x())) /
float(viewport.width())
);
828 tmp
.setY((tmp
.y() -
float(viewport.y())) /
float(viewport.height())
);
829 tmp = tmp * 2.0f - QVector4D(1.0f, 1.0f, 1.0f, 1.0f);
832 if (qFuzzyIsNull(obj
.w()))
839
840
841
842
843
844
845
846
847
850
851
852
853
854
855
856
857
858
859
860
863
864
865
866
867
868
869
870
871
872
873
874
875
878
879
880
881
882
883
884
885
886
887
890
891
892
893
894
897
898
899
900
901
904
905
906
907
910
911
912
913
914
915
916
919
920
921
922
923
924
925
928
929
930
931
932
933
936
937
938
939
940
941
944
945
946
947
948
949
950
951
952
953
956
957
958
959
960
961
962
963
966
967
968
969
970
971
972
973
974
977
978
979
980
981
982
983
984
985
986
989
990
991
992
993
996 return QtPrivate::fuzzyCompare(v1.v[0], v2.v[0])
997 && QtPrivate::fuzzyCompare(v1.v[1], v2.v[1])
998 && QtPrivate::fuzzyCompare(v1.v[2], v2.v[2]);
1001#ifndef QT_NO_VECTOR2D
1004
1005
1006
1007
1008
1009
1013#ifndef QT_NO_VECTOR4D
1016
1017
1018
1019
1020
1021
1026
1027
1028
1029
1030
1031
1032
1035
1036
1037
1038
1039
1040
1041
1044
1045
1048 return QVariant::fromValue(*
this);
1052
1053
1054
1055
1056
1057
1060
1061
1062
1063
1064
1065
1066
1068#ifndef QT_NO_DEBUG_STREAM
1072 QDebugStateSaver saver(dbg);
1073 dbg.nospace() <<
"QVector3D("
1074 << vector
.x() <<
", " << vector
.y() <<
", " << vector
.z() <<
')';
1080#ifndef QT_NO_DATASTREAM
1083
1084
1085
1086
1087
1088
1089
1090
1099
1100
1101
1102
1103
1104
1105
1106
1126#ifndef QT_NO_VECTOR4D
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1146
1147
1148
1149
1152
1153
1154
1155
1156
1157
1160
1161
1162
1163
1164
1167
1168
1169
1170
1171
1174
1175
1176
1177
1178
1180#ifndef QT_NO_VECTOR2D
1183
1184
1185
1186
1187
1188
1189
1192
1193
1194
1195
1196
1197
1198
1199
1203#ifndef QT_NO_VECTOR3D
1206
1207
1208
1209
1210
1211
1212
1215
1216
1217
1218
1219
1220
1221
1226
1227
1228
1229
1230
1233
1234
1235
1236
1237
1238
1241
1242
1243
1244
1245
1246
1249
1250
1251
1252
1253
1254
1257
1258
1259
1260
1261
1262
1265
1266
1267
1268
1269
1270
1273
1274
1275
1276
1277
1278
1281
1282
1283
1284
1285
1286
1289
1290
1291
1292
1293
1294
1297
1298
1299
1300
1301
1302
1303
1304
1307
1308
1309
1310
1311
1312
1313
1316
1317
1318
1319
1320
1321
1324
1325
1326
1327
1328
1329
1330
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1345
1346
1347
1348
1349
1350
1351
1355
1356
1357
1358
1359
1360
1361
1364
1365
1366
1367
1368
1369
1370
1373
1374
1375
1376
1377
1378
1379
1382
1383
1384
1385
1386
1387
1388
1391
1392
1393
1394
1395
1396
1397
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1412
1413
1414
1415
1418
1419
1420
1421
1422
1425
1426
1427
1428
1429
1432
1433
1434
1435
1438
1439
1440
1441
1442
1443
1444
1447
1448
1449
1450
1451
1452
1453
1456
1457
1458
1459
1460
1461
1464
1465
1466
1467
1468
1469
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1484
1485
1486
1487
1488
1489
1490
1491
1494
1495
1496
1497
1498
1499
1500
1501
1502
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1517
1518
1519
1520
1521
1524 return QtPrivate::fuzzyCompare(v1.v[0], v2.v[0])
1525 && QtPrivate::fuzzyCompare(v1.v[1], v2.v[1])
1526 && QtPrivate::fuzzyCompare(v1.v[2], v2.v[2])
1527 && QtPrivate::fuzzyCompare(v1.v[3], v2.v[3]);
1530#ifndef QT_NO_VECTOR2D
1533
1534
1535
1536
1537
1538
1541
1542
1543
1544
1545
1546
1547
1548
1552#ifndef QT_NO_VECTOR3D
1555
1556
1557
1558
1559
1560
1563
1564
1565
1566
1567
1568
1569
1574
1575
1576
1577
1578
1579
1580
1583
1584
1585
1586
1587
1588
1589
1592
1593
1596 return QVariant::fromValue(*
this);
1599#ifndef QT_NO_DEBUG_STREAM
1603 QDebugStateSaver saver(dbg);
1604 dbg.nospace() <<
"QVector4D("
1605 << vector
.x() <<
", " << vector
.y() <<
", "
1606 << vector
.z() <<
", " << vector
.w() <<
')';
1612#ifndef QT_NO_DATASTREAM
1615
1616
1617
1618
1619
1620
1621
1622
1632
1633
1634
1635
1636
1637
1638
1639
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