private ICurve GetCurve(RoadGraphNode node1, RoadGraphNode node2) { ICurve curve; if (node1.Neighbors.Count == 1 && node2.Neighbors.Count == 1) { curve = new CubicBezierCurve( node1.Position, GetControlPoint(node1), GetControlPoint(node2), node2.Position); } else if (node1.Neighbors.Count == 1 && node2.Neighbors.Count > 1) { curve = new QuadraticBezierCurve( node1.Position, GetControlPoint(node1), node2.Position); } else if (node2.Neighbors.Count == 1 && node1.Neighbors.Count > 1) { curve = new QuadraticBezierCurve( node1.Position, GetControlPoint(node2), node2.Position); } else { curve = new LinearBezierCurve(node1.Position, node2.Position); } return(curve); }
public void Test() { LinearBezierCurve curve = new LinearBezierCurve(); Point p1 = new Point(0, 0); Point p2 = new Point(2, 2); var result = curve.GenerateLinearBezierCurve(p1, p2); var midPoint = result[result.Length / 2]; Assert.AreEqual(new Point(1, 1), midPoint); }