Today in the MATLAB forum, there is a friend of the altar to draw a known relative angle relative length of continuous segments.
Looked up some information and thought about some ways. It is found that it can be solved by using polar coordinates to draw vectors and then by the way of vector superposition. Write a Trans_cood function:
1function [lx,ly] =Trans_cood (x,y,rho,r)2th = [0; rho*pi/ the]; 3Rho = [0; R]; 4[Xvec,yvec] =Pol2cart (Th,rho); 5Lx (1) =x; 6Ly (1) =y; 7Lx (2) = x + Xvec (2); 8Ly (2) = y + Yvec (2);
In this function Pol2cart generates a starting point for (0,0), the angle is determined by rho, and the relative length is determined by the vector of R. Adding this vector to the origin, we get the required continuous segment coordinates LX (2), Ly (2).
Example: Follow this example to draw a path map:?
1p_x =0; P_y =0; 2Rectangle'Position', [0 0 4 4.598]); 3x =0; y =0; 4RHO = [ -,0, -, -, -, -, -, -, -, -, -, -, the, -, -, -, -, -, -, -, -, -, -,0, -, -, -, -, -, -,0, the]; 5 6R = [0.866025403784439,0.500000000000000,1,1,1,1,1,1,1,0.866025403784439,1,0.866025403784439,0.500000000000000,1,1,1,1,1,1,1,0.866025403784439,1,0.866025403784439,0.500000000000000,1,1,1,1,1,1,0.500000000000000,0.866025403784439]; 7 fori =1: + 8[Lx,ly] =Trans_cood (X,y,rho (i), R (i)); 9x = Lx (2); y = Ly (2); P_x =[p_x Lx (2)]; p_y = [P_y Ly (2)]; Ten End One axis Equal APlot (p_x,p_y,'o','Markerfacecolor','R','Markeredgecolor','k','markersize',Ten); -H = Quiver (p_x (1: end-1), P_y (1: end-1), P_x (2: End)-P_x (1: end-1), P_y (2: End)-P_y (1: end-1)); -Axis ([-0.5 4.5-0.5 5]); the SetH'Color','b','maxheadsize',0.1); -box on;?
MATLAB uses polar coordinates to transform the relative length of a segment