src/gui_editactions.cc

changeset 615
b9073bddec0d
parent 614
aac6f0021070
child 617
f5059d144438
equal deleted inserted replaced
614:aac6f0021070 615:b9073bddec0d
469 const Vertex rotpoint = rotPoint (sel); 469 const Vertex rotpoint = rotPoint (sel);
470 const double angle = (pi * *currentGrid().confs[Grid::Angle]) / 180, 470 const double angle = (pi * *currentGrid().confs[Grid::Angle]) / 180,
471 cosangle = cos (angle), 471 cosangle = cos (angle),
472 sinangle = sin (angle); 472 sinangle = sin (angle);
473 473
474 log ("rotpoint: %1", rotpoint);
475
476 // ref: http://en.wikipedia.org/wiki/Transformation_matrix#Rotation_2 474 // ref: http://en.wikipedia.org/wiki/Transformation_matrix#Rotation_2
477 Matrix transform ( 475 Matrix transform (
478 { 476 {
479 (l* l * (1 - cosangle)) + cosangle, 477 (l* l * (1 - cosangle)) + cosangle,
480 (m* l * (1 - cosangle)) - (n* sinangle), 478 (m* l * (1 - cosangle)) - (n* sinangle),
498 { 496 {
499 Vertex v = obj->getVertex (i); 497 Vertex v = obj->getVertex (i);
500 rotateVertex (v, rotpoint, transform); 498 rotateVertex (v, rotpoint, transform);
501 obj->setVertex (i, v); 499 obj->setVertex (i, v);
502 } 500 }
503 } elif (obj->hasMatrix()) 501 }
502 elif (obj->hasMatrix())
504 { 503 {
505 LDMatrixObject* mo = dynamic_cast<LDMatrixObject*> (obj); 504 LDMatrixObject* mo = dynamic_cast<LDMatrixObject*> (obj);
506 505
507 // Transform the position 506 // Transform the position
508 /* 507 Vertex v = mo->getPosition();
509 vertex v = mo->getPosition();
510 rotateVertex (v, rotpoint, transform); 508 rotateVertex (v, rotpoint, transform);
511 mo->setPosition (v); 509 mo->setPosition (v);
512 */
513 510
514 // Transform the matrix 511 // Transform the matrix
515 mo->setTransform (transform * mo->getTransform()); 512 mo->setTransform (transform * mo->getTransform());
516 } elif (obj->getType() == LDObject::EVertex) 513 }
514 elif (obj->getType() == LDObject::EVertex)
517 { 515 {
518 LDVertex* vert = static_cast<LDVertex*> (obj); 516 LDVertex* vert = static_cast<LDVertex*> (obj);
519 Vertex v = vert->pos; 517 Vertex v = vert->pos;
520 rotateVertex (v, rotpoint, transform); 518 rotateVertex (v, rotpoint, transform);
521 vert->pos = v; 519 vert->pos = v;

mercurial