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

Version 1.0.0 (2,35 KB) von John Kearns
viewvec() returns the cartesian normal vector of the current axis view. Developed as the inbuilt view() mainly returns spherical angles.
4 Downloads
Aktualisiert 11. Jul 2023

Lizenz anzeigen

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.

Zitieren als

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. Abgerufen .

Kompatibilität der MATLAB-Version
Erstellt mit R2023a
Kompatibel mit allen Versionen
Plattform-Kompatibilität
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!
Version Veröffentlicht Versionshinweise
1.0.0