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.
인용 양식
John Kearns (2025). viewvec() - Get Cartesian Normal Vector of Current Axis View (https://kr.mathworks.com/matlabcentral/fileexchange/132203-viewvec-get-cartesian-normal-vector-of-current-axis-view), MATLAB Central File Exchange. 검색 날짜: .
MATLAB 릴리스 호환 정보
개발 환경:
R2023a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux태그
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!viewvec
| 버전 | 게시됨 | 릴리스 정보 | |
|---|---|---|---|
| 1.0.0 |
