简体   繁体   中英

plot solid spheres as points in matlab

I can draw cicle points and place arrows passing by them:

plot(1,1,'o','MarkerEdgeColor','k','MarkerFaceColor','k','MarkerSize',10,'LineWidth',1.5); hold on; 
plot(2,1,'o','MarkerEdgeColor','k','MarkerFaceColor','k','MarkerSize',10,'LineWidth',1.5); hold on; 


vec1=zeros(1,3); vec2=zeros(1,3); col1=zeros(1,3); col2=zeros(1,3);
vec1=[0.98996547   0.00000000    0.14130945];

vec2=[0.00000000    0.70710678   -0.70710678];


col1= [abs(vec1(1,1)) abs(vec1(1,2)) abs(vec1(1,3))];
col2= [abs(vec2(1,1)) abs(vec2(1,2)) abs(vec2(1,3))];

ac=0.1;
p1_sh = [1 1 0] - ac*vec1;
p2_sh= [2 1 0] - ac*vec2;

scalef=0.4;
quiver3(p1_sh(1),p1_sh(2),p1_sh(3),vec1(1,1)*scalef,vec1(1,2)*scalef,vec1(1,3)*scalef,'AutoScale','off','MaxHeadSize',5,'LineWidth',5,'Color',col1); hold on;

quiver3(p2_sh(1),p2_sh(2),p2_sh(3),vec2(1,1)*scalef,vec2(1,2)*scalef,vec2(1,3)*scalef,'AutoScale','off','MaxHeadSize',5,'LineWidth',5,'Color',col2); hold on; 

view(20,20);

hold off;

The output is:

在此处输入图像描述

The problem is that the points are circles and not spheres. LineSpec does not have an option for spheres. How can I make the points into spheres?

When using

plot(1,1,'o','MarkerEdgeColor','k',...
'MarkerFaceColor','k','MarkerSize',10,'LineWidth',1.5);

You are creating a 2D marker, an element that has no depth even if you used a plot3(...).

In order to create a "solid" sphere you could use the command "Sphere"

numVertices = 32;
sphereRadius = 15;
[sph.x, sph.y, sph.z] = sphere(numVertices);
sph.x = sph.x*sphereRadius;
sph.y = sph.y*sphereRadius;
sph.z = sph.z*sphereRadius;

surf(sph.x,sph.y,sph.z);

Also keep in mind that this sphere will be hollow, composed by the planes that conform its surface. You can not create a "solid" object.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM