2
$\begingroup$

How do I convert a translated filled curve into a region?

It works without translation:

a = FilledCurve[{{{1, 3, 2}}}, {{{0, 0}, {1/2, 1}, {1, 0}}}] // Graphics
a // DiscretizeGraphics // Region

It does not work with translation for no reason (since b is output of Graphics the same way as is a):

b = 
 Translate[
   FilledCurve[{{{1, 3, 2}}}, {{{0, 0}, {1/2, 1}, {1, 0}}}], {0, 1}] // Graphics
b // DiscretizeGraphics // Region
$\endgroup$
1
  • 1
    $\begingroup$ My guess is that transformations such as Translate, Rotate, etc., are computed in the GPU when the graphics are display, and there is no way (AFAIK) to convert them to Normal graphics. To me, it seems a gap in Mathematica's functionality. $\endgroup$
    – Michael E2
    Oct 13, 2020 at 14:39

2 Answers 2

1
$\begingroup$

You can translate the control point coordinates and proceed as before.

b = 
  With[{pts = TranslationTransform[{0, 1}][{{0, 0}, {1/2, 1}, {1, 0}}]},
    FilledCurve[{{{1, 3, 2}}}, {pts}]] // Graphics;
b // DiscretizeGraphics // Region[#, Frame -> True] &

region

$\endgroup$
1
  • $\begingroup$ @azerbajdzan. Thanks for accepting my answer. But I don't understand why you considered it worth an acceptance but not worth an up-vote. You are aware, aren't you, that you can do both. $\endgroup$
    – m_goldberg
    Oct 15, 2020 at 0:29
2
$\begingroup$

You could discretize first and then translate:

a = FilledCurve[{{{1, 3, 2}}}, {{{0, 0}, {1/2, 1}, {1, 0}}}] // 
  Graphics;

TransformedRegion[a // DiscretizeGraphics, 
 TranslationTransform[{0, 1}]]
$\endgroup$
1
  • $\begingroup$ I know this works, but I have have arguments that are translated first. $\endgroup$ Oct 13, 2020 at 14:44

Your Answer

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

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