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

Method SetPhysicalToWorldMatrix

Rendering/Core/vtkRenderWindow.cxx:250–299  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

248
249//------------------------------------------------------------------------------
250void vtkRenderWindow::SetPhysicalToWorldMatrix(vtkMatrix4x4* matrix)
251{
252 if (!matrix)
253 {
254 return;
255 }
256 vtkNew<vtkMatrix4x4> currentPhysicalToWorldMatrix;
257 this->GetPhysicalToWorldMatrix(currentPhysicalToWorldMatrix);
258 bool matrixDifferent = false;
259 for (int i = 0; i < 4; i++)
260 {
261 for (int j = 0; j < 4; j++)
262 {
263 if (fabs(matrix->GetElement(i, j) - currentPhysicalToWorldMatrix->GetElement(i, j)) >= 1e-3)
264 {
265 matrixDifferent = true;
266 break;
267 }
268 }
269 }
270 if (!matrixDifferent)
271 {
272 return;
273 }
274
275 vtkNew<vtkTransform> hmdToWorldTransform;
276 hmdToWorldTransform->SetMatrix(matrix);
277
278 double translation[3] = { 0.0 };
279 hmdToWorldTransform->GetPosition(translation);
280 this->PhysicalTranslation[0] = (-1.0) * translation[0];
281 this->PhysicalTranslation[1] = (-1.0) * translation[1];
282 this->PhysicalTranslation[2] = (-1.0) * translation[2];
283
284 double scale[3] = { 0.0 };
285 hmdToWorldTransform->GetScale(scale);
286 this->PhysicalScale = scale[0];
287
288 this->PhysicalViewUp[0] = matrix->GetElement(0, 1);
289 this->PhysicalViewUp[1] = matrix->GetElement(1, 1);
290 this->PhysicalViewUp[2] = matrix->GetElement(2, 1);
291 vtkMath::Normalize(this->PhysicalViewUp);
292 this->PhysicalViewDirection[0] = (-1.0) * matrix->GetElement(0, 2);
293 this->PhysicalViewDirection[1] = (-1.0) * matrix->GetElement(1, 2);
294 this->PhysicalViewDirection[2] = (-1.0) * matrix->GetElement(2, 2);
295 vtkMath::Normalize(this->PhysicalViewDirection);
296
297 this->InvokeEvent(vtkRenderWindow::PhysicalToWorldMatrixModified);
298 this->Modified();
299}
300
301//------------------------------------------------------------------------------
302void vtkRenderWindow::GetPhysicalToWorldMatrix(vtkMatrix4x4* physicalToWorldMatrix)

Callers 1

setCameraTravelMatrixFunction · 0.80

Calls 7

InvokeEventMethod · 0.80
NormalizeFunction · 0.50
SetMatrixMethod · 0.45
GetPositionMethod · 0.45
GetScaleMethod · 0.45
ModifiedMethod · 0.45

Tested by 1

setCameraTravelMatrixFunction · 0.64