Lines sometimes visible, although under/behind slice layer (should be hidden) - depending on camera position
2 次查看(过去 30 天)
显示 更早的评论
I have a Simulink-based 3D model of a wind farm and I plot the resulting wind speed on hub height using the coneplot and slice functions. Each wind turbine is indicated by a couple of simple lines using plot3 and fill3. The results look fine and can be saved as an animation:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1480306/image.jpeg)
I wanted to extend the animation by implementing a moving camera through the scene (based on https://de.mathworks.com/help/matlab/creating_plots/example-moving-the-camera-through-a-scene.html). However, I noticed that at some point, the results get weird. This happens when changing the camera settings in the figure window manually or through my script. It looks like the slice was not the top layer anymore, but the wind turbine line plots begin to overlay the slice layer. The proportion of overlay changes with moving the camera forward/back, there is no hard transition (which could occur if the order of objects was changed, i.e. wind turbine drawing to top instead of slice).
1) everything is fine:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1480311/image.jpeg)
2) first errors occur after a little forward movement:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1480316/image.jpeg)
3) fully developed incorrect visualisation after further forward movement. The rotor surface is now completely visible (although only the upper half should be visible and the rest should be covered by the slice layer) as well most of the wind turbine tower:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1480321/image.jpeg)
4) further forward movement reduces this behavor again:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1480326/image.jpeg)
To me, it looks like the figure itself is fine but there is some issue with the camera settings (at least in this specific case).
Where should I begin to look for the cause of this? What could be a possible solution?
5 个评论
Nathan Hardenberg
2023-9-19
There seems to be an issue when the camera is to close to the "plotted" area. Only then this glitches out. No clue what that could be. But I could reproduce the problem with similar code (see below). This can probably help when debugging. Maybe @Adam Danz has some insights, or you can make a bug report.
In the code the sine-plots should be cut exactly in half. But this does not happen, if you get "too close". This is even more obvious when looking at the "animation" (executing the code below on your device).
clear all
clf('reset')
x = -100:1:100;
[X,Y,Z] = meshgrid(x,x,x);
V = 1+sin(X/20)+cos(Y/20);
f1 = figure(1);
h = slice(X,Y,Z,V,[],[],[0],"linear");
set(h,'edgecolor','none');
hold on;
plot3(x, -60*ones(1,length(x)), 5*sin(x/1.5), LineWidth=3)
plot3(x, -20*ones(1,length(x)), 5*sin(x/1.5), LineWidth=3)
plot3(60*ones(1,length(x)),x, 5*sin(x/1.5), LineWidth=3)
axis equal
axis vis3d
xlabel('x');ylabel('y');zlabel('z');
xvec = linspace(-400,-40,400);
camtarget([0 0 0])
camva(40)
camproj perspective
for x = xvec
campos([x,0,20])
drawnow
end
Also sometimes red plot lines get drawn over the camera in your example, see below:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1487387/image.png)
Adam Danz
2023-9-21
I suggest contacting tech support and to include the reproduction steps and any files needed to reproduce this behavior.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Camera Views 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!