# How to plot a distribution of planes

How can one plot a distribution of planes in $\mathbb R^3$ in Mathematica?

For some point $p=(x,y,t)\in\mathbb R^3$, I want to attach a plane spanned by $X(p)=\left(1,0,\frac{y}{2}\right)$ and by $Y(p)=\left(0,1,-\frac{x}{2}\right)$, in order to obtain something like this:

(The above figure is taken from here.)

• What about the code/source for the shown image? Dec 14 '15 at 10:14
• The link is lukyanenko.net/gallery.php?page=3 Dec 14 '15 at 10:16
• Suggestion: you can put the link into the question, where it will be permanently preserved. Also, it usually helps to show what you tried already. Dec 14 '15 at 10:35
• I'm going to add the link in the question. But I don't know how to plot something like this. I'm an occasional Mathematica user, so I'm not expert at all. Dec 14 '15 at 10:40
• I've edited the post, I hope now it is clearer. Dec 14 '15 at 10:55

a = .2;
base = Polygon[{{-a, -a, 0}, {-a, a, 0}, {a, a, 0}, {a, -a, 0}}/2];
r = 2 a;

Graphics3D[{

GeometricTransformation[
base,
Flatten[
Table[
TranslationTransform[{x, y, 0}] @* RotationTransform[
{{0, 0, 1}, Cross[{1, 0, .5 y}, {0, 1, -.5 x}]}],
{x, - r, r, a}, {y, - r, r, a}
], 1]
],
{  Thick
,
Blue, (* normal to base*)
Arrow[{#, # + {0, 0, .2}} ]
,
Green, (* spanning vectors *)
Arrow[{#, # + .2 {1, 0, .5 #[[2]]}} ],
Arrow[{#, # + .2 {0, 1, -.5 #[[1]]}} ]
,
Red, (* normal to spanned plane*)
Arrow[{#, # + .2 Cross[{1, 0, .5 #[[2]]}, {0, 1, -.5 #[[1]]}]  }]
} &@{r, r, 0}
},
PlotRange -> All, Axes -> True]


and with J.M.'s suggestion about BoxRatios:

Graphics3D[{
base,
GeometricTransformation[
base,
Flatten[
Table[
TranslationTransform[{x, y, 0}]@*RotationTransform[
{{0, 0, 1}, Normalize@Cross[{1, 0, .5 y}, {0, 1, -.5 x}]}],
{x, -r, r, a}, {y, -r, r, a}
], 1]
]

}, PlotRange -> All, Axes -> True, BoxRatios -> {1, 1, 0.4}]


a = .1;
r = 5 a;


• Note that the original picture seems to be using the BoxRatios setting of Plot3D[]... Dec 14 '15 at 11:20
• @J.M., you're right!
– Kuba
Dec 14 '15 at 11:24
• I know. ;) For completeness: Lighting -> "Classic". Dec 14 '15 at 11:31
• @J.M. I won't doubt again!
– Kuba
Dec 14 '15 at 11:38
• @Kuba: Thanks a lot! Dec 14 '15 at 12:36

Here's a very compact version, constructed through the magic of dot products:

With[{a = 1/5, r = 2/5},
Graphics3D[Polygon[Flatten[Table[{x, y, 0} + # & /@
(a {{1, 1}, {-1, 1}, {-1, -1}, {1, -1}} .
{{1, 0, y/2}, {0, 1, -x/2}}/2),
{x, -r, r, a}, {y, -r, r, a}], 1]],
Axes -> True, BoxRatios -> {1, 1, 0.4},
Lighting -> "Classic", PlotRange -> All]]
`