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!