Lines sometimes visible, although under/behind slice layer (should be hidden) - depending on camera position

1 view (last 30 days)
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:
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:
2) first errors occur after a little forward movement:
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:
4) further forward movement reduces this behavor again:
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 Comments
Nathan Hardenberg
Nathan Hardenberg on 19 Sep 2023
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:
Adam Danz
Adam Danz on 21 Sep 2023
Thanks for the files @v k and thanks @Nathan Hardenberg for the reduced reproduction steps.
I suggest contacting tech support and to include the reproduction steps and any files needed to reproduce this behavior.

Sign in to comment.

Answers (0)

Categories

Find more on Geographic Plots in Help Center and File Exchange

Products


Release

R2017b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!