viewvec() - Get Cartesian Normal Vector of Current Axis View

Versión 1.0.0 (2,35 KB) por John Kearns
viewvec() returns the cartesian normal vector of the current axis view. Developed as the inbuilt view() mainly returns spherical angles.
6 Descargas
Actualizado 11 jul 2023

Ver licencia

viewvec(AxHandle) returns the cartesian normal vector for the current view/camera position of AxHandle.
normVec = viewvec(AxHandle);
% Inputs: AxHandle; Handle of the target axis object.
% Uses current axis (as in gca) is no input is specified
% Outputs: normVec; % a 1x3 normal vector of current view in target axis.
This function extends the utility of MATLAB's inbuilt 'view()' function, which only returns the shperical angles (or viewing matrix) of the current camera view. While 'view()' accepts a vector as an input to define the camera position/viewing angle, it cannot output a cartesian vector of the current view.
I wrote this because, when making figures for my research, I found that plotting curves over triangulation objects (such as when highlighting the free boundary of an STL/triangulation object with a coloured plot output) can lead the edges of the triangulation to bleed into the curve. While this can often be rectified by plotting two axes over one another, that is not always feasible to do and multiple overlaid axes increases the complexity of a script. The normal vector output from 'viewvec()' facilitates easy adjustment of axis children such that they are in front of or behind other other children relative to the current view, but will appear to be in the same position relative to the current view as they were prior to adjustment.
An example is included that shows points on a surface that appear to be unmoved relative to the initial camera position.

Citar como

John Kearns (2024). viewvec() - Get Cartesian Normal Vector of Current Axis View (https://www.mathworks.com/matlabcentral/fileexchange/132203-viewvec-get-cartesian-normal-vector-of-current-axis-view), MATLAB Central File Exchange. Recuperado .

Compatibilidad con la versión de MATLAB
Se creó con R2023a
Compatible con cualquier versión
Compatibilidad con las plataformas
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Versión Publicado Notas de la versión
1.0.0