194 { |
194 { |
195 if (primitive) |
195 if (primitive) |
196 primitive->restore(originalState); // Restoring does not change 'originalState' |
196 primitive->restore(originalState); // Restoring does not change 'originalState' |
197 } |
197 } |
198 |
198 |
|
199 /* |
|
200 * Rotates the primitive around its origin. The angle depends on its resolution and the passed 'factor' parameter. |
|
201 */ |
199 void CircularPrimitiveEditor::rotate(double factor) |
202 void CircularPrimitiveEditor::rotate(double factor) |
200 { |
203 { |
201 if (primitive) |
204 if (primitive) |
202 { |
205 { |
203 double angle = factor * 360.0 / primitive->divisions(); |
206 double angle = factor * 360.0 / primitive->divisions(); |
204 |
|
205 QQuaternion rotation = QQuaternion::fromAxisAndAngle({0.0f, 1.0f, 0.0f}, angle); |
|
206 QMatrix4x4 matrix = primitive->transformationMatrix(); |
207 QMatrix4x4 matrix = primitive->transformationMatrix(); |
207 matrix.rotate(rotation); |
208 matrix.rotate(QQuaternion::fromAxisAndAngle({0.0f, 1.0f, 0.0f}, angle)); |
208 primitive->setTransformationMatrix(matrix); |
209 primitive->setTransformationMatrix(matrix); |
209 } |
210 } |
210 } |
211 } |