drawVector- draws 2D or 3D vectors from specified points
버전 1.2.3 (38.8 KB) 작성자:
J. Benjamin Kacerovsky
Draws 3 arrows representing the basis vectors of an R3 coordinate system
drawVector - draws 2D or 3D vectors from specified points
drawOrdinates - draws 3 arrows representing the basis vectors of an R3 coordinate system
----------------------------------
drawVector - is a very simple function to make drawing vectors using the
quiver and quiver3 functions a little more convenient
all this is to prepare the input from xyz triplets or lists of pints and
vectors and pass it into the quiver or quiver3 functions
I was just getting tired of typing it out every time
Syntax:
q=drawVector(points, vectors);
q=drawVector(points, vectors, color);
q=drawVector(points, vectors, color, weigth);
drawVector(points, vectors);
drawVector(points, vectors, color);
drawVector(points, vectors, color, weigth);
Inputs:
points - Nx3 (3D) or Nx2 (2D) matrix; rows correspond to points
if N==1 the same point will be used as origin for all vectors
vectors - Nx3 (3D) or Nx2 (2D) matrix; rows correspond to vectors
color - (optional) string ('r', 'red', etc), RGB triplet or
hexadecimal string; default='red
weight - (optional) scalar setting LineWidth and arrow head size; default=3;
Outputs:
for simple drawing the output does not have to be defined
defining the output, p, saves the graphics element to allow later editing
Example:
% draw 3 red vector arrows from 3 points
% red is the default color
p=[0 0 0; 0 1 1; 2 1 1];
v=[1 1 1; 2 3 -4; 1 0 0];
drawVector(p, v);
axis equal
% draw 3 blue vector arrows from a single point with wider lines
p=[2 1 1];
v=[1 1 1; 2 -3 -1; 1 0 0];
drawVector(p, v, 'blue', 5);
axis equal
% defining the output saves the graphics element and allows for later
% changes to quiver properties
p=[2 1 1];
v=[1 1 1; 2 -3 -1; 1 0 0];
q=drawVector(p, v, 'blue', 5);
axis equal
q.LineStyle='-.';
-----------------------------
drawOrdinates - simple function to draw arrows representing the basis
vectors of any R3 coordinate system
Syntax: drawOrdinates
drawOrdinates(ord, ori)
drawOrdinates(ord, ori, ...)
this is a simple function to draw 3 vectors representing the axes of a
coordinate system
All this really does is prepare the inputs to pass them into the built-in
quiver3 function. I was just tired of typing it out all the time.
Inputs:
ord - ordinates; 3x3 matrix, each column represents one axis as a 1x3
vector. default x, y, z unit vectors at the origin ([1, 0, 0; 0, 1, 0; 0, 0, 1])
ori - origin; 1x3 matrix specifing the coordinates at which to draw;
default [0, 0, 0]
Optional Name-Value pairs
scale - scalar; factor by which to scale the length of each arrow;
default=0
weight - scalar; defines lineweight and arrow head size; default=3
colors - 1x3 list of strings defining colors for each vector;
default=['r', 'b', 'g']);
alternative: 3x3 matrix, where each row defienes one arrow color as
an RGB triplet
Outputs:
no outputs need to be specified
Example 1:
% calling the function without specifying any input will draw 3 unit
% vectors along the x, y, and z axis at the origin
drawOrdinates
Example 2:
% vec=[3, 4, 5]; % start with a random vector
% vec=vec/norm(vec); % normalize
% ord=null(vec); % use null(x) to find 2 orthonormal vectors
% ord=horzcat(vec', ord); % concatenate matrix of orthonormal basis vectors
%
% % draw new ordinates with default settinngs at the origin
% drawOrdinates(ord);
% axis equal
%
% % draw new ordinates centered at [2, 10, 3] with a changed appearence
% drawOrdinates(ord, [2, 10, 3], 'weight', 5, 'scale', 5, 'colors', [0 0 1; 0 0 1; 0 0 1]);
% axis equal
인용 양식
J. Benjamin Kacerovsky (2024). drawVector- draws 2D or 3D vectors from specified points (https://github.com/JBKacerovsky/Draw_Vector), GitHub. 검색됨 .
MATLAB 릴리스 호환 정보
개발 환경:
R2019b
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux카테고리
- MATLAB > Graphics > 2-D and 3-D Plots > Vector Fields >
Help Center 및 MATLAB Answers에서 Vector Fields에 대해 자세히 알아보기
태그
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!PlanePlotter
TestObjects
Voxel2Mesh
이 GitHub 애드온의 문제를 보거나 보고하려면 GitHub 리포지토리로 가십시오.
이 GitHub 애드온의 문제를 보거나 보고하려면 GitHub 리포지토리로 가십시오.