----------------------------------------------------------------------------
| 116 | |
| 117 | //---------------------------------------------------------------------------- |
| 118 | void vtkCone::UpdateTransform() |
| 119 | { |
| 120 | // vtkCone is aligned to the x-axis. Setup a transform that rotates |
| 121 | // <1, 0, 0> to the vector in Axis and translates according to origin |
| 122 | const vtkVector3d xAxis(1., 0., 0.); |
| 123 | vtkVector3d axis(this->Axis); |
| 124 | |
| 125 | vtkVector3d cross = xAxis.Cross(axis); |
| 126 | double crossNorm = cross.Normalize(); |
| 127 | double dot = xAxis.Dot(axis); |
| 128 | double angle = vtkMath::DegreesFromRadians(std::atan2(crossNorm, dot)); |
| 129 | |
| 130 | vtkNew<vtkTransform> xform; |
| 131 | xform->Identity(); |
| 132 | xform->Translate(this->Origin); |
| 133 | xform->RotateWXYZ(angle, cross.GetData()); |
| 134 | xform->Inverse(); |
| 135 | |
| 136 | this->SetTransform(xform.GetPointer()); |
| 137 | this->Modified(); |
| 138 | } |
| 139 | VTK_ABI_NAMESPACE_END |
no test coverage detected