Updated 23 Jun 2016
DEMO Video: https://www.youtube.com/watch?v=xHjyinJnIF8
Folders with various examples. Skip right to 4 if you just want the final code!
1. Figure, axis, and plot objects & changing their properties
2. 3D patch objects - single patches, compound patches, rotating patches, translating patches, adding keyboard controls to patches
3. Camera control - changing camera position, target, orientation, and view angle. Following an airplane 1st person, 3rd person?
4. Stuff to improve viewing:
- Importing 3d models as patch objects - cessna, A10
- Adding ground with texture and lighting
- Adding the horizon
- Final example incorporating 1,2,3,4
*** Credit to Eric Johnson for his great STLREAD function on the file exchange: https://www.mathworks.com/matlabcentral/fileexchange/22409-stl-file-reader
Originally created for use in Andy Ruina's flight dynamics course @ Cornell University.
**** NOTE: I use the "fig.Properties = 'something'" way of changing things. This works on MATLAB 2014b+. If you are using an older version, you will need to use something like set(fig,'Properties','something') To my knowledge, all other parts are compatible with previous versions.
Matthew Sheen (2020). User-controlled 3D Airplane Animation -- Set of examples (https://github.com/mws262/MatlabPlaneGraphics), GitHub. Retrieved .
The examples require the angle2dcm function in the aerospace toolbox to calculate the rotation matrix. The angle2dcm function is for frame transformation, not for rotation transformation. Therefore, the object rotates in the opposite direction to the specified direction. I put the correct rotation function at https://github.com/fuxicon/Animate-Graphics-Object-in-Matlab (you can rename the function to angle2dcm and run the examples if you don't have the aerospace toolbox)
Using this for visualization of vehicle dynamics simulations. Works great, many thanks!
edits to description
Inspired by: STL File Reader