I'm trying to model a 3D die with ImplicitRegion[]
in order to find out its center of mass. However, when I apply RegionCentroid[]
to this region it takes too long to give an output. So I thought DiscretizeRegion[]
would might render the computation of the centroid easier without losing precision.
θ=(63/100)Pi;
depth=9/10;
r = 22/10;
offset = 1/2;
offset61 = 3/10;
offset62 = 6/10;
ℛ= ImplicitRegion[
(*Cube*)
-1<=x<=1 &&
-1<=y<=1 &&
-1<=z<=1 &&
(*Sphere*)
x^2+y^2+z^2<=r&&
(* face 1*)
Not[(x^2+y^2)(Cos[θ]^2)-((Sin[θ]^2)((z-depth)^2))<=0&&0<(z-depth)<=1] &&
(* face 2*)
Not[((x-offset)^2+(z-offset)^2)(Cos[θ]^2)-((Sin[θ]^2)((y+depth)^2))<=0&&-1<(y+depth)<=0]&&
Not[((x+offset)^2+(z+offset)^2)(Cos[θ]^2)-((Sin[θ]^2)((y+depth)^2))<=0&&-1<(y+depth)<=0]&&
(*face3*)
Not[((y-offset)^2+(z-offset)^2)(Cos[θ]^2)-((Sin[θ]^2)((x+depth)^2))<=0&& -1<(x+depth)<=0]&&
Not[((y)^2+(z)^2)(Cos[θ]^2)-((Sin[θ]^2)((x+depth)^2))<=0&& -1<(x+depth)<=0]&&
Not[((y+offset)^2+(z+offset)^2)(Cos[θ]^2)-((Sin[θ]^2)((x+depth)^2))<=0&& -1<(x+depth)<=0]&&
(*face4*)
Not[((y-offset)^2+(z-offset)^2)(Cos[θ]^2)-((Sin[θ]^2)((x-depth)^2))<=0&& 0<(x-depth)<=1]&&
Not[((y+offset)^2+(z-offset)^2)(Cos[θ]^2)-((Sin[θ]^2)((x-depth)^2))<=0&& 0<(x-depth)<=1]&&
Not[((y+offset)^2+(z+offset)^2)(Cos[θ]^2)-((Sin[θ]^2)((x-depth)^2))<=0&& 0<(x-depth)<=1]&&
Not[((y-offset)^2+(z+offset)^2)(Cos[θ]^2)-((Sin[θ]^2)((x-depth)^2))<=0&& 0<(x-depth)<=1]&&
(* face 5*)
Not[((x-offset)^2+(z-offset)^2)(Cos[θ]^2)-((Sin[θ]^2)((y-depth)^2))<=0&&0<(y-depth)<=1]&&
Not[((x)^2+(z)^2)(Cos[θ]^2)-((Sin[θ]^2)((y-depth)^2))<=0&&0<(y-depth)<=1]&&
Not[((x-offset)^2+(z+offset)^2)(Cos[θ]^2)-((Sin[θ]^2)((y-depth)^2))<=0&&0<(y-depth)<=1]&&
Not[((x+offset)^2+(z+offset)^2)(Cos[θ]^2)-((Sin[θ]^2)((y-depth)^2))<=0&&0<(y-depth)<=1]&&
Not[((x+offset)^2+(z-offset)^2)(Cos[θ]^2)-((Sin[θ]^2)((y-depth)^2))<=0&&0<(y-depth)<=1]&&
(*face 6*)
Not[((x+offset62)^2+(y+offset61)^2)(Cos[θ]^2)-((Sin[θ]^2)((z+depth)^2))<=0&&-1<(z+depth)<=0]&&
Not[((x-offset62)^2+(y+offset61)^2)(Cos[θ]^2)-((Sin[θ]^2)((z+depth)^2))<=0&&-1<(z+depth)<=0]&&
Not[((x+offset62)^2+(y-offset61)^2)(Cos[θ]^2)-((Sin[θ]^2)((z+depth)^2))<=0&&-1<(z+depth)<=0]&&
Not[((x-offset62)^2+(y-offset61)^2)(Cos[θ]^2)-((Sin[θ]^2)((z+depth)^2))<=0&&-1<(z+depth)<=0]&&
Not[((x)^2+(y+offset61)^2)(Cos[θ]^2)-((Sin[θ]^2)((z+depth)^2))<=0&&-1<(z+depth)<=0]&&
Not[((x)^2+(y-offset61)^2)(Cos[θ]^2)-((Sin[θ]^2)((z+depth)^2))<=0&&-1<(z+depth)<=0]
, {x,y,z}];
(*b=RegionPlot3D[ℛ,Axes->True, AxesLabel->{x,y,z},PlotStyle->Directive[Opacity[0.9]], PlotPoints->100]*)
When I try to discretize this region I get the following error:
DiscretizeRegion::drf: DiscretizeRegion was unable to discretize the region ImplicitRegion[<<2>>].
I'd like to know:
- How to circumvent this error?
- Is there a better method to obtain the centroid of this solid?