2
$\begingroup$

Here is a 3D inverted Truchet tiling, p is "radius of the tubes", n is "volume".

    inverze[x_] := 8 x/(x[[1]]^2 + x[[2]]^2 + x[[3]]^2) ;
    p = 0.3;
    n = 4;
    nrotace = 
    Table[RandomInteger[3], {i, 1, n}, {j, 1, n}, {k, 1, n}, {r, 1, n}];
    nzrcadleni = 
    Table[RandomInteger[1], {i, 1, n}, {j, 1, n}, {k, 1, n}, {r, 1, n}];
    mat = Table[(If[nzrcadleni[[i, j, k, 3]] == 1, 
    ReflectionMatrix[{1, 0, 0}], IdentityMatrix[3]]).(If[
    nzrcadleni[[i, j, k, 2]] == 1, ReflectionMatrix[{0, 1, 0}], 
    IdentityMatrix[3]]).(If[nzrcadleni[[i, j, k, 1]] == 1, 
    ReflectionMatrix[{0, 0, 1}], IdentityMatrix[3]]).RotationMatrix[
    nrotace[[i, j, k, 1]] (Pi/2), {0, 0, 1}].RotationMatrix[
    nrotace[[i, j, k, 2]] (Pi/2), {0, 1, 0}].RotationMatrix[
    nrotace[[i, j, k, 3]] (Pi/2), {1, 0, 0}], {i, 1, n}, {j, 1, n}, {k, 1, n}];
    tst = Table[2 {i - (n + 1)/2, j - (n + 1)/2, k - (n + 1)/2} + (mat[[i, j, k]].#) & /@ {{(1 + p Cos[v]) Cos[u] - 1, (1 + p Cos[v]) Sin[u] - 1, p Sin[v]}, {(1 + p Cos[v]) Sin[u + (3/2) Pi] + 1, p Sin[v], (1 + p Cos[v]) Cos[u + (3/2) Pi] - 1}, {p Sin[v], (1 + p Cos[v]) Sin[u + Pi] + 1, (1 + p Cos[v]) Cos[u + Pi] + 1}}, {i, 1, n}, {j, 1, n}, {k, 1, n}];
    tst2 = (inverze /@ Flatten[tst, 3]);
    ParametricPlot3D[tst2, {u, 0, Pi/2}, {v, 0, 2 Pi}, PlotPoints -> Automatic, PlotRange -> {{-5, 5}, {-5, 5}, {-5, 5}}, PlotStyle -> {Red,Specularity[White, 20]}, RegionFunction -> Function[{x, y, z, u, v}, x^2 + y^2 + z^2 <= 5^2], ViewPoint -> {1, 1, 1}, SphericalRegion -> True, PlotTheme -> "ThickSurface", Boxed -> False, Axes -> False]

Result enter image description here

Here is what it looks like when it is ray traced:

You can also change continuously the point of inversion to make some nice videos. Please suggest useful code optimizations.

$\endgroup$

closed as off-topic by J. M. will be back soon Mar 31 at 13:55

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question cannot be answered without additional information. Questions on problems in code must describe the specific problem and include valid code to reproduce it. Any data used for programming examples should be embedded in the question or code to generate the (fake) data must be included." – J. M. will be back soon
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ Here is the effect of the continuous change of the point of inversion: youtube.com/watch?v=7QWqqTdT8Kg $\endgroup$ – Woertgner Feb 23 '18 at 12:28
  • $\begingroup$ OK, my mistake, so delete it please. $\endgroup$ – Woertgner Feb 23 '18 at 12:28
  • $\begingroup$ This may be a very interesting topic, but as posted, it is not appropriate for this site because there is no question about Mathematica. $\endgroup$ – m_goldberg Feb 23 '18 at 12:29
  • 3
    $\begingroup$ I'm voting to close this question as off-topic because it poses no question that is appropriate to this site. $\endgroup$ – m_goldberg Feb 23 '18 at 12:30
  • 1
    $\begingroup$ If you simply would like to showcase your code and model you can post at Wolfram Community where question format is not required. $\endgroup$ – Vitaliy Kaurov Mar 1 '18 at 3:50