如何将向量列表绘制为球体? [英] How to plot a list of vectors as a sphere?
问题描述
我有一组归一化向量(其中 1538 个)形成一个球体.此外,我还有一组大小相同的数字 1538.我想绘制如下图:
I have an array of normalized vectors (1538 of them) forming a sphere. Also I has an array of numbers of the same size 1538. I want to plot something like this:
我尝试了 sphere
和 surf
函数,但找不到使用向量的方法.我想应该有办法做到这一点.
I tried the sphere
and surf
functions but I can't find a way to use my vectors. I figured there should be some way to do this.
非常感谢.
推荐答案
我认为你可以使用 delaunay 使用 trimesh 创建三角剖分和绘图 或 trisurf.
I think you can use delaunay to create a triangulation and plot that using trimesh or trisurf.
trimesh 和 trisurf 都接受第四个参数来指定每个顶点的颜色,添加选项 'facecolor','interp'
以在顶点之间插入每个面的颜色.
Both trimesh as trisurf accepts a fourth argument to specify the color of each vertex, add the option 'facecolor','interp'
to interpolate the color of each face between vertices.
我对它进行了进一步的实验,因为它是一个球体,我认为 convhull 更适合.
edit: I experimented a bit further on it, and since it's a sphere, I think convhull is better suited.
示例:
[x,y,z]=sphere(25);
x=x(:);y=y(:);z=z(:);
tri = convhull([x y z]);
C = cos(y);
trisurf(tri,x,y,z,C,'facecolor','interp');
代替示例中的 C
,您可以使用自己的值向量来指定颜色
instead of C
in the example you can use your own vector of values to specify the color
这篇关于如何将向量列表绘制为球体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!