Question regarding impoly restraint to move about a specified path
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Saikat Banerjee
am 11 Jun. 2020
Kommentiert: Saikat Banerjee
am 14 Jun. 2020
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 Kommentare
Akzeptierte Antwort
darova
am 13 Jun. 2020
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
0 Kommentare
Weitere Antworten (1)
Ameer Hamza
am 12 Jun. 2020
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 Kommentare
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!