Rotate the camera by 'angle' degrees about the point and around the vector/axis .
| 609 | // and around the vector/axis <ax, ay, az>. |
| 610 | // |
| 611 | void vtkInteractorStyleUnicam::MyRotateCamera( |
| 612 | double cx, double cy, double cz, double ax, double ay, double az, double angle) |
| 613 | { |
| 614 | angle *= 180.0 / vtkMath::Pi(); // vtk uses degrees, not radians |
| 615 | |
| 616 | double p[4], f[4], u[4]; |
| 617 | vtkCamera* camera = this->CurrentRenderer->GetActiveCamera(); |
| 618 | camera->GetPosition(p); |
| 619 | camera->GetFocalPoint(f); |
| 620 | camera->GetViewUp(u); |
| 621 | p[3] = f[3] = 1.0; // (points) |
| 622 | u[3] = 0.0; // (a vector) |
| 623 | |
| 624 | vtkTransform* t = vtkTransform::New(); |
| 625 | t->PostMultiply(); |
| 626 | t->Identity(); |
| 627 | t->Translate(-cx, -cy, -cz); |
| 628 | t->RotateWXYZ(angle, ax, ay, az); |
| 629 | t->Translate(cx, cy, cz); |
| 630 | |
| 631 | double new_p[4], new_f[4]; |
| 632 | t->MultiplyPoint(p, new_p); |
| 633 | t->MultiplyPoint(f, new_f); |
| 634 | |
| 635 | double new_u[4]; |
| 636 | t->Identity(); |
| 637 | t->RotateWXYZ(angle, ax, ay, az); |
| 638 | t->MultiplyPoint(u, new_u); |
| 639 | |
| 640 | camera->SetPosition(new_p[0], new_p[1], new_p[2]); |
| 641 | camera->SetFocalPoint(new_f[0], new_f[1], new_f[2]); |
| 642 | camera->SetViewUp(new_u[0], new_u[1], new_u[2]); |
| 643 | |
| 644 | // IMPORTANT! If you don't re-compute view plane normal, the camera |
| 645 | // view gets all messed up. |
| 646 | camera->ComputeViewPlaneNormal(); |
| 647 | t->Delete(); |
| 648 | } |
| 649 | |
| 650 | // Translate the camera by the offset <v[0], v[1], v[2]>. Update |
| 651 | // the camera clipping range. |
nothing calls this directly
no test coverage detected