フィルターのクリア

points lying on a line from a particular distance

1 回表示 (過去 30 日間)
KalMandy
KalMandy 2017 年 2 月 18 日
回答済み: Matt J 2017 年 2 月 18 日
Hi All, In my matlab program , I find two points from solving the line equation (given a point and the angle) and the distance equation. ex:
syms x y
[solx,soly]=solve(y-m*x==yc-m*xc , (x-xc).^2+(y-yc).^2==d^2)
here (xc,yc) is the point coordinate, m is tand(angle) and d is distance. my angle rotates from 0-360 degrees.
my problem is (solx,soly) gives me two solutions, although I want to calculate only in angle=0 degrees direction. For example, I do not want the solution for angle 0 and 360 at the same time. Do you know how I can just sort out the point lying in angle 0 direction for instance?
  2 件のコメント
Matt J
Matt J 2017 年 2 月 18 日
I do not want the solution for angle 0 and 360 at the same time
You should be letting the angle run from only 0 to 180. Angles theta and 180+theta will always correspond to the same line.
Even then, though, you will have 2 intersection points.
KalMandy
KalMandy 2017 年 2 月 18 日
Thank you!

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

採用された回答

Matt J
Matt J 2017 年 2 月 18 日
A better way to obtain the points might be parametrically
theta=0:359;
x=xc+d*cosd(theta);
y=yc+d*sind(theta);

その他の回答 (1 件)

Matt J
Matt J 2017 年 2 月 18 日
編集済み: Matt J 2017 年 2 月 18 日
You should be restricting the angle to (-90, 90). tan() has redundant or undefined values outside that interval. In particular, you must avoid angles +/-90 deg. where yc-m*xc will be infinite.
This restriction will still give you two solutions, but you can throw away the solution for which x < xc.
  2 件のコメント
KalMandy
KalMandy 2017 年 2 月 18 日
編集済み: KalMandy 2017 年 2 月 18 日
but I need to find the points lying d distance away from (xc,yc) in all 360 angles (However the solution will not be a circle, due to some other conditions). what can i do in this case?
Matt J
Matt J 2017 年 2 月 18 日
編集済み: Matt J 2017 年 2 月 18 日
Then keep both solutions returned by solve(). One corresponds to angle theta, the other to theta+180. As I said, though theta=+/-90 has no solution. You will have to compromise on that case.

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by