Sun, 18 Aug 2013 16:04:36 +0300
more cleanup
src/gui_editactions.cpp | file | annotate | diff | comparison | revisions | |
src/types.cpp | file | annotate | diff | comparison | revisions | |
src/types.h | file | annotate | diff | comparison | revisions |
--- a/src/gui_editactions.cpp Sun Aug 18 15:33:00 2013 +0300 +++ b/src/gui_editactions.cpp Sun Aug 18 16:04:36 2013 +0300 @@ -418,24 +418,23 @@ List<LDObject*> sel = g_win->sel(); List<vertex*> queue; const vertex rotpoint = rotPoint (sel); - const double angle = (pi * currentGrid().confs[Grid::Angle]->value) / 180; - - // ref: http://en.wikipedia.org/wiki/Transformation_matrix#Rotation_2 - const double cosangle = cos (angle), + const double angle = (pi * currentGrid().confs[Grid::Angle]->value) / 180, + cosangle = cos (angle), sinangle = sin (angle); + // ref: http://en.wikipedia.org/wiki/Transformation_matrix#Rotation_2 matrix transform ({ - (l* l * (1 - cosangle)) + cosangle, - (m* l * (1 - cosangle)) - (n* sinangle), - (n* l * (1 - cosangle)) + (m* sinangle), + (l * l * (1 - cosangle)) + cosangle, + (m * l * (1 - cosangle)) - (n * sinangle), + (n * l * (1 - cosangle)) + (m * sinangle), - (l* m * (1 - cosangle)) + (n* sinangle), - (m* m * (1 - cosangle)) + cosangle, - (n* m * (1 - cosangle)) - (l* sinangle), + (l * m * (1 - cosangle)) + (n * sinangle), + (m * m * (1 - cosangle)) + cosangle, + (n * m * (1 - cosangle)) - (l * sinangle), - (l* n * (1 - cosangle)) - (m* sinangle), - (m* n * (1 - cosangle)) + (l* sinangle), - (n* n * (1 - cosangle)) + cosangle + (l * n * (1 - cosangle)) - (m * sinangle), + (m * n * (1 - cosangle)) + (l * sinangle), + (n * n * (1 - cosangle)) + cosangle }); // Apply the above matrix to everything @@ -448,9 +447,13 @@ } } elif (obj->hasMatrix()) { LDMatrixObject* mo = dynamic_cast<LDMatrixObject*> (obj); + + // Transform the position vertex v = mo->position(); rotateVertex (v, rotpoint, transform); mo->setPosition (v); + + // Transform the matrix mo->setTransform (mo->transform() * transform); } elif (obj->getType() == LDObject::Vertex) { LDVertexObject* vert = static_cast<LDVertexObject*> (obj);
--- a/src/types.cpp Sun Aug 18 15:33:00 2013 +0300 +++ b/src/types.cpp Sun Aug 18 16:04:36 2013 +0300 @@ -5,7 +5,7 @@ * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -227,7 +227,7 @@ // ============================================================================= // ----------------------------------------------------------------------------- void matrix::zero() { - memset (&m_vals[0], 0, sizeof (double) * 9); + memset (&m_vals[0], 0, sizeof m_vals); } // ============================================================================= @@ -239,15 +239,15 @@ for (short i = 0; i < 3; ++i) for (short j = 0; j < 3; ++j) for (short k = 0; k < 3; ++k) - val[ (i * 3) + j] += m_vals[ (i * 3) + k] * other[ (k * 3) + j]; - + val[ (i * 3) + j] += m_vals[(i * 3) + k] * other[(k * 3) + j]; + return val; } // ============================================================================= // ----------------------------------------------------------------------------- matrix& matrix::operator= (matrix other) { - memcpy (&m_vals[0], &other.m_vals[0], sizeof (double) * 9); + memcpy (&m_vals[0], &other.m_vals[0], sizeof m_vals); return *this; }
--- a/src/types.h Sun Aug 18 15:33:00 2013 +0300 +++ b/src/types.h Sun Aug 18 16:04:36 2013 +0300 @@ -509,6 +509,6 @@ extern const vertex g_origin; // Vertex at (0, 0, 0) extern const matrix g_identity; // Identity matrix -static const double pi = 3.14159265358979323846f; +static const double pi = 3.14159265358979323846; #endif // TYPES_H \ No newline at end of file