필터 지우기
필터 지우기

Draw a line with an angle

조회 수: 132 (최근 30일)
SUBHA GHOSH
SUBHA GHOSH 2017년 6월 30일
편집: Garvit Amipara 2021년 4월 8일
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
Jan 2017년 6월 30일
Fine. What is your question? What have you tried so far and which problem occurres?
Image Analyst
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
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
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Hilbert and Walsh-Hadamard Transforms에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by