src/types.cpp

changeset 538
2f85d4d286e5
parent 522
afa691788bdb
child 539
72ad83a67165
equal deleted inserted replaced
537:1add0ee96fb3 538:2f85d4d286e5
17 */ 17 */
18 18
19 #include <QObject> 19 #include <QObject>
20 #include <QStringList> 20 #include <QStringList>
21 #include <QTextStream> 21 #include <QTextStream>
22 #include <qfile.h> 22 #include <QFile>
23 #include <assert.h> 23 #include <assert.h>
24 #include "common.h" 24 #include "common.h"
25 #include "types.h" 25 #include "types.h"
26 #include "misc.h" 26 #include "misc.h"
27 #include "ldtypes.h" 27 #include "ldtypes.h"
179 } 179 }
180 180
181 // ============================================================================= 181 // =============================================================================
182 // ----------------------------------------------------------------------------- 182 // -----------------------------------------------------------------------------
183 matrix::matrix (double vals[]) 183 matrix::matrix (double vals[])
184 { for (short i = 0; i < 9; ++i) 184 { for (int i = 0; i < 9; ++i)
185 m_vals[i] = vals[i]; 185 m_vals[i] = vals[i];
186 } 186 }
187 187
188 // ============================================================================= 188 // =============================================================================
189 // ----------------------------------------------------------------------------- 189 // -----------------------------------------------------------------------------
190 matrix::matrix (double fillval) 190 matrix::matrix (double fillval)
191 { for (short i = 0; i < 9; ++i) 191 { for (int i = 0; i < 9; ++i)
192 m_vals[i] = fillval; 192 m_vals[i] = fillval;
193 } 193 }
194 194
195 // ============================================================================= 195 // =============================================================================
196 // ----------------------------------------------------------------------------- 196 // -----------------------------------------------------------------------------
200 } 200 }
201 201
202 // ============================================================================= 202 // =============================================================================
203 // ----------------------------------------------------------------------------- 203 // -----------------------------------------------------------------------------
204 void matrix::puts() const 204 void matrix::puts() const
205 { for (short i = 0; i < 3; ++i) 205 { for (int i = 0; i < 3; ++i)
206 { for (short j = 0; j < 3; ++j) 206 { for (int j = 0; j < 3; ++j)
207 log ("%1\t", m_vals[ (i * 3) + j]); 207 log ("%1\t", m_vals[ (i * 3) + j]);
208 208
209 log ("\n"); 209 log ("\n");
210 } 210 }
211 } 211 }
213 // ============================================================================= 213 // =============================================================================
214 // ----------------------------------------------------------------------------- 214 // -----------------------------------------------------------------------------
215 str matrix::stringRep() const 215 str matrix::stringRep() const
216 { str val; 216 { str val;
217 217
218 for (short i = 0; i < 9; ++i) 218 for (int i = 0; i < 9; ++i)
219 { if (i > 0) 219 { if (i > 0)
220 val += ' '; 220 val += ' ';
221 221
222 val += str::number (m_vals[i]); 222 val += str::number (m_vals[i]);
223 } 223 }
235 // ----------------------------------------------------------------------------- 235 // -----------------------------------------------------------------------------
236 matrix matrix::mult (matrix other) const 236 matrix matrix::mult (matrix other) const
237 { matrix val; 237 { matrix val;
238 val.zero(); 238 val.zero();
239 239
240 for (short i = 0; i < 3; ++i) 240 for (int i = 0; i < 3; ++i)
241 for (short j = 0; j < 3; ++j) 241 for (int j = 0; j < 3; ++j)
242 for (short k = 0; k < 3; ++k) 242 for (int k = 0; k < 3; ++k)
243 val[ (i * 3) + j] += m_vals[ (i * 3) + k] * other[ (k * 3) + j]; 243 val[(i * 3) + j] += m_vals[(i * 3) + k] * other[(k * 3) + j];
244 244
245 return val; 245 return val;
246 } 246 }
247 247
248 // ============================================================================= 248 // =============================================================================
252 return *this; 252 return *this;
253 } 253 }
254 254
255 // ============================================================================= 255 // =============================================================================
256 // ----------------------------------------------------------------------------- 256 // -----------------------------------------------------------------------------
257 double matrix::determinant() const 257 double matrix::getDeterminant() const
258 { return (val (0) * val (4) * val (8)) + 258 { return (val (0) * val (4) * val (8)) +
259 (val (1) * val (5) * val (6)) + 259 (val (1) * val (5) * val (6)) +
260 (val (2) * val (3) * val (7)) - 260 (val (2) * val (3) * val (7)) -
261 (val (2) * val (4) * val (6)) - 261 (val (2) * val (4) * val (6)) -
262 (val (1) * val (3) * val (8)) - 262 (val (1) * val (3) * val (8)) -
285 285
286 StringFormatArg::StringFormatArg (const uchar& v) 286 StringFormatArg::StringFormatArg (const uchar& v)
287 { m_val = v; 287 { m_val = v;
288 } 288 }
289 289
290 StringFormatArg::StringFormatArg (const qchar& v) 290 StringFormatArg::StringFormatArg (const QChar& v)
291 { m_val = v; 291 { m_val = v;
292 } 292 }
293 293
294 StringFormatArg::StringFormatArg (const float& v) 294 StringFormatArg::StringFormatArg (const float& v)
295 { m_val = str::number (v); 295 { m_val = str::number (v);
523 { switch (obj->getType()) 523 { switch (obj->getType())
524 { case LDObject::Line: 524 { case LDObject::Line:
525 case LDObject::Triangle: 525 case LDObject::Triangle:
526 case LDObject::Quad: 526 case LDObject::Quad:
527 case LDObject::CndLine: 527 case LDObject::CndLine:
528 528 { for (int i = 0; i < obj->vertices(); ++i)
529 for (short i = 0; i < obj->vertices(); ++i)
530 calcVertex (obj->getVertex (i)); 529 calcVertex (obj->getVertex (i));
531 530 } break;
532 break;
533 531
534 case LDObject::Subfile: 532 case LDObject::Subfile:
535 { LDSubfile* ref = static_cast<LDSubfile*> (obj); 533 { LDSubfile* ref = static_cast<LDSubfile*> (obj);
536 QList<LDObject*> objs = ref->inlineContents (LDSubfile::DeepCacheInline); 534 QList<LDObject*> objs = ref->inlineContents (LDSubfile::DeepCacheInline);
537 535
538 for (LDObject * obj : objs) 536 for (LDObject * obj : objs)
539 { calcObject (obj); 537 { calcObject (obj);
540 delete obj; 538 delete obj;
541 } 539 }
542 } 540 }
543 break; 541 break;

mercurial