I have a typical problem I want to solve the intersection point of two polynomial curves by moving the curves within specific limits of X and Y. My problem is let's say we have equation of two 2Dimensional circles say x^2 + y^2 + 5*x + 12*y +15 and x^2 + y^2 -18*x -22*y -24. Now I want to drag both the circles within specific limits of x and y and if the two circles intersect each other simultaneously solve the point of intersections and display them along with two circles I have one solution here https://in.mathworks.com/matlabcentral/fileexchange/4179-draggable which uses the plot function to drag the figures however the only problem is it does not solve and displays the point of intersection of two curves I tried the code on fimplicit but it gives error that X data and y data are read only. If anybody can help me

8 commentaires

Walter Roberson
Walter Roberson le 15 Juil 2020
So as you dragged them, you would be changing their implied centers, while leaving the radii the same?
Currently:
center (-5/2, -6) radius sqrt(109/4)
center (9, 11) radius sqrt(226)
Saikat Banerjee
Saikat Banerjee le 15 Juil 2020
Look the equations of circle are just an example in general it will be a polynomial in X and Y of maximum degree 2 so do not solve this just for a circle but solve it for a General polynomial of degree 2 one more thing the equation of polynomial will not change during the drag process. I mean to say that the shape of the polynomial will not change but only the position of the points will change
Saikat Banerjee
Saikat Banerjee le 15 Juil 2020
Modifié(e) : Steven Lord le 15 Juil 2020
what I mean to say is relative position of the points with respect to each other will not change but the overall position of the point with respect to the axis will change
[SL: formatted comment as text rather than code]
Walter Roberson
Walter Roberson le 15 Juil 2020
A circle is a multinomial with total degree 2, not a polynomial.
If you have any y terms other than a constant times y, or if you have any xy terms, then you do not have a polynomial (unless you reversed the x and y axes)
Saikat Banerjee
Saikat Banerjee le 15 Juil 2020
Well let us define the equation as such :- each term of the equation will be of his form. a*(x^m)*(y^n). Where a = any real number n=[0,1,2] m=[0,1,2] and m+n<=2. (integer number 0,1,2). Mostly it will be used for conic sections like Circle Parabola ellipse etc and straight line. i am rather interested to get dynamic intersection points of two or more curves when they are moved around
Saikat Banerjee
Saikat Banerjee le 15 Juil 2020
The same can be stated in another way. The equation of polynomial is of the form a*x^2 + b*y^2 + c*x*y + d*x +e*y +f. Where each of the terms a,b,c,d,e,f is any real number including zero
Saikat Banerjee
Saikat Banerjee le 17 Juil 2020
can anyone provide an answer for anybody working on this problem
Walter Roberson
Walter Roberson le 17 Juil 2020
I am so backlogged on answering people, that I cannot even find some of the posts that are waiting for responses from me. I have active contributions to over 30 different Questions per day, plus material I read but do not contribute to, plus a heck-load of software upgrades for me this week. I have made it to bed before day once in the past two weeks.

Connectez-vous pour commenter.

 Réponse acceptée

Walter Roberson
Walter Roberson le 17 Juil 2020

1 vote

Set a ButtonDownFcn callback for each of the graphic objects. The callback should just register which of the objects was selected.
Set a WindowButtonUpFcn callback for the figure. The callback should unregister the last last object, so that no objects would be marked as selected.
Set a WindowButtonMotionFcn callback for the figure. The callback should check to see if any object is marked as active, and if not it should return. If an object is marked as active, then get the Axes CurrentPoint . Now take the XData and YData for the selected graphics object and subtract off the mean x and mean y coordinates, and add the x and y of the CurrentPoint, and set those as being the new XData and YData of the graphics object. This will have the effect of moving the graphics object to be centered around the place the user is pointing to.
Under some circumstance, you will want to trigger detection of potential intersection and calculation of the exact intersection for your purposes. It might perhaps make sense to program that into the WindowButtonUpFcn callback under the circumstance that an object was indeed active.

10 commentaires

