Hi there,
I am working on building a model of a virtual world (animated simulation) in MATLAB. Therefore, I tried to replicate a simple setting of the virtual world with MATLAB's 3D plotting tools. The following picture is an overlay of my results. The blue plane and the green square are surface plots generated with MATLAB. The checkered road and the squared checkerboard are from the simulated virtual world.
As can be seen clearly, neither the blue plane with the road nor the green square with the checkerboard do accurately match. Virtually, the corresponding objects have the same dimensions. Furthermore, the camera positions are identical as well as directions and vertical field of view.
Since both cameras are placed in a way they are directly targeting the corresponding square (with camera center axis parallel to ground), it looks pretty much the MATLAB view is somehow distorted. That is, the center of the checkerboard is in the center of the window, whereas the center of the green plane is off to the right and the top of its window.
So, am I missing an essential parameter or why do the two views not match? Below is the code to generate my 3D plot in MATLAB.
Any ideas appreciated a lot!
fig = figure;
fig.Units = 'pixels';
fig.Position = [0 1200-900 1440 900];
fig.Resize = 'off';
[X,Y] = meshgrid(0:0.5:100,-2.5:0.5:7.5);
Z = zeros(size(X));
surf(X,Y,Z);
hold on
[Ysgn Zsgn] = meshgrid(-0.5: 0.5, 2 : 3);
Xsgn = ones(size(Zsgn))*15;
surf(Xsgn, Ysgn, Zsgn);
p = gca;
set(gca, 'CameraViewAngle', 47)
daspect(p, [1 1 1])
camproj('perspective')
campos([0,0,2.5])
camtarget([50,0,2.5])
ylim([-2.5 7.5])
zlim([0 5])
0 Comments
Sign in to comment.