VTK6 represents a major upgrade to VTK. The upgrade presents an opportunity to provide consistent representation and usage of Pi and TwoPi.
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.
Provide a consistent use if Pi and TwoPi throughout the toolkit. Currently Pi is used in the following manner:
- vtkMath::Pi() returns a single precision representation of Pi.
- vtkMath::DoublePi() returns a double precision representation of Pi.
- Explict forms like 3.1415927
Similar uses exist for TwoPi, DoubleTwoPi and 6.28...
Pi usage was measured using the unix grep command on just .cxx files.
- vtkMath::Pi() - 64 files
- vtkMath::DoublePi() - 13 files
- Explicit Pi - 19 files
- vtkMath::TwoPi - 0 files
- vtkMath::DoubleTwoPi() - 4 files
- Explicit 2Pi - 5 files
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.
A gerrit patch introduced the following changes to 41 files:
- vtkMath::Pi now returns double.
- vtkMath::TwoPi() is replaced with 2.0 * vtkMath::Pi().
- Remove vtkMath::DoublePi and vtkMath::DoubleTwoPi and mark them as deprecated.
- Replace explicit use of 3.1415... and 6.28... with the vtkMath constants.
Because of these changes, 4 baseline images were updated.
In addition, the conversion to double uncovered a precision-related bug in vtkSuperquadricSource. The diffs for that bug fix are here.
Gerrit reviewers should watch for the introduction of explicit representation of Pi and 2Pi