Draw a line with an angle
132 ビュー (過去 30 日間)
古いコメントを表示
we have a point(x,y) and length of the line is L and the angle between horizontal line and the draw line is A.
2 件のコメント
Jan
2017 年 6 月 30 日
Fine. What is your question? What have you tried so far and which problem occurres?
Image Analyst
2017 年 6 月 30 日
There is a line function you know. Just specify the two endpoints, which can be computed from simple trig.
line([x1,x2], [y1,y2], 'Color', 'r', 'LineWidth', 2);
回答 (1 件)
Ahmed raafat
2017 年 7 月 29 日
%L is the length
%angle is alpha
x2=x+(L*cos(alpha));
y2=y+(L*sin(alpha));
plot([x x2],[y y2])
1 件のコメント
Garvit Amipara
2021 年 4 月 8 日
編集済み: Garvit Amipara
2021 年 4 月 8 日
This works perfectly!
Note: instead of sin(alpha), cos(alpha), use sind(alpha) and cosd(alpha) to avoid the floating point errors of the sin and cos values.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!