Beispiel #1
0
        public static bool EdgesCross(PedigreeCoupleEdge a, PedigreeCoupleEdge b, bool hiding)
        {
            if (a == null || b == null)
                return false;

            if (hiding)
            {
                if (!a.u.mother.bloodRelative || !a.u.father.bloodRelative || !a.v.mother.bloodRelative || !a.v.father.bloodRelative)
                    return false;
                if (!b.u.mother.bloodRelative || !b.u.father.bloodRelative || !b.v.mother.bloodRelative || !b.v.father.bloodRelative)
                    return false;
            }
            bool aAndBShareAVertex = false;
            aAndBShareAVertex = aAndBShareAVertex || a.u == b.u;
            aAndBShareAVertex = aAndBShareAVertex || a.v == b.u;
            aAndBShareAVertex = aAndBShareAVertex || a.u == b.v;
            aAndBShareAVertex = aAndBShareAVertex || a.v == b.v;

            if (aAndBShareAVertex)
                return false;

            double x1 = a.u.point.x;
            double y1 = a.u.point.y;
            double x2 = a.v.point.x;
            double y2 = a.v.point.y;
            double x3 = b.u.point.x;
            double y3 = b.u.point.y;
            double x4 = b.v.point.x;
            double y4 = b.v.point.y;

            return PedigreeUtils.LinesIntersect(x1, y1, x2, y2, x3, y3, x4, y4);
        }
        private static void CollapseEdge(PedigreeCoupleEdge edge,PedigreeModel model)
        {
            double avgX = (edge.u.point.x + edge.v.point.x) / 2;
            if (!model.pointsBeingDragged.Contains(edge.u.point))
                edge.u.point.x = avgX;
            if (!model.pointsBeingDragged.Contains(edge.v.point))
                edge.v.point.x = avgX;

            double avgY = (edge.u.point.y + edge.v.point.y) / 2;
            if (!model.pointsBeingDragged.Contains(edge.u.point))
                edge.u.point.y = avgY;
            if (!model.pointsBeingDragged.Contains(edge.v.point))
                edge.v.point.y = avgY;
        }
        private static void ShrinkEdge(PedigreeCoupleEdge edge, double strength)
        {
            PointWithVelocity a = edge.u.point;
            PointWithVelocity b = edge.v.point;

            double distance = b.x - a.x;

            double forceX = strength * distance;
            a.dx += forceX;
            b.dx -= forceX;
        }