Question regarding impoly restraint to move about a specified path

1 回表示 (過去 30 日間)
Saikat Banerjee
Saikat Banerjee 2020 年 6 月 11 日
コメント済み: Saikat Banerjee 2020 年 6 月 14 日
Lets say I have an implicit equation in x and y f(x,y)=x^2 + y^2 -5*x +12*y +24 which is an example. I construct an impoly with three or n number of vertices over the curve.My question is how can I restrict the movement of vertices of impoly to be restricted to follow the path of the curve.
  2 件のコメント
darova
darova 2020 年 6 月 12 日
PLease attach some example or something
Saikat Banerjee
Saikat Banerjee 2020 年 6 月 12 日
I have already attached example. Read question carefully. Let us say we construct a circle through fimplicit(x^2 + y^2 -5*x +12*y +24). After that we construct a traingle with three vertices using impoly. Now the vertices of the triangle will only move along the Circle. Restrain the movement of vertices using impoly along the circle. It will not go inside the circle or can come out of the circle. It will only move on the curve of the Circle

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

採用された回答

darova
darova 2020 年 6 月 13 日
Use setPositionConstraintFcn function
function main
clc,clear
x = 0:.05:10;
y = sin(x);
plot(x,y,'.-r')
h = impoly(gca,[0:2; sin(0:2)]'); % create impoly on the curve
setPositionConstraintFcn(h,@fcn) % assign constraint
function newPos = fcn(currPos)
d = pdist2([x(:) y(:)],currPos);
[~,ix] = min(d); % find closest points
newPos = [x(ix); y(ix)]'; % constrained position
end
end

その他の回答 (1 件)

Ameer Hamza
Ameer Hamza 2020 年 6 月 12 日
You can use fimplicit() to get the points on the equation and then pass those points to impoly()
f = @(x, y) x.^2 + y.^2 - 5*x + 12*y + 24;
fi = fimplicit(f, [-3 8 -15 0]);
x = fi.XData;
y = fi.YData;
  2 件のコメント
Saikat Banerjee
Saikat Banerjee 2020 年 6 月 13 日
I construct impoly as h=impoly([-1,-5];[3,-1];[5,-8]); Now give the rest of the code. I can't understand
Saikat Banerjee
Saikat Banerjee 2020 年 6 月 14 日
This answer is also of help but the other one is better

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

カテゴリ

Help Center および File ExchangeData Import and Analysis についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by