The basic idea is that you want to take the data from your object like this:
h = ezplot3('t', 'sin(t)', '20*cos(t)', [0 10*pi]);
pts = [h.XData; h.YData; h.ZData; ones(size(h.XData))];
and then multiply it by the view transform. Unfortunately accurately reproducing the view transform for an arbitrary 3D MATLAB plot can be a bit tricky. It is pretty close to this:
mat = viewmtx(-37.5,30) * makehgtform('scale',1./[20 1 20])
The first half of that is the azimuth and elevation. The second half is the DataAspectRatio.
Once you have that matrix, you can transform your points like this:
pt2 = mat * pts;
x = pt2(1,:) ./ pt2(4,:);
y = pt2(2,:) ./ pt2(4,:);
If we plot those, we'll see that I'm close, but slightly off:
I think I've neglected to account for the PlotBoxAspectRatio, but I'm not 100% sure of that.
Hope that helps.
0 Comments
Sign in to comment.