The best workaround I can think out at the moment is to turn to RegionPlot3D
.
To plot ellipsoid with RegionPlot3D
, we need formula for general ellipsoid, which has been mentioned in the Details of document of Ellipsoid
:
$$(x-p).{\Sigma^{-1 }}.(x-p)\leq 1$$
where $\Sigma$ is weight matrix, which can be generated with the help of TransformedRegion
:
mat = TransformedRegion[Ellipsoid[{0, 0, 0}, {4, 2, 3}],
RotationTransform[k Pi/(30/2) + Pi/180, {0, 0, 1}]][[2]]
$$\left(
\begin{array}{ccc}
16 \cos ^2\left(\frac{\pi k}{15}+\frac{\pi }{180}\right)+4 \sin ^2\left(\frac{\pi k}{15}+\frac{\pi }{180}\right) & 12 \cos \left(\frac{\pi k}{15}+\frac{\pi }{180}\right) \sin \left(\frac{\pi k}{15}+\frac{\pi }{180}\right) & 0 \\
12 \cos \left(\frac{\pi k}{15}+\frac{\pi }{180}\right) \sin \left(\frac{\pi k}{15}+\frac{\pi }{180}\right) & 4 \cos ^2\left(\frac{\pi k}{15}+\frac{\pi }{180}\right)+16 \sin ^2\left(\frac{\pi k}{15}+\frac{\pi }{180}\right) & 0 \\
0 & 0 & 9 \\
\end{array}
\right)$$
So the inequality representing the region is
expr = Or @@ Table[{x, y, z}.Inverse@mat.{x, y, z} <= 1 // Evaluate, {k, 30}];
expr
is so large a symbolic expression, thus we compile it to speed up plotting:
cf = Compile[{x, y, z}, Evaluate@expr,
RuntimeOptions -> {"EvaluateSymbolically" -> False}];
(gra = RegionPlot3D[cf[x, y, z], {x, -5, 5}, {y, -5, 5}, {z, -5, 5}, Mesh -> None,
PlotPoints -> 100]) // AbsoluteTiming
Finally discretize gra
and export (directly exporting gra
is OK, but it takes 89.2224
seconds to finish):
disgra = gra // DiscretizeGraphics; // AbsoluteTiming
(* {3.33076, Null} *)
Export["test.obj", disgra] // AbsoluteTiming
(* {1.02844, "test.obj"} *)
The biggest advantage of this approach is, the quality of the generated mesh seems to be good:
Show[disgra, PlotRange -> {-5, 0}]
FindMeshDefects@disgra
So the generated .obj file should be suitable for 3D printing.
Indeed, it's suitable for 3D printing:
GeometricTransformation
causes trouble when exporting. (Another example I can find at the moment: mathematica.stackexchange.com/q/63173/1871 ) It should be easier to find a workaround in this case, given rotated ellipsoid is not hard to generate withoutRotate
. $\endgroup$