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

Method AdjustViewport

Common/Transforms/vtkPerspectiveTransform.cxx:215–228  ·  view source on GitHub ↗

------------------------------------------------------------------------------ Utility for adjusting the window range to a new one. Usually the previous range was ([-1,+1],[-1,+1]) as per Ortho and Frustum, and you are mapping to the display coordinate range ([0,width-1],[0,height-1]).

Source from the content-addressed store, hash-verified

213// previous range was ([-1,+1],[-1,+1]) as per Ortho and Frustum, and you
214// are mapping to the display coordinate range ([0,width-1],[0,height-1]).
215void vtkPerspectiveTransform::AdjustViewport(double oldXMin, double oldXMax, double oldYMin,
216 double oldYMax, double newXMin, double newXMax, double newYMin, double newYMax)
217{
218 double matrix[4][4];
219 vtkMatrix4x4::Identity(*matrix);
220
221 matrix[0][0] = (newXMax - newXMin) / (oldXMax - oldXMin);
222 matrix[1][1] = (newYMax - newYMin) / (oldYMax - oldYMin);
223
224 matrix[0][3] = (newXMin * oldXMax - newXMax * oldXMin) / (oldXMax - oldXMin);
225 matrix[1][3] = (newYMin * oldYMax - newYMax * oldYMin) / (oldYMax - oldYMin);
226
227 this->Concatenate(*matrix);
228}
229
230//------------------------------------------------------------------------------
231// Utility for adjusting the min/max range of the Z buffer. Usually

Callers 1

Calls 2

ConcatenateMethod · 0.95
IdentityFunction · 0.70

Tested by

no test coverage detected