257 changeProperty(&this->m_referenceName, newReferenceName); |
257 changeProperty(&this->m_referenceName, newReferenceName); |
258 } |
258 } |
259 |
259 |
260 // ============================================================================= |
260 // ============================================================================= |
261 // |
261 // |
262 // Moves this object using the given vertex as a movement List |
262 // Moves this object using the given vector |
263 // |
263 // |
264 void LDObject::move (Vertex vect) |
264 void LDObject::move (const QVector3D vector) |
265 { |
265 { |
266 if (hasMatrix()) |
266 if (hasMatrix()) |
267 { |
267 { |
268 LDMatrixObject* mo = static_cast<LDMatrixObject*> (this); |
268 LDMatrixObject* mo = static_cast<LDMatrixObject*> (this); |
269 mo->setPosition (mo->position() + vect); |
269 mo->setPosition (mo->position() + vector); |
270 } |
270 } |
271 else |
271 else |
272 { |
272 { |
273 for (int i = 0; i < numVertices(); ++i) |
273 for (int i = 0; i < numVertices(); ++i) |
274 setVertex (i, vertex (i) + vect); |
274 setVertex (i, vertex (i) + vector); |
275 } |
275 } |
276 } |
276 } |
277 |
277 |
278 bool LDObject::isHidden() const |
278 bool LDObject::isHidden() const |
279 { |
279 { |
366 |
366 |
367 LDMatrixObject::LDMatrixObject (const Matrix& transform, const Vertex& pos) : |
367 LDMatrixObject::LDMatrixObject (const Matrix& transform, const Vertex& pos) : |
368 m_position (pos), |
368 m_position (pos), |
369 m_transformationMatrix (transform) {} |
369 m_transformationMatrix (transform) {} |
370 |
370 |
371 void LDMatrixObject::setCoordinate (const Axis ax, double value) |
371 void LDMatrixObject::setCoordinate (const Axis axis, double value) |
372 { |
372 { |
373 Vertex v = position(); |
373 Vertex position = this->position(); |
374 |
374 position.setCoordinate(axis, value); |
375 switch (ax) |
375 this->setPosition(position); |
376 { |
|
377 case X: v.setX (value); break; |
|
378 case Y: v.setY (value); break; |
|
379 case Z: v.setZ (value); break; |
|
380 } |
|
381 |
|
382 setPosition (v); |
|
383 } |
376 } |
384 |
377 |
385 const Vertex& LDMatrixObject::position() const |
378 const Vertex& LDMatrixObject::position() const |
386 { |
379 { |
387 return m_position; |
380 return m_position; |
422 |
415 |
423 Vertex LDBezierCurve::pointAt (qreal t) const |
416 Vertex LDBezierCurve::pointAt (qreal t) const |
424 { |
417 { |
425 if (t >= 0.0 and t <= 1.0) |
418 if (t >= 0.0 and t <= 1.0) |
426 { |
419 { |
427 Vertex result; |
420 Vertex result = pow(1.0 - t, 3) * vertex(0); |
428 result += pow (1.0 - t, 3) * vertex (0); |
421 result += (3 * pow(1.0 - t, 2) * t) * vertex(2).toVector(); |
429 result += (3 * pow (1.0 - t, 2) * t) * vertex (2); |
422 result += (3 * (1.0 - t) * pow(t, 2)) * vertex(3).toVector(); |
430 result += (3 * (1.0 - t) * pow (t, 2)) * vertex (3); |
423 result += pow(t, 3) * vertex(1).toVector(); |
431 result += pow (t, 3) * vertex (1); |
|
432 return result; |
424 return result; |
433 } |
425 } |
434 else |
426 else |
435 return Vertex(); |
427 return Vertex(); |
436 } |
428 } |