Transparent plane over on object
10 ビュー (過去 30 日間)
古いコメントを表示
Can anyone please explain to me what am I doing wrong here. I plan to have a transparent plane over the 3d object(cylinder), I have tried all possible methods to define the plane and set the transparency using alpha parameter but the plane ends up being a solid color. The code only for the transparent plane works fine until I plot it along with the object. Here is a Snippet of my code:
plot my_3dobject; %plot command for my 3d object
%code to define and plot the transparent plane using three reference points
pointA = [0,0,0];
pointB = [-4,0,0];
pointC = [4,0,4];
normal = cross(pointA-pointB, pointA-pointC); %# Calculate plane normal
%# Transform points to x,y,z
xx = [pointA(1) pointB(1) pointC(1)];
yy = [pointA(2) pointB(2) pointC(2)];
zz = [pointA(3) pointB(3) pointC(3)];
%Find all coefficients of plane equation
A = normal(1); B = normal(2); C = normal(3);
D = -dot(normal,pointA);
%Decide on a suitable showing range
xLim = [min(xx) max(xx)];
zLim = [min(zz) max(zz)];
[X,Z] = meshgrid(xLim,zLim);
Y = (A * X + C * Z + D)/ (-B);
reOrder = [1 2 4 3];
v = patch(X(reOrder),Y(reOrder),Z(reOrder),'g');
set(v,'facealpha',0.1);
set(v,'edgealpha',0.1);
Any pointers/suggestions will be really helpful. Thank you
0 件のコメント
採用された回答
Chad Greene
2014 年 6 月 19 日
I can think of two possible problems. If you're plotting the object after plotting the plane, the plane will disappear if you don't use the hold on command before plotting the object. The other possible issue is the figure renderer. Try each of the following:
set(gcf,'renderer','opengl')
If that doesn't work, try
set(gcf,'renderer','zbuffer')
and if that doesn't work try
set(gcf,'renderer','painters')
Hope this helps.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Line Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!