specifying the coordinates of the corners of astraight line segments

조회 수: 1 (최근 30일)
Mads Albertsen
Mads Albertsen 2021년 8월 13일
답변: DGM 2021년 8월 13일
i have tried multiple different ways but always end up with errors, i need to make the following equation into a loop
The initial point is x0 = (0, 0)T and the initial direction is along a unit vector d0 = (1, 0)T .
the angel i get from a row vector consisting of alternating length and angle specifications [l1, φ1, l2, φ2, . . . ].
the l_n is always the same, but the angel changes, i split it up so i got 2 vectors, 1 with the length and 1 with the angels.
idk if it is enough information, in short, i want the equation to run the same number of times there is l_n in the vector.
if anymore information is needed let me know, and thanks in advance

답변 (1개)

DGM
DGM 2021년 8월 13일
Something like this?
pt0 = [0 0]; % initial position [x y]
segl = 1; % segment length
N = 10; % number of segments
% these are the polar component vectors
segments = ones(1,N)*segl;
angles = [0 45 90 45 -90 180 -135 -180 45 90];
% convert to rectangular deltas
pts = [segments.*cosd(angles); segments.*sind(angles)].';
% accumulate deltas
pts = cumsum([pt0; pts],1);
plot(pts(:,1),pts(:,2))
If the angles are relative, you could just do cumsum on the angle vector before converting.

카테고리

Help CenterFile Exchange에서 Direction of Arrival Estimation에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by