2
$\begingroup$

I am trying to integrate a figure composed of a piecewise parametric curve with both ends bound by a straight, vertical line segment. I have displayed the curves on top of each other using the Show function because I could not display the straight line using the ParametricPlot, code shown:

Show[ParametricPlot[{{InsideLoopA}},{t,0,1}],
Graphics[Line[{{0.62,0.69},{0.62,0.27}}]]]

enter image description here

However, now that I am trying to find the area within, I cannot figure out how to accomplish it. I have tried creating a Region, but the issue of one curve being Cartesian and the other Parametric seems to prevent mixing them successfully, despite Region accomodating multiple elements. For the same reason, I cannot use a ParametricRegion. What methods would facilitate creating a closed area that would allow me to then take the area, whether using the Area function on a type of Region or by taking an integral? Do I instead need to apply RegionUnion or rewrite my straight line in a very ugly parametric form, and figure out how to include it?

Example of incorrect attempt:Region[{InsideLoopA}, {Line[{{ 1.01 , 0.26},{1, 0.19 }}]}]

$\endgroup$

1 Answer 1

3
$\begingroup$

I think you're going about this in such a way as to make this harder than it is. Polygon represents a closed curve where the final point will connect to the first by default so we can just use that here. No need to add a line or anything.

The way this will work is as such, first get a tabular set of your noisy data. I'll do this in a slow way (with lots of RandomReal calls) but if possible vectorize your generating function to make it fast.

noisyFunction[t_] :=
 RandomReal[{.9, 1}]*{Cos[2*Pi*t], Sin[2*Pi*t]}

dats = BlockRandom[Table[noisyFunction[t], {t, 0, .5, .01}]];

ListLinePlot[dats]

enter image description here

We can see that this data was properly ordered from the get-go, but that's not a given, so you can use FindShortestTour to force an ordering if you need to. Then simply use Polygon to wrap this data and it can become a Region:

orderedDats = dats[[FindShortestTour[dats][[2]]]];

reg = Region[Polygon[orderedDats]]

enter image description here

At this point all the built-in stuff like Area will work:

Area[reg]

1.41799
$\endgroup$
2
  • $\begingroup$ I'm not sure I understand your solution. I am using an existing parametric piecewise equation; it is a set of stable functions resulting in a curve with an open side and not a set of data . I am trying to close it. While I think that Polygon looks like something that will fix the issue, I am not sure how to implement it. Did I misunderstand your answer? $\endgroup$
    – Mark
    Commented Jan 13, 2020 at 4:02
  • $\begingroup$ @Mark I know you have a function so I showed you how to convert it to a set of points to be used with Polygon in the very first step. The InsideLoopA can be converted to a function or used directly as an argument to Table. Maybe it would have been clearer if I had written InsideLoopA:=RandomReal[{.9, 1}]*{Cos[2*Pi*t], Sin[2*Pi*t]} so that I could use dats = Table[InsideLoopA, {t, 0, .5, .01} $\endgroup$
    – b3m2a1
    Commented Jan 13, 2020 at 4:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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