3
$\begingroup$

I've created a Graphics3D object by extruding a binary 2D image (as shown here).

pts = ImageData[ColorNegate@Binarize@Import["https://i.stack.imgur.com/UWO6k.png"], "Bit"];
g = RegionPlot3D[pts[[Sequence @@ Round@{i, j}]] == 1, {i, 1, #1}, {j, 1, #2},
  {z, 0, 300}, PlotPoints -> 100, Mesh -> False, Axes -> True, 
  Boxed -> False] & @@ Dimensions[pts]

enter image description here

This object has dimensions 600 $\times$ 600 $\times$ 300 and it is centered on (300, 300, 150). In other words, all coordinates are within the ranges of the given dimensions.

My need is to be able to rescale this object by preserving the same Graphics3D structure (i.e., including vertices, polygons, vertex normals, etc.). The new ranges of dimensions I'm looking for are ((-0.5, 0.5), (-0.5, 0.5), (-0.25, 0.25)).

I had no troubles to rescale the coordinates of the GraphicsComplex, but these are not enough to then export the Graphics3D as an .obj file. A second approach that I took was to use TetGenLink to recompute the needed information, but since my object has also concavities this did not work as expected.

Has anyone done this before? Any suggestion is more than welcome.

$\endgroup$

1 Answer 1

2
$\begingroup$

How about using RescalingTransform:

Graphics3D[{
            GeometricTransformation[
                          First@g, 
                          RescalingTransform[{{1, 600}, {1, 600}, {0, 300}}, 
                                             {{-.5, .5}, {-.5, .5}, {-.25, .25}}]]}
          , Axes -> True]

enter image description here

$\endgroup$

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.