VTK/VTK6/Migration/DoublePrecisionPi

From KitwarePublic
Jump to navigationJump to search

VTK6 represents a major upgrade to VTK. The upgrade presents an opportunity to provide consistent representation and usage of Pi and TwoPi.

This experiment uses the DMAIC methodology of the Six Sigma management process to "Define", "Measure", "Analyze", "Improve" and "Control" valgrind defects in VTK.

The basic methodology (from Wikipedia) consists of the following five steps:

  • Define process goals that are consistent with customer demands and VTK's strategy.
  • Measure key aspects of the current process and collect relevant data.
  • Analyze the data to verify cause-and-effect relationships. Determine what the relationships are, and attempt to ensure that all factors have been considered.
  • Improve or optimize the process.
  • Control to ensure that any deviations from target are corrected before they result in defects. Set up pilot runs to establish software quality, move on to production, set up control mechanisms and continuously monitor the process.

Define

Provide a consistent use if Pi and TwoPi throughout the toolkit. Currently Pi is used in the following manner:

  1. vtkMath::Pi() returns a single precision representation of Pi.
  2. vtkMath::DoublePi() returns a double precision representation of Pi.
  3. Explict forms like 3.1415927
    1. 3.141593
    2. 3.1415926
    3. 3.141592653589
    4. 3.141592654
    5. 3.14159265358979
    6. 3.141592653589793
    7. 3.14159265358979323846

Similar uses exist for TwoPi, DoubleTwoPi and 6.28...

Measure

Pi usage was measured using the unix grep command on just .cxx files.

  1. vtkMath::Pi() - 64 files
  2. vtkMath::DoublePi() - 13 files
  3. Explicit Pi - 19 files
  4. vtkMath::TwoPi - 0 files
  5. vtkMath::DoubleTwoPi() - 4 files
  6. Explicit 2Pi - 5 files

Analyze

Sometime around vtk4.4, most floating point calculations were converted from single precision to double precision. Apparently at that time, the vtkMath::Pi() was not converted to double. Rather, vtkMath::DoublePi() was introduced. Also, throughout the toolkit, some developers chose to use explicit representations of Pi. These varied in precision.

Improve

Control

Gerrit reviewers should watch for the introduction of explicit representation of Pi and 2Pi