5
$\begingroup$

I have 2 curves on 1 axes. I've been working on how to plot the error between those 2 curves. I want to plot a new error curve on a new axes but I couldn't find the solution for this problem.

Here attached the sample Bézier curve and the circle. If you noticed the red dashed line is the error between those curves. So, I want to plot an error curve based on the differences of this 2 curves.

Cubic1 = {{-1, 0}, {-1, 1.5}, {0, 1.5}, {1, 1.5}, {1,0}};
Print[MatrixForm[Cubic1]]
C1 = Graphics[BezierCurve[Cubic1]];
c = BezierFunction[Cubic1]
pts1 = c /@ Range[1/5, 4/5, 1/5];
pts2 = {Cos[#], Sin[#]} & /@ (Pi Range[4/5, 1/5, -1/5]);
Show[Graphics[{Red, Point[Cubic1], Green, Line[Cubic1]}, 
  Axes -> True], ParametricPlot[c[t], {t, 0, 1}], 
  ParametricPlot[{{ Cos[t], Sin[t]}}, {t, 0, Pi}, 
  PlotLegends -> "Expressions", PlotStyle -> Orange], 
  Epilog -> {AbsolutePointSize[6], Red, Point[pts1], Point[pts2], 
  Dashed, Line /@ Transpose[{pts1, pts2}]}]

enter image description here

$\endgroup$
3
$\begingroup$

I suppose you want the norm of the error, as a function of the parameter as opposed to the distance to the semicircle from a point on the Bézier curve.

Cubic1 = {{-1, 0}, {-1, 1.5}, {0, 1.5}, {1, 1.5}, {1, 0}};
c = BezierFunction[Cubic1];
circleFN = {Cos[Pi (1 - #)], Sin[Pi (1 - #)]} &;

Plot[Norm[c[t] - circleFN[t]], {t, 0, 1}]

Mathematica graphics

If you want the actual (vector) error, then do as follows:

ParametricPlot[c[t] - circleFN[t], {t, 0, 1}, AspectRatio -> 0.6]

Mathematica graphics

$\endgroup$
  • $\begingroup$ Yeah!! This is what I want. Thank you so much. $\endgroup$ – BayWilson Sep 29 '16 at 3:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.