Arcball like 3D figure rotation
One of the major drawbacks of matlab is the lack of a way of changing the viewpoint of a 3D mesh using a natural (arcball) interaction.
In this simple function I demonstrate the arcball interaction allowing a 3D sphere to be moved naturally. Run the function and drag and drop with your mouse on the sphere surface.
A very important aspect that you should note is that I am rotating the ACTUAL 3D object instead of the viewpoint.
There is a specific reason for this choice. The OpenGL lighting is linked to the axis in matlab, thus, if you rotate the veiwpoint, the lighting on the mesh surface wouldn't change. On the other hand, if you rotate your object using hgttransoforms you achieve this result.
It is now apparently bug-free :)
Cite As
Andrea Tagliasacchi (2024). Arcball like 3D figure rotation (https://www.mathworks.com/matlabcentral/fileexchange/19760-arcball-like-3d-figure-rotation), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
- MATLAB > Graphics > Formatting and Annotation > 3-D Scene Control > Lighting, Transparency, and Shading >
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Version | Published | Release Notes | |
---|---|---|---|
1.0.0.0 | Corrected a bug in the rotation direction update which caused the "bug". Now it works nicely. |