示例#1
0
            private static double[][] GetCube_Finish(Dot[] dots, Tuple<double[], double[]> aabb, double stopRadiusPercent, int stopIterationCount)
            {
                const double MOVEPERCENT = .1;

                CapToCube(dots, aabb);

                double radius = MathND.GetLength(MathND.Subtract(aabb.Item2, aabb.Item1)) / 2;
                double stopAmount = radius * stopRadiusPercent;

                double? minDistance = GetMinDistance(dots, radius, aabb);

                for (int cntr = 0; cntr < stopIterationCount; cntr++)
                {
                    double amountMoved = MoveStep(dots, MOVEPERCENT, aabb, minDistance);
                    if (amountMoved < stopAmount)
                    {
                        break;
                    }
                }

                //NOTE: The movable dots are always the front of the list, so the returned array will be the same positions as the initial movable array
                return dots.
                    Where(o => !o.IsStatic).
                    Select(o => o.Position).
                    ToArray();
            }