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

Method ComputeRotationAndTranlation

Rendering/Annotation/vtkAxisFollower.cxx:287–349  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

285
286//------------------------------------------------------------------------------
287void vtkAxisFollower::ComputeRotationAndTranlation(vtkRenderer* ren, double translation[3],
288 double rX[3], double rY[3], double rZ[3], vtkAxisActor* axis)
289{
290 double autoScaleHoriz =
291 this->AutoScale(ren, this->Camera, this->ScreenOffsetVector[0], this->Position);
292 double autoScaleVert =
293 this->AutoScale(ren, this->Camera, this->ScreenOffsetVector[1], this->Position);
294
295 double dop[3];
296 this->Camera->GetDirectionOfProjection(dop);
297 vtkMath::Normalize(dop);
298
299 this->CalculateOrthogonalVectors(rX, rY, rZ, axis, dop, ren);
300
301 double dotVal = vtkMath::Dot(rZ, dop);
302
303 double origRx[3] = { rX[0], rX[1], rX[2] };
304 double origRy[3] = { rY[0], rY[1], rY[2] };
305
306 // NOTE: Basically the idea here is that dotVal will be positive
307 // only when we have projection direction aligned with our z direction
308 // and when that happens it means that our Y is inverted.
309 if (dotVal > 0)
310 {
311 rY[0] = -rY[0];
312 rY[1] = -rY[1];
313 rY[2] = -rY[2];
314 }
315
316 // Check visibility at current view angle.
317 if (this->EnableViewAngleLOD)
318 {
319 this->ExecuteViewAngleVisibility(rZ);
320 }
321 else
322 {
323 this->VisibleAtCurrentViewAngle = 1;
324 }
325
326 // Since we already stored all the possible Y axes that are geometry aligned,
327 // we compare our vertical vector with these vectors and if it aligns then we
328 // translate in opposite direction.
329 int axisPosition = this->Axis->GetAxisPosition();
330 int vertSign;
331 double vertDotVal1 =
332 vtkMath::Dot(AxisAlignedY[this->Axis->GetAxisType()][axisPosition][0], origRy);
333 double vertDotVal2 =
334 vtkMath::Dot(AxisAlignedY[this->Axis->GetAxisType()][axisPosition][1], origRy);
335
336 if (fabs(vertDotVal1) > fabs(vertDotVal2))
337 {
338 vertSign = (vertDotVal1 > 0 ? -1 : 1);
339 }
340 else
341 {
342 vertSign = (vertDotVal2 > 0 ? -1 : 1);
343 }
344

Callers 1

Calls 5

AutoScaleMethod · 0.95
NormalizeFunction · 0.50
DotFunction · 0.50

Tested by

no test coverage detected