public HermiteSpline InteractiveHermiteSpline(double[] knots, double[] controlPoints, double[] derivations) { var ellipses = new List <Ellipse>(knots.Length); var derivationEllipses = new List <Ellipse>(derivations.Length); double pax, pay; double auxKnot, auxFunctionValue; for (int i = 0; i < knots.Length; i++) { pax = TransformCoordinates.WorldAreaToPlotAreaX(knots[i], _plotArea, _worldArea); pay = TransformCoordinates.WorldAreaToPlotAreaY(controlPoints[i], _plotArea, _worldArea); ellipses.Add(_auxiliaryEngine.DrawEllipse(pax - W_DIV_2, pay - H_DIV_2, KNOT_COLOR2)); auxKnot = knots[i] - DERIVATIVE_AUX_KNOT_DISTANCE; auxFunctionValue = MathOperations.LinearFunction(auxKnot, knots[i], controlPoints[i], derivations[i]); pax = TransformCoordinates.WorldAreaToPlotAreaX(auxKnot, _plotArea, _worldArea); pay = TransformCoordinates.WorldAreaToPlotAreaY(auxFunctionValue, _plotArea, _worldArea); derivationEllipses.Add(_auxiliaryEngine.DrawEllipse(pax - W_DIV_2, pay - H_DIV_2, AUX_KNOT_COLOR2)); } // List<Line> linesOfSpline = HermiteSplineLines(knots,controlPoints); HermiteSpline spline = HermiteSpline(knots, controlPoints, derivations); spline.DragEllipses = ellipses; spline.DerivationEllipses = derivationEllipses; return(spline); }
public BSpline InteractiveBSpline(int degree, double[] knots, double[] controlPoints, bool containsServiceKnots) { var ellipses = new List <Ellipse>(); var serviceKnots = containsServiceKnots ? knots : SilverlightApplication3.BSpline.ServiceKnots(knots, degree, true); double PAControlPoint; double PAKnot; for (int i = 0; i < controlPoints.Length; i++) { PAKnot = TransformCoordinates.WorldAreaToPlotAreaX(serviceKnots[i + 1], _plotArea, _worldArea); PAControlPoint = TransformCoordinates.WorldAreaToPlotAreaY(controlPoints[i], _plotArea, _worldArea); if (i < degree - 1) { ellipses.Add(_auxiliaryEngine.DrawEllipse(PAKnot - W_DIV_2, PAControlPoint - H_DIV_2, AUX_KNOT_COLOR)); } else { ellipses.Add(_auxiliaryEngine.DrawEllipse(PAKnot - W_DIV_2, PAControlPoint - H_DIV_2, KNOT_COLOR)); } } var bSpline = BSpline(degree, serviceKnots, controlPoints, true); bSpline.DragEllipses = ellipses; //gbSpline.isInteractive = true; return(bSpline); }
public GlobalBSpline InteractiveGlobalBSpline(int degree, double[] knots, double[] referencePoints, double leftDerivation, double rightDerivation, bool containsServiceKnots) { var controlPointsAndAuxKnots = _globalBSplineEngine.GlobalControlPointsAndAuxiliaryKnots(degree, knots, referencePoints, leftDerivation, rightDerivation, containsServiceKnots); var spline = InteractiveGlobalBSpline(degree, controlPointsAndAuxKnots.Item2, controlPointsAndAuxKnots.Item1, referencePoints, true); spline.LeftDerivation = leftDerivation; spline.RightDerivation = rightDerivation; Ellipse leftDerEll, rightDerEll; double pax, pay; if (containsServiceKnots) { var auxKnot = knots[degree] - DERIVATIVE_AUX_KNOT_DISTANCE; var auxReferencePoint = MathOperations.LinearFunction(auxKnot, knots[degree], referencePoints.First(), leftDerivation); pax = TransformCoordinates.WorldAreaToPlotAreaX(auxKnot, _plotArea, _worldArea); pay = TransformCoordinates.WorldAreaToPlotAreaY(auxReferencePoint, _plotArea, _worldArea); leftDerEll = _auxiliaryEngine.DrawEllipse(pax - W_DIV_2, pay - H_DIV_2, AUX_KNOT_COLOR3); auxKnot = knots[degree + referencePoints.Length - 1] + DERIVATIVE_AUX_KNOT_DISTANCE; auxReferencePoint = MathOperations.LinearFunction(auxKnot, knots[degree + referencePoints.Length - 1], referencePoints.Last(), rightDerivation); pax = TransformCoordinates.WorldAreaToPlotAreaX(auxKnot, _plotArea, _worldArea); pay = TransformCoordinates.WorldAreaToPlotAreaY(auxReferencePoint, _plotArea, _worldArea); rightDerEll = _auxiliaryEngine.DrawEllipse(pax - W_DIV_2, pay - H_DIV_2, AUX_KNOT_COLOR3); } else { var auxKnot = knots.First() - DERIVATIVE_AUX_KNOT_DISTANCE; var auxReferencePoint = MathOperations.LinearFunction(auxKnot, knots.First(), referencePoints.First(), leftDerivation); pax = TransformCoordinates.WorldAreaToPlotAreaX(auxKnot, _plotArea, _worldArea); pay = TransformCoordinates.WorldAreaToPlotAreaY(auxReferencePoint, _plotArea, _worldArea); leftDerEll = _auxiliaryEngine.DrawEllipse(pax - W_DIV_2, pay - H_DIV_2, AUX_KNOT_COLOR3); auxKnot = knots.Last() + DERIVATIVE_AUX_KNOT_DISTANCE; auxReferencePoint = MathOperations.LinearFunction(auxKnot, knots.Last(), referencePoints.Last(), rightDerivation); pax = TransformCoordinates.WorldAreaToPlotAreaX(auxKnot, _plotArea, _worldArea); pay = TransformCoordinates.WorldAreaToPlotAreaY(auxReferencePoint, _plotArea, _worldArea); rightDerEll = _auxiliaryEngine.DrawEllipse(pax - W_DIV_2, pay - H_DIV_2, AUX_KNOT_COLOR3); } spline.LeftDerivationEllipse = leftDerEll; spline.RightDerivationEllipse = rightDerEll; return(spline); }
internal GlobalBSpline InteractiveGlobalBSpline(int degree, double[] knots, double[] controlPoints, double[] referencePoints, bool containsServiceKnots) { var ellipses = new List <Ellipse>(); var cpEllipses = new List <Ellipse>(); var serviceKnots = containsServiceKnots ? knots : SilverlightApplication3.BSpline.ServiceKnots(knots, degree, true); double PAReferencePoint; double PAKnot; for (int i = 0; i < referencePoints.Length; i++) { PAKnot = TransformCoordinates.WorldAreaToPlotAreaX(serviceKnots[degree + i], _plotArea, _worldArea); PAReferencePoint = TransformCoordinates.WorldAreaToPlotAreaY(referencePoints[i], _plotArea, _worldArea); ellipses.Add(_auxiliaryEngine.DrawEllipse(PAKnot - W_DIV_2, PAReferencePoint - H_DIV_2, KNOT_COLOR2)); } double PAControlPoint; for (int i = 0; i < controlPoints.Length; i++) { PAKnot = TransformCoordinates.WorldAreaToPlotAreaX(serviceKnots[i + 1], _plotArea, _worldArea); PAControlPoint = TransformCoordinates.WorldAreaToPlotAreaY(controlPoints[i], _plotArea, _worldArea); if (i < degree - 1) { ellipses.Add(_auxiliaryEngine.DrawEllipse(PAKnot - W_DIV_2, PAControlPoint - H_DIV_2, AUX_KNOT_COLOR3)); } else { ellipses.Add(_auxiliaryEngine.DrawEllipse(PAKnot - W_DIV_2, PAControlPoint - H_DIV_2, KNOT_COLOR3)); } } var gbSpline = GlobalBSpline(degree, serviceKnots, controlPoints, true); gbSpline.DragEllipses = ellipses; gbSpline.ControlPointsEllipses = cpEllipses; // gbSpline.isInteractive = true; gbSpline.FunctionValues = referencePoints.ToList(); return(gbSpline); }
public ClampedSpline InteractiveClampedSpline(double[] knots, double[] controlPoints, double leftDerivation, double rightDerivation) { var ellipses = new List <Ellipse>(knots.Length); Ellipse leftDerEll, rightDerEll; double pax, pay; var auxKnot = knots.First() - DERIVATIVE_AUX_KNOT_DISTANCE; var auxControlPoint = MathOperations.LinearFunction(auxKnot, knots.First(), controlPoints.First(), leftDerivation); pax = TransformCoordinates.WorldAreaToPlotAreaX(auxKnot, _plotArea, _worldArea); pay = TransformCoordinates.WorldAreaToPlotAreaY(auxControlPoint, _plotArea, _worldArea); leftDerEll = _auxiliaryEngine.DrawEllipse(pax - W_DIV_2, pay - H_DIV_2, AUX_KNOT_COLOR2); auxKnot = knots.Last() + DERIVATIVE_AUX_KNOT_DISTANCE; auxControlPoint = MathOperations.LinearFunction(auxKnot, knots.Last(), controlPoints.Last(), rightDerivation); pax = TransformCoordinates.WorldAreaToPlotAreaX(auxKnot, _plotArea, _worldArea); pay = TransformCoordinates.WorldAreaToPlotAreaY(auxControlPoint, _plotArea, _worldArea); rightDerEll = _auxiliaryEngine.DrawEllipse(pax - W_DIV_2, pay - H_DIV_2, AUX_KNOT_COLOR2); for (int i = 0; i < knots.Length; i++) { pax = TransformCoordinates.WorldAreaToPlotAreaX(knots[i], _plotArea, _worldArea); pay = TransformCoordinates.WorldAreaToPlotAreaY(controlPoints[i], _plotArea, _worldArea); ellipses.Add(_auxiliaryEngine.DrawEllipse(pax - W_DIV_2, pay - H_DIV_2, KNOT_COLOR2)); } // List<Line> linesOfSpline = HermiteSplineLines(knots,controlPoints); ClampedSpline spline = ClampedSpline(knots, controlPoints, leftDerivation, rightDerivation); spline.DragEllipses = ellipses; spline.LeftDerivationEllipse = leftDerEll; spline.RightDerivationEllipse = rightDerEll; return(spline); }
private void DefaultCanvas() { Line horizontal = new Line(); Line vertical = new Line(); TextBlock min_X_TextBlock = new TextBlock(); TextBlock max_X_TextBlock = new TextBlock(); TextBlock max_Y_TextBlock = new TextBlock(); TextBlock min_Y_TextBlock = new TextBlock(); SolidColorBrush color = new SolidColorBrush(); color.Color = Color.FromArgb(255, 170, 170, 0); horizontal.X1 = TransformCoordinates.WorldAreaToPlotAreaX(_worldArea.XMin, _plotArea, _worldArea); horizontal.Y1 = _waZeroPointInPACoordinates.Y; horizontal.X2 = TransformCoordinates.WorldAreaToPlotAreaX(_worldArea.XMax, _plotArea, _worldArea); horizontal.Y2 = _waZeroPointInPACoordinates.Y; vertical.X1 = _waZeroPointInPACoordinates.X; vertical.Y1 = TransformCoordinates.WorldAreaToPlotAreaY(_worldArea.YMin, _plotArea, _worldArea); vertical.X2 = _waZeroPointInPACoordinates.X; vertical.Y2 = TransformCoordinates.WorldAreaToPlotAreaY(_worldArea.YMax, _plotArea, _worldArea); horizontal.StrokeThickness = 1; vertical.StrokeThickness = 1; horizontal.Stroke = color; vertical.Stroke = color; Canvas.SetZIndex(horizontal, 1); min_X_TextBlock.Text = _worldArea.XMin.ToString(); max_X_TextBlock.Text = _worldArea.XMax.ToString(); max_Y_TextBlock.Text = _worldArea.YMax.ToString(); min_Y_TextBlock.Text = _worldArea.YMin.ToString(); min_X_TextBlock.Height = 14; max_X_TextBlock.Height = 14; max_Y_TextBlock.Height = 14; min_Y_TextBlock.Height = 14; min_X_TextBlock.Width = 30; max_X_TextBlock.Width = 30; max_Y_TextBlock.Width = 30; min_Y_TextBlock.Width = 30; min_X_TextBlock.Foreground = color; max_X_TextBlock.Foreground = color; max_Y_TextBlock.Foreground = color; min_Y_TextBlock.Foreground = color; Canvas.SetLeft(min_X_TextBlock, _plotArea.XMin + 10); Canvas.SetLeft(max_X_TextBlock, _plotArea.XMax - 30); Canvas.SetLeft(max_Y_TextBlock, _plotArea.XMax / 2 + 12); Canvas.SetLeft(min_Y_TextBlock, _plotArea.XMax / 2 + 12); Canvas.SetTop(min_X_TextBlock, _plotArea.YMax / 2 - 23); Canvas.SetTop(max_X_TextBlock, _plotArea.YMax / 2 - 23); Canvas.SetTop(max_Y_TextBlock, _plotArea.YMin + 10); Canvas.SetTop(min_Y_TextBlock, _plotArea.YMax - 20); Canvas.SetZIndex(horizontal, 1); Canvas.SetZIndex(horizontal, 1); Canvas.SetZIndex(horizontal, 1); Canvas.SetZIndex(horizontal, 1); _dragInfoLabel = new DragInfoLabel(CANVAS_TEXT_COLOR); _dragInfoLabel.Visibility = Visibility.Collapsed; canvas1.Children.Add(_dragInfoLabel); canvas1.Children.Add(horizontal); canvas1.Children.Add(vertical); canvas1.Children.Add(min_X_TextBlock); canvas1.Children.Add(min_Y_TextBlock); canvas1.Children.Add(max_X_TextBlock); canvas1.Children.Add(max_Y_TextBlock); }