フィルターのクリア

How to rotate a fixed length Line about a perimeter of a circle

1 回表示 (過去 30 日間)
S
S 2020 年 9 月 14 日
コメント済み: S 2020 年 9 月 15 日
I am new to coding matlab.
I wish to code the above situation as shown in to picture where a fixed length line(or tangent) is rotated inside a large grid in a circular manner with fixed radius and the center is chosen same as the large grid.
Any suggestion - how can I proceed to code above situation ?
Thank you.
  2 件のコメント
Matt J
Matt J 2020 年 9 月 14 日
What would be the input and output of such code?
S
S 2020 年 9 月 15 日
I am trying to learn how to use the rotation matrix formula for different situations.

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

採用された回答

Image Analyst
Image Analyst 2020 年 9 月 14 日
It's simple geometry. Just pick a radius, then go from 0 to 2*pi, or whatever angles you want. The slope is
angle = linspace(0, 2*pi, 360);
y = radius * sind(angle);
x = radius * cosd(angle);
slope = atand(y/x);
The slope of the perpendicular to that point is -1/slope. Now pick a new radius that is the length of the little line segment you want to create and create new x,y values (xr, yr) using the above formulas. These will be relative to the origin. Then add the original x,y to move that line segment from the origin to the (x,y) point out at the circle perimeter. It sounds like homework so that's why I'm not providing a full solution but it's pretty easy now that I've explained it and you'll have no problem finishing it.
  1 件のコメント
S
S 2020 年 9 月 15 日
Thanks you very much for the suggestion. I will follow it. :-)

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by