equal
deleted
inserted
replaced
91 case Plane: |
91 case Plane: |
92 { |
92 { |
93 QLineF delta(m_lastPos, p); |
93 QLineF delta(m_lastPos, p); |
94 m_angularVelocity = 180*delta.length() / (PI*msecs); |
94 m_angularVelocity = 180*delta.length() / (PI*msecs); |
95 m_axis = QVector3D(-delta.dy(), delta.dx(), 0.0f).normalized(); |
95 m_axis = QVector3D(-delta.dy(), delta.dx(), 0.0f).normalized(); |
96 m_axis = transformation.rotateVector(m_axis); |
96 m_axis = transformation.rotatedVector(m_axis); |
97 m_rotation = QQuaternion::fromAxisAndAngle(m_axis, 180 / PI * delta.length()) * m_rotation; |
97 m_rotation = QQuaternion::fromAxisAndAngle(m_axis, 180 / PI * delta.length()) * m_rotation; |
98 } |
98 } |
99 break; |
99 break; |
100 case Sphere: |
100 case Sphere: |
101 { |
101 { |
116 m_axis = QVector3D::crossProduct(lastPos3D, currentPos3D); |
116 m_axis = QVector3D::crossProduct(lastPos3D, currentPos3D); |
117 float angle = 180 / PI * asin(sqrt(QVector3D::dotProduct(m_axis, m_axis))); |
117 float angle = 180 / PI * asin(sqrt(QVector3D::dotProduct(m_axis, m_axis))); |
118 |
118 |
119 m_angularVelocity = angle / msecs; |
119 m_angularVelocity = angle / msecs; |
120 m_axis.normalize(); |
120 m_axis.normalize(); |
121 m_axis = transformation.rotateVector(m_axis); |
121 m_axis = transformation.rotatedVector(m_axis); |
122 m_rotation = QQuaternion::fromAxisAndAngle(m_axis, angle) * m_rotation; |
122 m_rotation = QQuaternion::fromAxisAndAngle(m_axis, angle) * m_rotation; |
123 } |
123 } |
124 break; |
124 break; |
125 } |
125 } |
126 |
126 |