每个单元格中带有球体的 3D 网格

3D grid with spheres in each cell

我正在尝试创建一个与此类似的图表。

每个单元格中都有球体的 3D 网格图。我想使用 matlab,略有不同的是我希望球体上有特定的图像。

这可能吗?如果可以,什么是好的起点?

以下是我如何使用 bubbleplot3 from the File Exchange to plot an array of evenly spaced spheres, in addition to using warp 将图像显示为球体的纹理贴图表面。基本上用 bubbleplot3 创建球体,然后在 for 循环中获取每个单独的表面对象,并在它们上调用 warp 以用图像替换它们的纹理贴图。

对于生成网格立方体,我没有任何功劳,并稍微修改了@Raf 的回答 here

clc;clear;close all

%// Read image
C = flipud(imread('peppers.png'));

%// Generate array of spheres
Radius = 1;
[x,y,z] = meshgrid(0:2:4,0:2:4,0:2:4);
r=repmat(Radius,1,numel(x));

%// Call bubbleplot3
hBubble = bubbleplot3(x,y,z,r,[],[],[],[]);

hold on

%// Get surfaces objects
SurfHandles = findobj('type','surface');

%// Use warp function to replace colordata with image
for k = 1:numel(SurfHandles)
    warp(SurfHandles(k).XData,SurfHandles(k).YData,SurfHandles(k).ZData,C)
end

%// Now cube.
%// Credit to Raf here: 
CubeData = -1:2:5;
[X, Y] = meshgrid(CubeData,CubeData);                         
x = [X(:) X(:)]';                                
y = [Y(:) Y(:)]';
z = [repmat(CubeData(1),1,length(x)); repmat(CubeData(end),1,length(x))];
col = 'b';

plot3(x,y,z,col,'Color','k');                                         
plot3(y,z,x,col,'Color','k');
plot3(z,x,y,col,'Color','k');

rotate3d on

并输出: