72 Vertex Vertex::midpoint (const Vertex& other) |
72 Vertex Vertex::midpoint (const Vertex& other) |
73 { |
73 { |
74 Vertex mid; |
74 Vertex mid; |
75 |
75 |
76 for_axes (ax) |
76 for_axes (ax) |
77 mid[ax] = (m_coords[ax] + other[ax]) / 2; |
77 mid[ax] = (getCoordinate (ax) + other[ax]) / 2; |
78 |
78 |
79 return mid; |
79 return mid; |
80 } |
80 } |
81 |
81 |
82 // ============================================================================= |
82 // ============================================================================= |
83 // ----------------------------------------------------------------------------- |
83 // ----------------------------------------------------------------------------- |
84 QString Vertex::stringRep (bool mangled) const |
84 QString Vertex::toString (bool mangled) const |
85 { |
85 { |
86 QString fmtstr = "%1 %2 %3"; |
86 QString fmtstr = "%1 %2 %3"; |
87 |
87 |
88 if (mangled) |
88 if (mangled) |
89 fmtstr = "(%1, %2, %3)"; |
89 fmtstr = "(%1, %2, %3)"; |
90 |
90 |
91 return fmt (fmtstr, coord (X), coord (Y), coord (Z)); |
91 return fmt (fmtstr, x(), y(), z()); |
92 } |
92 } |
93 |
93 |
94 // ============================================================================= |
94 // ============================================================================= |
95 // ----------------------------------------------------------------------------- |
95 // ----------------------------------------------------------------------------- |
96 void Vertex::transform (Matrix matr, Vertex pos) |
96 void Vertex::transform (const Matrix& matr, const Vertex& pos) |
97 { |
97 { |
98 double x2 = (matr[0] * x()) + (matr[1] * y()) + (matr[2] * z()) + pos[X]; |
98 double x2 = (matr[0] * x()) + (matr[1] * y()) + (matr[2] * z()) + pos[X]; |
99 double y2 = (matr[3] * x()) + (matr[4] * y()) + (matr[5] * z()) + pos[Y]; |
99 double y2 = (matr[3] * x()) + (matr[4] * y()) + (matr[5] * z()) + pos[Y]; |
100 double z2 = (matr[6] * x()) + (matr[7] * y()) + (matr[8] * z()) + pos[Z]; |
100 double z2 = (matr[6] * x()) + (matr[7] * y()) + (matr[8] * z()) + pos[Z]; |
101 |
101 |
118 return !operator== (other); |
118 return !operator== (other); |
119 } |
119 } |
120 |
120 |
121 // ============================================================================= |
121 // ============================================================================= |
122 // ----------------------------------------------------------------------------- |
122 // ----------------------------------------------------------------------------- |
123 double& Vertex::operator[] (const Axis ax) |
|
124 { |
|
125 return coord ( (int) ax); |
|
126 } |
|
127 |
|
128 const double& Vertex::operator[] (const Axis ax) const |
|
129 { |
|
130 return coord ( (int) ax); |
|
131 } |
|
132 |
|
133 double& Vertex::operator[] (const int ax) |
|
134 { |
|
135 return coord (ax); |
|
136 } |
|
137 |
|
138 const double& Vertex::operator[] (const int ax) const |
|
139 { |
|
140 return coord (ax); |
|
141 } |
|
142 |
|
143 // ============================================================================= |
|
144 // ----------------------------------------------------------------------------- |
|
145 bool Vertex::operator== (const Vertex& other) const |
123 bool Vertex::operator== (const Vertex& other) const |
146 { |
124 { |
147 return coord (X) == other[X] && |
125 return getCoordinate (X) == other[X] && |
148 coord (Y) == other[Y] && |
126 getCoordinate (Y) == other[Y] && |
149 coord (Z) == other[Z]; |
127 getCoordinate (Z) == other[Z]; |
150 } |
128 } |
151 |
129 |
152 // ============================================================================= |
130 // ============================================================================= |
153 // ----------------------------------------------------------------------------- |
131 // ----------------------------------------------------------------------------- |
154 Vertex& Vertex::operator/= (const double d) |
132 Vertex& Vertex::operator/= (const double d) |
189 int Vertex::operator< (const Vertex& other) const |
167 int Vertex::operator< (const Vertex& other) const |
190 { |
168 { |
191 if (operator== (other)) |
169 if (operator== (other)) |
192 return false; |
170 return false; |
193 |
171 |
194 if (coord (X) < other[X]) |
172 if (getCoordinate (X) < other[X]) |
195 return true; |
173 return true; |
196 |
174 |
197 if (coord (X) > other[X]) |
175 if (getCoordinate (X) > other[X]) |
198 return false; |
176 return false; |
199 |
177 |
200 if (coord (Y) < other[Y]) |
178 if (getCoordinate (Y) < other[Y]) |
201 return true; |
179 return true; |
202 |
180 |
203 if (coord (Y) > other[Y]) |
181 if (getCoordinate (Y) > other[Y]) |
204 return false; |
182 return false; |
205 |
183 |
206 return coord (Z) < other[Z]; |
184 return getCoordinate (Z) < other[Z]; |
207 } |
185 } |
208 |
186 |
209 // ============================================================================= |
187 // ============================================================================= |
210 // ----------------------------------------------------------------------------- |
188 // ----------------------------------------------------------------------------- |
211 Matrix::Matrix (double vals[]) |
189 Matrix::Matrix (double vals[]) |