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]
Is there a way to get the inside of that shape as a Mathematica region?
Edit
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]
Correct answer by cvgmt on August 16, 2021
An alternative approach: You can use the coordinate data to define BezierFunction
s 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}]
BoundaryDiscretizeRegion @ poly
Answered by kglr on August 16, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP