| 287 | } |
| 288 | |
| 289 | void vtkWidgetRepresentation::UpdatePropPose(vtkProp3D* prop3D, const double* pos1, |
| 290 | const double* orient1, const double* pos2, const double* orient2) |
| 291 | { |
| 292 | double trans[3]; |
| 293 | for (int i = 0; i < 3; i++) |
| 294 | { |
| 295 | trans[i] = pos2[i] - pos1[i]; |
| 296 | } |
| 297 | |
| 298 | vtkTransform* newTransform = this->TempTransform; |
| 299 | if (prop3D->GetUserMatrix() != nullptr) |
| 300 | { |
| 301 | vtkTransform* t = newTransform; |
| 302 | t->Identity(); |
| 303 | t->PostMultiply(); |
| 304 | t->Concatenate(prop3D->GetUserMatrix()); |
| 305 | t->Translate(trans); |
| 306 | prop3D->GetUserMatrix()->DeepCopy(t->GetMatrix()); |
| 307 | } |
| 308 | else |
| 309 | { |
| 310 | prop3D->AddPosition(trans); |
| 311 | } |
| 312 | |
| 313 | // compute the net rotation |
| 314 | vtkQuaternion<double> q1; |
| 315 | q1.SetRotationAngleAndAxis( |
| 316 | vtkMath::RadiansFromDegrees(orient1[0]), orient1[1], orient1[2], orient1[3]); |
| 317 | vtkQuaternion<double> q2; |
| 318 | q2.SetRotationAngleAndAxis( |
| 319 | vtkMath::RadiansFromDegrees(orient2[0]), orient2[1], orient2[2], orient2[3]); |
| 320 | q1.Conjugate(); |
| 321 | q2 = q2 * q1; |
| 322 | double axis[4]; |
| 323 | axis[0] = vtkMath::DegreesFromRadians(q2.GetRotationAngleAndAxis(axis + 1)); |
| 324 | |
| 325 | vtkMatrix4x4* oldMatrix = this->TempMatrix; |
| 326 | prop3D->GetMatrix(oldMatrix); |
| 327 | |
| 328 | double orig[3]; |
| 329 | prop3D->GetOrigin(orig); |
| 330 | |
| 331 | newTransform->Identity(); |
| 332 | newTransform->PostMultiply(); |
| 333 | if (prop3D->GetUserMatrix() != nullptr) |
| 334 | { |
| 335 | newTransform->Concatenate(prop3D->GetUserMatrix()); |
| 336 | } |
| 337 | else |
| 338 | { |
| 339 | newTransform->Concatenate(oldMatrix); |
| 340 | } |
| 341 | |
| 342 | newTransform->Translate(-(pos1[0]), -(pos1[1]), -(pos1[2])); |
| 343 | |
| 344 | newTransform->RotateWXYZ(axis[0], axis[1], axis[2], axis[3]); |
| 345 | |
| 346 | newTransform->Translate(pos1[0], pos1[1], pos1[2]); |
no test coverage detected