src/basics.cpp

Sun, 29 Jan 2017 21:02:11 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Sun, 29 Jan 2017 21:02:11 +0200
changeset 1079
67c6e5d32e68
parent 1073
a0a0d581309b
child 1086
621c2e5853bb
permissions
-rw-r--r--

More rework on model stuff, removals of LDSpawn calls. Most importantly, the LDraw code parsing function was moved to Model.

655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 /*
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
2 * LDForge: LDraw parts authoring CAD
1072
9ce9496427f2 Happy new year 2017!
Teemu Piippo <teemu@hecknology.net>
parents: 1068
diff changeset
3 * Copyright (C) 2013 - 2017 Teemu Piippo
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
4 *
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or modify
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8 * (at your option) any later version.
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
9 *
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 * GNU General Public License for more details.
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14 *
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 */
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 #include <QObject>
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 #include <QStringList>
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21 #include <QTextStream>
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22 #include <QFile>
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23 #include <assert.h>
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24 #include "main.h"
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25 #include "basics.h"
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
26 #include "miscallenous.h"
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
27 #include "ldObject.h"
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
28 #include "ldDocument.h"
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
29
733
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
30 Vertex::Vertex() :
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
31 QVector3D() {}
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
32
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
33 Vertex::Vertex (const QVector3D& a) :
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
34 QVector3D (a) {}
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
35
733
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
36 Vertex::Vertex (qreal xpos, qreal ypos, qreal zpos) :
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
37 QVector3D(xpos, ypos, zpos) {}
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
38
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
39
1068
283de3bd8b0e Reworked the Matrix interface so that less index math is involved
Teemu Piippo <teemu@hecknology.net>
parents: 1053
diff changeset
40 void Vertex::transform (const Matrix& matrix, const Vertex& pos)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
41 {
1068
283de3bd8b0e Reworked the Matrix interface so that less index math is involved
Teemu Piippo <teemu@hecknology.net>
parents: 1053
diff changeset
42 double x2 = (matrix(0, 0) * x()) + (matrix(0, 1) * y()) + (matrix(0, 2) * z()) + pos.x();
283de3bd8b0e Reworked the Matrix interface so that less index math is involved
Teemu Piippo <teemu@hecknology.net>
parents: 1053
diff changeset
43 double y2 = (matrix(1, 0) * x()) + (matrix(1, 1) * y()) + (matrix(1, 2) * z()) + pos.y();
283de3bd8b0e Reworked the Matrix interface so that less index math is involved
Teemu Piippo <teemu@hecknology.net>
parents: 1053
diff changeset
44 double z2 = (matrix(2, 0) * x()) + (matrix(2, 1) * y()) + (matrix(2, 2) * z()) + pos.z();
733
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
45 setX (x2);
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
46 setY (y2);
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
47 setZ (z2);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
48 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
49
733
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
50 void Vertex::apply (ApplyFunction func)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
51 {
733
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
52 double newX = x(), newY = y(), newZ = z();
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
53 func (X, newX);
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
54 func (Y, newY);
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
55 func (Z, newZ);
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
56 *this = Vertex (newX, newY, newZ);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
57 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
58
733
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
59 void Vertex::apply (ApplyConstFunction func) const
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
60 {
733
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
61 func (X, x());
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
62 func (Y, y());
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
63 func (Z, z());
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
64 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
65
733
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
66 double Vertex::operator[] (Axis ax) const
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
67 {
733
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
68 switch (ax)
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
69 {
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
70 case X: return x();
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
71 case Y: return y();
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
72 case Z: return z();
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
73 }
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
74
733
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
75 return 0.0;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
76 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
77
733
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
78 void Vertex::setCoordinate (Axis ax, qreal value)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
79 {
733
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
80 switch (ax)
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
81 {
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
82 case X: setX (value); break;
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
83 case Y: setY (value); break;
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
84 case Z: setZ (value); break;
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
85 }
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
86 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
87
789
4b7306f52bb5 - String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents: 786
diff changeset
88 QString Vertex::toString (bool mangled) const
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
89 {
733
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
90 if (mangled)
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
91 return format ("(%1, %2, %3)", x(), y(), z());
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
92
733
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
93 return format ("%1 %2 %3", x(), y(), z());
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
94 }
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
95
1002
a3ee23db8393 Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
96 Vertex Vertex::operator* (qreal scalar) const
a3ee23db8393 Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
97 {
a3ee23db8393 Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
98 return Vertex (x() * scalar, y() * scalar, z() * scalar);
a3ee23db8393 Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
99 }
a3ee23db8393 Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
100
a3ee23db8393 Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
101 Vertex& Vertex::operator+= (const Vertex& other)
a3ee23db8393 Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
102 {
a3ee23db8393 Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
103 setX (x() + other.x());
a3ee23db8393 Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
104 setY (y() + other.y());
a3ee23db8393 Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
105 setZ (z() + other.z());
a3ee23db8393 Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
106 return *this;
a3ee23db8393 Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
107 }
a3ee23db8393 Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
108
a3ee23db8393 Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
109 Vertex Vertex::operator+ (const Vertex& other) const
a3ee23db8393 Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
110 {
a3ee23db8393 Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
111 Vertex result (*this);
a3ee23db8393 Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
112 result += other;
a3ee23db8393 Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
113 return result;
a3ee23db8393 Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
114 }
a3ee23db8393 Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
115
a3ee23db8393 Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
116 Vertex& Vertex::operator*= (qreal scalar)
a3ee23db8393 Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
117 {
a3ee23db8393 Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
118 setX (x() * scalar);
a3ee23db8393 Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
119 setY (y() * scalar);
a3ee23db8393 Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
120 setZ (z() * scalar);
a3ee23db8393 Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
121 return *this;
a3ee23db8393 Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
122 }
a3ee23db8393 Bézier curves may now be serialized down using the "Demote" function. I need to rename that now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
123
733
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
124 bool Vertex::operator< (const Vertex& other) const
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
125 {
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
126 if (x() != other.x()) return x() < other.x();
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
127 if (y() != other.y()) return y() < other.y();
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
128 if (z() != other.z()) return z() < other.z();
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
129 return false;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
130 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
131
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
132 // =============================================================================
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
133 //
1013
fa025ba493d8 Cleanup miscallenous.cpp/.h
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1011
diff changeset
134 BoundingBox::BoundingBox()
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
135 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
136 reset();
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
137 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
138
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
139 // =============================================================================
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
140 //
1013
fa025ba493d8 Cleanup miscallenous.cpp/.h
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1011
diff changeset
141 BoundingBox& BoundingBox::operator<< (const Vertex& v)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
142 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
143 calcVertex (v);
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
144 return *this;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
145 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
146
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
147 // =============================================================================
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
148 //
1013
fa025ba493d8 Cleanup miscallenous.cpp/.h
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1011
diff changeset
149 void BoundingBox::calcVertex (const Vertex& vertex)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
150 {
966
a834e43a57da Replaced Min/Max/Clamp/Abs with use of Qt versions of them.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 958
diff changeset
151 m_vertex0.setX (qMin (vertex.x(), m_vertex0.x()));
a834e43a57da Replaced Min/Max/Clamp/Abs with use of Qt versions of them.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 958
diff changeset
152 m_vertex0.setY (qMin (vertex.y(), m_vertex0.y()));
a834e43a57da Replaced Min/Max/Clamp/Abs with use of Qt versions of them.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 958
diff changeset
153 m_vertex0.setZ (qMin (vertex.z(), m_vertex0.z()));
a834e43a57da Replaced Min/Max/Clamp/Abs with use of Qt versions of them.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 958
diff changeset
154 m_vertex1.setX (qMax (vertex.x(), m_vertex1.x()));
a834e43a57da Replaced Min/Max/Clamp/Abs with use of Qt versions of them.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 958
diff changeset
155 m_vertex1.setY (qMax (vertex.y(), m_vertex1.y()));
a834e43a57da Replaced Min/Max/Clamp/Abs with use of Qt versions of them.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 958
diff changeset
156 m_vertex1.setZ (qMax (vertex.z(), m_vertex1.z()));
1010
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1002
diff changeset
157 m_isEmpty = false;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
158 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
159
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
160 // =============================================================================
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
161 //
1010
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1002
diff changeset
162 // Clears the bounding box
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1002
diff changeset
163 //
1013
fa025ba493d8 Cleanup miscallenous.cpp/.h
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1011
diff changeset
164 void BoundingBox::reset()
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
165 {
733
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
166 m_vertex0 = Vertex (10000.0, 10000.0, 10000.0);
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
167 m_vertex1 = Vertex (-10000.0, -10000.0, -10000.0);
1010
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1002
diff changeset
168 m_isEmpty = true;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
169 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
170
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
171 // =============================================================================
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
172 //
1010
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1002
diff changeset
173 // Returns the length of the bounding box on the longest measure.
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1002
diff changeset
174 //
1013
fa025ba493d8 Cleanup miscallenous.cpp/.h
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1011
diff changeset
175 double BoundingBox::longestMeasurement() const
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
176 {
733
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
177 double xscale = (m_vertex0.x() - m_vertex1.x());
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
178 double yscale = (m_vertex0.y() - m_vertex1.y());
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
179 double zscale = (m_vertex0.z() - m_vertex1.z());
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
180 double size = zscale;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
181
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
182 if (xscale > yscale)
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
183 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
184 if (xscale > zscale)
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
185 size = xscale;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
186 }
967
eb586d3e1a6a elif -> else if
Teemu Piippo <crimsondusk64@gmail.com>
parents: 966
diff changeset
187 else if (yscale > zscale)
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
188 size = yscale;
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
189
966
a834e43a57da Replaced Min/Max/Clamp/Abs with use of Qt versions of them.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 958
diff changeset
190 if (qAbs (size) >= 2.0)
a834e43a57da Replaced Min/Max/Clamp/Abs with use of Qt versions of them.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 958
diff changeset
191 return qAbs (size / 2);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
192
733
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
193 return 1.0;
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
194 }
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
195
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
196 // =============================================================================
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
197 //
1010
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1002
diff changeset
198 // Yields the center of the bounding box.
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1002
diff changeset
199 //
1013
fa025ba493d8 Cleanup miscallenous.cpp/.h
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1011
diff changeset
200 Vertex BoundingBox::center() const
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
201 {
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
202 return Vertex (
733
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
203 (m_vertex0.x() + m_vertex1.x()) / 2,
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
204 (m_vertex0.y() + m_vertex1.y()) / 2,
cc39df788660 - reimplemented the Vertex class as a derivative of QVector3D
Santeri Piippo <crimsondusk64@gmail.com>
parents: 714
diff changeset
205 (m_vertex0.z() + m_vertex1.z()) / 2);
655
b376645315ab - renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
206 }
1010
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1002
diff changeset
207
1013
fa025ba493d8 Cleanup miscallenous.cpp/.h
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1011
diff changeset
208 bool BoundingBox::isEmpty() const
1010
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1002
diff changeset
209 {
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1002
diff changeset
210 return m_isEmpty;
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1002
diff changeset
211 }
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1002
diff changeset
212
1013
fa025ba493d8 Cleanup miscallenous.cpp/.h
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1011
diff changeset
213 const Vertex& BoundingBox::vertex0() const
1010
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1002
diff changeset
214 {
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1002
diff changeset
215 return m_vertex0;
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1002
diff changeset
216 }
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1002
diff changeset
217
1013
fa025ba493d8 Cleanup miscallenous.cpp/.h
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1011
diff changeset
218 const Vertex& BoundingBox::vertex1() const
1010
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1002
diff changeset
219 {
969b48eddd6b A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1002
diff changeset
220 return m_vertex1;
1031
55c0d3beea0d removed removeDuplicates in favor of QSet, and the unused ObjectList class
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1014
diff changeset
221 }
55c0d3beea0d removed removeDuplicates in favor of QSet, and the unused ObjectList class
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1014
diff changeset
222
1036
993c46d7eb75 Replaced the ugly for_enum macro with a generator class
Teemu Piippo <teemu@compsta2.com>
parents: 1031
diff changeset
223 // http://stackoverflow.com/a/18204188/3629665
993c46d7eb75 Replaced the ugly for_enum macro with a generator class
Teemu Piippo <teemu@compsta2.com>
parents: 1031
diff changeset
224 template<typename T>
993c46d7eb75 Replaced the ugly for_enum macro with a generator class
Teemu Piippo <teemu@compsta2.com>
parents: 1031
diff changeset
225 inline int rotl10(T x)
993c46d7eb75 Replaced the ugly for_enum macro with a generator class
Teemu Piippo <teemu@compsta2.com>
parents: 1031
diff changeset
226 {
993c46d7eb75 Replaced the ugly for_enum macro with a generator class
Teemu Piippo <teemu@compsta2.com>
parents: 1031
diff changeset
227 return (((x) << 10) | (((x) >> 22) & 0x000000ff));
993c46d7eb75 Replaced the ugly for_enum macro with a generator class
Teemu Piippo <teemu@compsta2.com>
parents: 1031
diff changeset
228 }
993c46d7eb75 Replaced the ugly for_enum macro with a generator class
Teemu Piippo <teemu@compsta2.com>
parents: 1031
diff changeset
229
993c46d7eb75 Replaced the ugly for_enum macro with a generator class
Teemu Piippo <teemu@compsta2.com>
parents: 1031
diff changeset
230 template<typename T>
993c46d7eb75 Replaced the ugly for_enum macro with a generator class
Teemu Piippo <teemu@compsta2.com>
parents: 1031
diff changeset
231 inline int rotl20(T x)
993c46d7eb75 Replaced the ugly for_enum macro with a generator class
Teemu Piippo <teemu@compsta2.com>
parents: 1031
diff changeset
232 {
993c46d7eb75 Replaced the ugly for_enum macro with a generator class
Teemu Piippo <teemu@compsta2.com>
parents: 1031
diff changeset
233 return (((x) << 20) | (((x) >> 12) & 0x000000ff));
993c46d7eb75 Replaced the ugly for_enum macro with a generator class
Teemu Piippo <teemu@compsta2.com>
parents: 1031
diff changeset
234 }
993c46d7eb75 Replaced the ugly for_enum macro with a generator class
Teemu Piippo <teemu@compsta2.com>
parents: 1031
diff changeset
235
1031
55c0d3beea0d removed removeDuplicates in favor of QSet, and the unused ObjectList class
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1014
diff changeset
236 uint qHash(const Vertex& key)
55c0d3beea0d removed removeDuplicates in favor of QSet, and the unused ObjectList class
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1014
diff changeset
237 {
1036
993c46d7eb75 Replaced the ugly for_enum macro with a generator class
Teemu Piippo <teemu@compsta2.com>
parents: 1031
diff changeset
238 return qHash(key.x()) ^ rotl10(qHash(key.y())) ^ rotl20(qHash(key.z()));
1031
55c0d3beea0d removed removeDuplicates in favor of QSet, and the unused ObjectList class
Teemu Piippo <crimsondusk64@gmail.com>
parents: 1014
diff changeset
239 }
1053
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1037
diff changeset
240
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1037
diff changeset
241 /*
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1037
diff changeset
242 * getRadialPoint
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1037
diff changeset
243 *
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1037
diff changeset
244 * Gets an ordinate of a point in circle.
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1037
diff changeset
245 * If func == sin, then this gets the Y co-ordinate, if func == cos, then X co-ordinate.
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1037
diff changeset
246 */
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1037
diff changeset
247 double getRadialPoint(int segment, int divisions, double(*func)(double))
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1037
diff changeset
248 {
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1037
diff changeset
249 return (*func)((segment * 2 * pi) / divisions);
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1037
diff changeset
250 }
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1037
diff changeset
251
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1037
diff changeset
252 /*
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1037
diff changeset
253 * makeCircle
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1037
diff changeset
254 *
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1037
diff changeset
255 * Creates a possibly partial circle rim.
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1037
diff changeset
256 * Divisions is how many segments the circle makes if up if it's full.
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1037
diff changeset
257 * Segments is now many segments are added.
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1037
diff changeset
258 * Radius is the radius of the circle.
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1037
diff changeset
259 *
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1037
diff changeset
260 * If divisions == segments, this yields a full circle rim.
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1037
diff changeset
261 * The rendered circle is returned as a vector of lines.
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1037
diff changeset
262 */
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1037
diff changeset
263 QVector<QLineF> makeCircle(int segments, int divisions, double radius)
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1037
diff changeset
264 {
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1037
diff changeset
265 QVector<QLineF> lines;
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1037
diff changeset
266
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1037
diff changeset
267 for (int i = 0; i < segments; ++i)
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1037
diff changeset
268 {
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1037
diff changeset
269 double x0 = radius * getRadialPoint(i, divisions, cos);
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1037
diff changeset
270 double x1 = radius * getRadialPoint(i + 1, divisions, cos);
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1037
diff changeset
271 double z0 = radius * getRadialPoint(i, divisions, sin);
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1037
diff changeset
272 double z1 = radius * getRadialPoint(i + 1, divisions, sin);
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1037
diff changeset
273 lines.append(QLineF {QPointF {x0, z0}, QPointF {x1, z1}});
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1037
diff changeset
274 }
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1037
diff changeset
275
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1037
diff changeset
276 return lines;
2a48c0fff107 Refactor primitives
Teemu Piippo <teemu@hecknology.net>
parents: 1037
diff changeset
277 }

mercurial