Matlab's default rotate3d suffers from Gimbol-Lock effect. Using this trackball function, one can better enjoy 3D plot viewing.
simbaforrest (2021). trackball for better viewing 3D plot (https://www.mathworks.com/matlabcentral/fileexchange/56922-trackball-for-better-viewing-3d-plot), MATLAB Central File Exchange. Retrieved .
Hi Chen. I realized afterwards that the issue related to the axis units in the GUI rather than the code itself.
I tried the script you provided and maximize the figure, it appears that the rotation works fine (unless the sphere is shown with a very small scale, and in that case, just zooming in should solve the problem). Let me know if this is the case.
Thanks for your response Chen. Actually it has nothing to do with data volume. Rotation is very smooth even with a one million cloud using pcshow() (Computer Vision Systems Toolbox) on my notebook. The issue appears to relate to the size of the figure window. Using the worked example:
At the default figure window display size the function works nicely. However, if you maximize the figure, the mouse movements translate to very marginal rotations of the sphere. This is very frustrating when the current axis is in a GUI (which needs to be maximized). Is there a work around for scaling the mouse movements to a maximized figure. It would be a very useful function for GUI tools if this can be fixed.
Are you drawing lots of points or lines? If that is the case, it will indeed be sluggish, which I think is due to Matlab's poor rendering pipeline rather than this script. Maybe you can turn on some hardware acceleration?
Do you know how to increase sensitivity of rotation to mouse movements? The code is an improvement over default rotate but is a little sluggish.
Inspired by: Virtual Tackball
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!