/// <summary> /// Returns the curved moved by delta /// </summary> public void Translate(Point delta) { this.b[0] += delta; this.b[1] += delta; this.b[2] += delta; this.b[3] += delta; c = 3 * (b[1] - b[0]); e = 3 * (b[2] - b[1]) - c; l = b[3] - b[0] - c - e; pBoxNode = null; }
/// <summary> /// Moves the ellipse to the delta vector /// </summary> public void Translate(Point delta) { this.center += delta; this.box = new Rectangle(center + bAxis + aAxis, center - bAxis - aAxis); parallelogramNodeOverICurve = null; }
internal void AddChild(ParallelogramNodeOverICurve node) { children.Add(node); }
/// <summary> /// Moves the ellipse to the delta vector /// </summary> public void Translate(Point delta) { this.center += delta; this.box.Center += delta; parallelogramNodeOverICurve = null; }
static List<IntersectionInfo> CrossOverIntervals(ParallelogramNodeOverICurve n0, ParallelogramNodeOverICurve n1, List<IntersectionInfo> intersections) { //both are leafs var l0 = n0 as ParallelogramLeaf; var l1 = n1 as ParallelogramLeaf; double d0 = (l0.High - l0.Low)/2; double d1 = (l1.High - l1.Low)/2; bool found = false; for (int i = 1; i < 2; i++) { double p0 = i*d0 + l0.Low; for (int j = 1; j < 2; j++) { double p1 = j*d1 + l1.Low; double aSol, bSol; Point x; bool r; if (l0.Chord == null && l1.Chord == null) r = CrossWithinIntervalsWithGuess(n0.Seg, n1.Seg, l0.Low, l0.High, l1.Low, l1.High, p0, p1, out aSol, out bSol, out x); else if (l0.Chord != null && l1.Chord == null) { r = CrossWithinIntervalsWithGuess(l0.Chord, n1.Seg, 0, 1, l1.Low, l1.High, 0.5*i, p1, out aSol, out bSol, out x); if (r) aSol = l0.Low + aSol*(l0.High - l0.Low); } else if (l0.Chord == null) { //&& l1.Chord != null) r = CrossWithinIntervalsWithGuess(n0.Seg, l1.Chord, l0.Low, l0.High, 0, 1, p0, 0.5*j, out aSol, out bSol, out x); if (r) bSol = l1.Low + bSol*(l1.High - l1.Low); } else //if (l0.Chord != null && l1.Chord != null) { r = CrossWithinIntervalsWithGuess(l0.Chord, l1.Chord, 0, 1, 0, 1, 0.5*i, 0.5*j, out aSol, out bSol, out x); if (r) { bSol = l1.Low + bSol*(l1.High - l1.Low); aSol = l0.Low + aSol*(l0.High - l0.Low); } } if (r) { AddIntersection(l0, l1, intersections, aSol, bSol, x); found = true; } } } if (!found) GoDeeper(ref intersections, l0, l1); return intersections; }
static IntersectionInfo CrossOverIntervalsOne(ParallelogramNodeOverICurve n0, ParallelogramNodeOverICurve n1) { //both are leafs var l0 = n0 as ParallelogramLeaf; var l1 = n1 as ParallelogramLeaf; double d0 = (l0.High - l0.Low)/2; double d1 = (l1.High - l1.Low)/2; for (int i = 1; i < 2; i++) { double p0 = i*d0 + l0.Low; for (int j = 1; j < 2; j++) { double p1 = j*d1 + l1.Low; double aSol, bSol; Point x; bool r; if (l0.Chord == null && l1.Chord == null) r = CrossWithinIntervalsWithGuess(n0.Seg, n1.Seg, l0.Low, l0.High, l1.Low, l1.High, p0, p1, out aSol, out bSol, out x); else if (l0.Chord != null && l1.Chord == null) { r = CrossWithinIntervalsWithGuess(l0.Chord, n1.Seg, 0, 1, l1.Low, l1.High, 0.5*i, p1, out aSol, out bSol, out x); if (r) aSol = l0.Low + aSol*(l0.High - l0.Low); } else if (l0.Chord == null) { r = CrossWithinIntervalsWithGuess(n0.Seg, l1.Chord, l0.Low, l0.High, 0, 1, p0, 0.5*j, out aSol, out bSol, out x); if (r) bSol = l1.Low + bSol*(l1.High - l1.Low); } else //if (l0.Chord != null && l1.Chord != null) { r = CrossWithinIntervalsWithGuess(l0.Chord, l1.Chord, 0, 1, 0, 1, 0.5*i, 0.5*j, out aSol, out bSol, out x); if (r) { bSol = l1.Low + bSol*(l1.High - l1.Low); aSol = l0.Low + aSol*(l0.High - l0.Low); } } if (r) return CreateIntersectionOne(l0, l1, aSol, bSol, x); } } return GoDeeperOne(l0, l1); }
static void CurveCurveXWithParallelogramNodes(ParallelogramNodeOverICurve n0, ParallelogramNodeOverICurve n1, ref List<IntersectionInfo> intersections) { if (!Parallelogram.Intersect(n0.Parallelogram, n1.Parallelogram)) //Console.WriteLine("Boxes {0} and {1} do not intersect", n0.Box, n1.Box); return; //if(Routing.debug) // Testing.InternalTest.Show(n0, n1, n0.Seg, n1.Seg); var n0Pb = n0 as ParallelogramInternalTreeNode; var n1Pb = n1 as ParallelogramInternalTreeNode; if (n0Pb != null && n1Pb != null) foreach (ParallelogramNodeOverICurve n00 in n0Pb.Children) foreach (ParallelogramNodeOverICurve n11 in n1Pb.Children) CurveCurveXWithParallelogramNodes(n00, n11, ref intersections); else if (n1Pb != null) foreach (ParallelogramNodeOverICurve n in n1Pb.Children) CurveCurveXWithParallelogramNodes(n0, n, ref intersections); else if (n0Pb != null) foreach (ParallelogramNodeOverICurve n in n0Pb.Children) CurveCurveXWithParallelogramNodes(n, n1, ref intersections); else intersections = CrossOverIntervals(n0, n1, intersections); }
static IntersectionInfo CurveCurveXWithParallelogramNodesOne(ParallelogramNodeOverICurve n0, ParallelogramNodeOverICurve n1) { if (!Parallelogram.Intersect(n0.Parallelogram, n1.Parallelogram)) //Console.WriteLine("Boxes {0} and {1} do not intersect", n0.Box, n1.Box); return null; var n0Pb = n0 as ParallelogramInternalTreeNode; var n1Pb = n1 as ParallelogramInternalTreeNode; if (n0Pb != null && n1Pb != null) foreach (ParallelogramNodeOverICurve n00 in n0Pb.Children) foreach (ParallelogramNodeOverICurve n11 in n1Pb.Children) { IntersectionInfo x = CurveCurveXWithParallelogramNodesOne(n00, n11); if (x != null) return x; } else if (n1Pb != null) foreach (ParallelogramNodeOverICurve n in n1Pb.Children) { IntersectionInfo x = CurveCurveXWithParallelogramNodesOne(n0, n); if (x != null) return x; } else if (n0Pb != null) foreach (ParallelogramNodeOverICurve n in n0Pb.Children) { IntersectionInfo x = CurveCurveXWithParallelogramNodesOne(n, n1); if (x != null) return x; } else return CrossOverIntervalsOne(n0, n1); return null; }