How to move random point on an arc by matlab

8 ビュー (過去 30 日間)
omar th
omar th 2021 年 11 月 24 日
コメント済み: omar th 2021 年 12 月 4 日
I deployed 2 nodes randomly by Binomial point process and
I wanted to move them on arc for specific distance then keep moving on straight line for specific distance and so forth, instead of Only move these nodes in straight lines.
given the turingangle of arc, length of arc, speed, acceleration of that node
could someone help me with that by using Matlab ? or advice me if this can be achieved by using Matlab and how ?
thanks in adance

採用された回答

Image Analyst
Image Analyst 2021 年 11 月 24 日
Take your two points, and the angle you want to rotate them by, and construct the rotation matrix
r = [cosd(theta), -sind(theta); sind(theta), cosd(theta)];
Then multiply your x,y to get the rotated xy
x = 5;
y = 0
plot([0, x], [0, y], 'b.-', 'MarkerSize', 50, 'LineWidth', 3)
grid on;
% Construct rotation matrix
theta = 25;
r = [cosd(theta), -sind(theta); sind(theta), cosd(theta)];
% Then multiply your x,y to get the rotated xy
xyRotated = r * [x; y];
xr = xyRotated(1);
yr = xyRotated(2);
hold on
plot([0. xr], [0, yr], 'r*-', 'MarkerSize', 30, 'LineWidth', 3)
axis equal; % Need equal so the angle is not squashed.
  9 件のコメント
Image Analyst
Image Analyst 2021 年 12 月 3 日
You just have to subtract the drone position so that the drone if at the origin. Then get the incoming/prior angle. And add the desired "turn" to that angle to get a new angle. Multiply by the radius to get the new location. Then add back in the original drone position to shift the system back to its original location.
omar th
omar th 2021 年 12 月 4 日
I really appreciate your help
Please, would you give me an example, by coding, if you don't mind?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by