Plotting line perpendicular to another on the endpoint

조회 수: 1 (최근 30일)
Garrett Purvis
Garrett Purvis 2019년 5월 9일
답변: Ryan Klots 2019년 5월 17일
Hello! I am looking to plot the perpendicular of my line at the endpoint of my line, forming a "T" shape.
My line starts at [0,0] and ends at [x,y] where
O = 0:pi/100:2*pi;
a = str2num(get(handles.Anibox,'String'));
n = str2num(get(handles.Numsides,'String'));
x = cos(O)+(a.*cos((n+1).*O));
y = sin(O)+(a.*sin((n+1).*O));
Is there a way to plot a line that is perpendicular to my line, and intersects at [x,y]?
also, would there be a way to control how long this line is?
Thank you for your help!

답변 (1개)

Ryan Klots
Ryan Klots 2019년 5월 17일
Note that any vector perpendicular to lies in the span of since . We can take advantage of this fact to construct the "T" bar.
Suppose we want each side of our "T" bar to have length r. We can constuct a vector of length r that is perpendicular to via the formula where is the norm of .
Then we can add this vector and its negative to in order to construct the endpoints of the "T" bar:

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by