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

Method ComputeProjectionTransform

Rendering/Core/vtkCamera.cxx:1060–1149  ·  view source on GitHub ↗

------------------------------------------------------------------------------ Compute the projection transform matrix. This is used in converting between view and world coordinates.

Source from the content-addressed store, hash-verified

1058// Compute the projection transform matrix. This is used in converting
1059// between view and world coordinates.
1060void vtkCamera::ComputeProjectionTransform(double aspect, double nearz, double farz)
1061{
1062 this->ProjectionTransform->Identity();
1063
1064 // apply user defined transform last if there is one
1065 if (this->UserTransform)
1066 {
1067 this->ProjectionTransform->Concatenate(this->UserTransform->GetMatrix());
1068 }
1069
1070 if (this->UseExplicitProjectionTransformMatrix)
1071 {
1072 assert(this->ExplicitProjectionTransformMatrix != nullptr);
1073 this->ProjectionTransform->Concatenate(this->ExplicitProjectionTransformMatrix);
1074 return;
1075 }
1076
1077 if (this->UseExplicitAspectRatio)
1078 {
1079 aspect = this->ExplicitAspectRatio;
1080 }
1081
1082 // adjust Z-buffer range
1083 this->ProjectionTransform->AdjustZBuffer(-1, +1, nearz, farz);
1084
1085 if (this->ParallelProjection)
1086 {
1087 // set up a rectangular parallelipiped
1088
1089 double width = this->ParallelScale * aspect;
1090 double height = this->ParallelScale;
1091
1092 double xmin = (this->WindowCenter[0] - 1.0) * width;
1093 double xmax = (this->WindowCenter[0] + 1.0) * width;
1094 double ymin = (this->WindowCenter[1] - 1.0) * height;
1095 double ymax = (this->WindowCenter[1] + 1.0) * height;
1096
1097 this->ProjectionTransform->Ortho(
1098 xmin, xmax, ymin, ymax, this->ClippingRange[0], this->ClippingRange[1]);
1099 }
1100 else if (this->UseOffAxisProjection)
1101 {
1102 this->ComputeOffAxisProjectionFrustum();
1103 }
1104 else
1105 {
1106 // set up a perspective frustum
1107
1108 double tmp = tan(vtkMath::RadiansFromDegrees(this->ViewAngle) / 2.);
1109 double width;
1110 double height;
1111 if (this->UseHorizontalViewAngle)
1112 {
1113 width = this->ClippingRange[0] * tmp;
1114 height = this->ClippingRange[0] * tmp / aspect;
1115 }
1116 else
1117 {

Calls 11

AdjustZBufferMethod · 0.80
OrthoMethod · 0.80
FrustumMethod · 0.80
StereoMethod · 0.80
assertFunction · 0.50
tanFunction · 0.50
IdentityMethod · 0.45
ConcatenateMethod · 0.45
GetMatrixMethod · 0.45
ShearMethod · 0.45

Tested by

no test coverage detected