TransWikia.com

Create region bounded by parametric curves

Mathematica Asked by FrankM on August 16, 2021

How can I define a region that is bounded by a set of parametric curves?

E.g. three parametric curves – which are cubic Bezier curves – define the boundary of a shape:

cubicbez[a_, b_, c_, d_, t_] := (1 - t)^3*a + 3*(1 - t)^2*t*b + 
  3*(1 - t)*t^2*c + t^3*d

bezierRegion[{a_, b_, c_, d_}] := 
 ParametricRegion[cubicbez[a, b, c, d, t], {{t, 0, 1}}]

regions = {bezierRegion[{{5, 5}, {10, 13}, {18, 4}, {20, 30}}], 
   bezierRegion[{{20, 30}, {18, 40}, {17, 40}, {15, 35}}], 
   bezierRegion[{{15, 35}, {25, 25}, {5, 20}, {5, 5}}]};

Show[Region /@ regions, Frame -> True]

Shape defined by a chain of parametric curves

Is there a way to get the inside of that shape as a Mathematica region?

2 Answers

Edit

  • Another way is just use
Show[Region /@ regions, Frame -> False] // BoundaryDiscretizeGraphics
BezierCurve[{{5, 5}, {10, 13}, {18, 4}, {20, 30}, {18, 40}, {17, 
    40}, {15, 35}, {25, 25}, {5, 20}, {5, 
    5}}] // BoundaryDiscretizeGraphics
fig = Graphics@
   FilledCurve@
    BezierCurve[{{5, 5}, {10, 13}, {18, 4}, {20, 30}, {18, 40}, {17, 
       40}, {15, 35}, {25, 25}, {5, 20}, {5, 5}}];
reg = BoundaryDiscretizeGraphics[fig]

enter image description here

Correct answer by cvgmt on August 16, 2021

An alternative approach: You can use the coordinate data to define BezierFunctions and use them to construct a polygon which can be used as is as a region or discretized using BoundaryDiscretizeRegion:

bzfuncs = {BezierFunction[{{5, 5}, {10, 13}, {18, 4}, {20, 30}}], 
   BezierFunction[{{20, 30}, {18, 40}, {17, 40}, {15, 35}}], 
   BezierFunction[{{15, 35}, {25, 25}, {5, 20}, {5, 5}}]};

poly = Polygon[Join @@ (Map[#]@Subdivide[100] & /@ bzfuncs)];

RegionQ @ poly
True
Graphics[{EdgeForm[Gray], FaceForm[LightBlue], poly}]

enter image description here

BoundaryDiscretizeRegion @ poly

enter image description here

Answered by kglr on August 16, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP