private Vector GetRepulsionForce(Point uPos, Point vPos, Size uSize, Size vSize, double repulsionRange)
        {
            var positionVector = (uPos - vPos);

            if (positionVector.Length == 0)
            {
                var compensationVector = new Vector(_rnd.NextDouble(), _rnd.NextDouble());
                positionVector = compensationVector * 2;
                uPos          += compensationVector;
                vPos          -= compensationVector;
            }
            positionVector.Normalize();

            var c_u = LayoutUtil.GetClippingPoint(uSize, uPos, vPos);
            var c_v = LayoutUtil.GetClippingPoint(vSize, vPos, uPos);

            var F = c_u - c_v;
            var isSameDirection = LayoutUtil.IsSameDirection(positionVector, F);
            var Fr = new Vector();

            if (isSameDirection && F.Length > repulsionRange)
            {
                return(new Vector());
            }
            double length = Math.Max(1, F.Length);

            //double length = F.LengthSquared;
            length = Math.Pow(isSameDirection ? length / (Parameters.IdealEdgeLength * 2.0) : 1 / length, 2);
            Fr     = Parameters.RepulsionConstant / length * positionVector * _phaseDependentRepulsionMultiplier;
            return(Fr);
        }
        private Vector GetSpringForce(double idealLength, Point uPos, Point vPos, Size uSize, Size vSize)
        {
            var positionVector = (uPos - vPos);

            if (positionVector.Length == 0)
            {
                var compensationVector = new Vector(_rnd.NextDouble(), _rnd.NextDouble());
                positionVector = compensationVector * 2;
                uPos          += compensationVector;
                vPos          -= compensationVector;
            }
            positionVector.Normalize();

            //get the clipping points
            var c_u = LayoutUtil.GetClippingPoint(uSize, uPos, vPos);
            var c_v = LayoutUtil.GetClippingPoint(vSize, vPos, uPos);

            Vector F = (c_u - c_v);
            bool   isSameDirection = LayoutUtil.IsSameDirection(positionVector, F);
            double length          = 0;

            if (isSameDirection)
            {
                length = F.Length - idealLength;
            }
            else
            {
                length = F.Length + idealLength;
            }

            if (F.Length == 0)
            {
                F = -positionVector;
            }
            F.Normalize();
            if (length > 0)
            {
                F *= -1;
            }

            var Fs = Math.Pow(length / (idealLength), 2) / Parameters.ElasticConstant * F;

            return(Fs);
        }