MCPcopy Create free account
hub / github.com/Kitware/VTK / Spin

Method Spin

Interaction/Widgets/vtkBrokenLineWidget.cxx:928–1001  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

926}
927
928void vtkBrokenLineWidget::Spin(double* p1, double* p2, double* vpn)
929{
930 // Mouse motion vector in world space
931 double v[3];
932 v[0] = p2[0] - p1[0];
933 v[1] = p2[1] - p1[1];
934 v[2] = p2[2] - p1[2];
935
936 // Axis of rotation
937 double axis[3] = { 0., 0., 0. };
938
939 if (this->ProjectToPlane)
940 {
941 if (this->ProjectionNormal == VTK_PROJECTION_OBLIQUE)
942 {
943 if (this->PlaneSource != nullptr)
944 {
945 double* normal = this->PlaneSource->GetNormal();
946 axis[0] = normal[0];
947 axis[1] = normal[1];
948 axis[2] = normal[2];
949 vtkMath::Normalize(axis);
950 }
951 else
952 {
953 axis[0] = 1.;
954 }
955 }
956 else
957 {
958 axis[this->ProjectionNormal] = 1.;
959 }
960 }
961 else
962 {
963 // Create axis of rotation and angle of rotation
964 vtkMath::Cross(vpn, v, axis);
965 if (vtkMath::Normalize(axis) == 0.)
966 {
967 return;
968 }
969 }
970
971 // Radius vector ( from mean center to cursor position )
972 double rv[3] = { p2[0] - this->Centroid[0], p2[1] - this->Centroid[1],
973 p2[2] - this->Centroid[2] };
974
975 // Distance between center and cursor location
976 double rs = vtkMath::Normalize(rv);
977
978 // Spin direction
979 double ax_cross_rv[3];
980 vtkMath::Cross(axis, rv, ax_cross_rv);
981
982 // Spin angle
983 double theta = 360. * vtkMath::Dot(v, ax_cross_rv) / rs;
984
985 // Manipulate the transform to reflect the rotation

Callers 1

OnMouseMoveMethod · 0.95

Calls 11

RotateWXYZMethod · 0.80
NormalizeFunction · 0.50
CrossFunction · 0.50
DotFunction · 0.50
GetNormalMethod · 0.45
IdentityMethod · 0.45
TranslateMethod · 0.45
GetCenterMethod · 0.45
TransformPointMethod · 0.45
SetCenterMethod · 0.45
UpdateMethod · 0.45

Tested by

no test coverage detected