Saikat Banerjee
Saikat Banerjee le 17 Juil 2020
Modifié(e) : Walter Roberson le 17 Juil 2020
sir I beg your pardon that I am not a software professional but an engineering professional these words are simply Greek to me. moreover the Xdata and Ydata object of an implicit function gives error that they are read only. Sir I would appreciate if you write the entire program taking two function values as input. the two functions can be dragged around the current Axis which can be set and whenever one function intersects another function then a label will display the point of intersection and their coordinates. Sir if you write this full programme I will simply copy paste it and run in matlab. A detailed help is needed.
Saikat Banerjee
Saikat Banerjee le 17 Juil 2020
If the function intersect in multiple points then coordinates of all points are needed
h = fimplict(appropriate arguments for first conic);
F(1).Function = h.Function;
F(1).XData = h.XData;
F(1).YData = h.YData;
F(1).meanx = mean(F(1).XData, 'omitnan');
F(1).meany = mean(F(1).YData, 'omitnan');
delete(h);
F(1).h = plot(F(1).XData, F(1).YData);
h = fimplict(appropriate arguments for second conic);
F(2).Function = h.Function;
F(2).XData = h.XData;
F(2).YData = h.YData;
F(2).meanx = mean(F(2).XData, 'omitnan');
F(2).meany = mean(F(2).YData, 'omitnan');
delete(h);
F(2).h = plot(F(2).XData, F(2).YData);
Now F(1).h and F(2).h are line() objects that you can attach callbacks to, and drag around using the techniques I described above.
I talked about "subtract off the mean x and mean y coordinates, and add the x and y of the CurrentPoint" to get the graphics object to be centered around CurrentPoint. But the original center of the graphics object is not necessarily the same as the coordinate system used in the function: you have to subtract off meanx and meany to get the origin of the coordinate system used in the function.
In order to compute the intersection points, you would need to do a change of coordinates on the recorded Function, substituting (x - currentcentroid_x+meanx) for x and (y - currentcentroid_y+meany) for y to get the revised function. You would do that for both parts and then do the calculation of intersections.
I do not have time to write the entire program for you. I already mentioned above that I am answering a lot of people at this time. You have something non-trivial that you want done, and I have described how it can be done. Our purpose in MATLAB Answers is not to offer free software development: it is to educate people so that they can develop the software themselves (or at least know what to tell the people they get to do the development for them.)
Saikat Banerjee
Saikat Banerjee le 18 Juil 2020
Modifié(e) : Walter Roberson le 18 Juil 2020
"% Now F(1).h and F(2).h are line() objects that you can attach callbacks to, and drag around using the techniques I described above.
I talked about "subtract off the mean x and mean y coordinates, and add the x and y of the CurrentPoint" to get the graphics object to be centered around CurrentPoint. But the original center of the graphics object is not necessarily the same as the coordinate system used in the function: you have to subtract off meanx and meany to get the origin of the coordinate system used in the function.
In order to compute the intersection points, you would need to do a change of coordinates on the recorded Function, substituting (x - currentcentroid_x+meanx) for x and (y - currentcentroid_y+meany) for y to get the revised function. You would do that for both parts and then do the calculation of intersections."
Just translate this much from simple english language to matlab code. I will do the rest. I only ask for help only if i myself fail to do it. Upto the point you have given the code can also be got through the link I have given earlier. the important part is that while moving it will continiously that whether it is crossing the path of any other fimplicits and if it is crossing at every point it will calculate and print the co-ordinates of point. thisis the most difficult part. please write the motionfcn and dragfcn and other codes in Matlab. ipromise wherever I use this code I shall give due credit to you
Walter Roberson
Walter Roberson le 18 Juil 2020
Thinking again, I do not think it is needed to find the original centroid and then be continually adding or subtracting the centroid. Doing that gives the advantage of being able to point to a particular location with the mouse and have what is under the crosshairs be the new origin, but I think it is probably easier to leave it out, and have the cursor effectively just drag the origin.
Walter Roberson
Walter Roberson le 18 Juil 2020
For each of the function, you will want to record the original function, and you will also want to record the current version of the function, which you will update according to where you drag the line to, by substituting (x-current_point_x) for x, and (y-current_point_y) for y. Then find the intersection of the two current versiosn of the functions.
To find the intersection of the two functions, it will probably be easier to express them in terms of the same variables -- the outline I posted above has the possibility that they are in terms of different variables because fimplicit does not have to be passed equations with particular variables.
Saikat Banerjee
Saikat Banerjee le 18 Juil 2020
Sir just give the Matlab code and not just ideas. I cannot code such advanced matlab
Walter Roberson
Walter Roberson le 18 Juil 2020
You want something complicated done, you can put in the effort of learning MATLAB to write the code. Or you can hire someone. The role of the volunteers here is to educate, not to be a free program writing service.
I will typically answer specific questions (but not necessarily immediately because I have other things to do), and I will help debug code you have produced, but I will not do your task for you. Also I am dealing with a lot of different questions and people at the same time, and people who demand that I do things for them have lower priority for my attention than people who ask specific questions and demonstrate that they are trying to learn.
Saikat Banerjee
Saikat Banerjee le 19 Juil 2020
then please do not comment further on this post I will ask for help from someone else who would genuinely help me
Walter Roberson
Walter Roberson le 19 Juil 2020
We have different ideas about what is involved to "help" you. The volunteers here mostly believe that the best way to "help" people is to teach them how to do things, rather than for the volunteers to do the work on behalf of the people.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Mathematics dans Centre d'aide et File Exchange

Produits

Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by