private void CalculateMaxDistances() { const int tdiv = 180; const int pdiv = 360; const double dθ = 1 * System.Math.PI / tdiv; const double dφ = 2 * System.Math.PI / pdiv; var doubleUtils = new DoubleUtils(1e-12); var xmax = new double[tdiv + 1]; var ymax = new double[tdiv + 1]; var zmax = new double[tdiv + 1]; Parallel.For(0, tdiv + 1, it => { for (var ip = 0; ip <= pdiv; ++ip) { var point = GetSurfacePoint(it * dθ, ip * dφ); if (doubleUtils.Less(xmax[it], System.Math.Abs(point.X))) { xmax[it] = System.Math.Abs(point.X); } if (doubleUtils.Less(ymax[it], System.Math.Abs(point.Y))) { ymax[it] = System.Math.Abs(point.Y); } if (doubleUtils.Less(zmax[it], System.Math.Abs(point.Z))) { zmax[it] = System.Math.Abs(point.Z); } } }); _xmax = 0; _ymax = 0; _zmax = 0; for (var it = 0; it <= tdiv; ++it) { _xmax = System.Math.Max(_xmax, xmax[it]); _ymax = System.Math.Max(_ymax, ymax[it]); _zmax = System.Math.Max(_zmax, zmax[it]); } }