| 985 | } |
| 986 | |
| 987 | void vtkSplineWidget::Spin(double* p1, double* p2, double* vpn) |
| 988 | { |
| 989 | // Mouse motion vector in world space |
| 990 | double v[3]; |
| 991 | v[0] = p2[0] - p1[0]; |
| 992 | v[1] = p2[1] - p1[1]; |
| 993 | v[2] = p2[2] - p1[2]; |
| 994 | |
| 995 | // Axis of rotation |
| 996 | double axis[3] = { 0.0, 0.0, 0.0 }; |
| 997 | |
| 998 | if (this->ProjectToPlane) |
| 999 | { |
| 1000 | if (this->ProjectionNormal == VTK_PROJECTION_OBLIQUE) |
| 1001 | { |
| 1002 | if (this->PlaneSource != nullptr) |
| 1003 | { |
| 1004 | double* normal = this->PlaneSource->GetNormal(); |
| 1005 | axis[0] = normal[0]; |
| 1006 | axis[1] = normal[1]; |
| 1007 | axis[2] = normal[2]; |
| 1008 | vtkMath::Normalize(axis); |
| 1009 | } |
| 1010 | else |
| 1011 | { |
| 1012 | axis[0] = 1.0; |
| 1013 | } |
| 1014 | } |
| 1015 | else |
| 1016 | { |
| 1017 | axis[this->ProjectionNormal] = 1.0; |
| 1018 | } |
| 1019 | } |
| 1020 | else |
| 1021 | { |
| 1022 | // Create axis of rotation and angle of rotation |
| 1023 | vtkMath::Cross(vpn, v, axis); |
| 1024 | if (vtkMath::Normalize(axis) == 0.0) |
| 1025 | { |
| 1026 | return; |
| 1027 | } |
| 1028 | } |
| 1029 | |
| 1030 | // Radius vector (from mean center to cursor position) |
| 1031 | double rv[3] = { p2[0] - this->Centroid[0], p2[1] - this->Centroid[1], |
| 1032 | p2[2] - this->Centroid[2] }; |
| 1033 | |
| 1034 | // Distance between center and cursor location |
| 1035 | double rs = vtkMath::Normalize(rv); |
| 1036 | |
| 1037 | // Spin direction |
| 1038 | double ax_cross_rv[3]; |
| 1039 | vtkMath::Cross(axis, rv, ax_cross_rv); |
| 1040 | |
| 1041 | // Spin angle |
| 1042 | double theta = 360.0 * vtkMath::Dot(v, ax_cross_rv) / rs; |
| 1043 | |
| 1044 | // Manipulate the transform to reflect the rotation |
no test coverage detected