Coordinate measuring machines and machine tools self-calibration and error correction