From: Walter Roberson on 29 Apr 2010 18:18 GAURAV wrote: > Hello Eveyone, > > I am trying to get an ellipse passing through the four points I have > which are not symmetric. > So, I am using the equation (X-Xc)^2/(a^2) + (Y-Yc)^2/(b^2) =1 > > I have four points which wil go in X and Y of the equation above. > Let the points be (a1,b1), (a2,b2), (a3,b3) and (a4,b4).. > > How do I get a,b,Xc and Yc from this?? Answer 1: [a = 0, b = 0, Xc = Xc, Yc = Yc] Answer 2: [a = (1/4) * 4^(1/2) * ((-a4 * b3 + a4 * b2 - b4 * a2 - a3 * b2 + a3 * b4 + b3 * a2) * (-a3 * b2 + a4 * b2 + a1 * b3 - a4 * b3 - a1 * b4 + a3 * b4) * (a3 * b4 - a3 * b2 + a1 * b2 + a2 * b2 - a4 * b2 - a1 * b3 + a4 * b3 - b4 * a2) * (a3 * b4 - a3 * b2 + a1 * b2 + a2 * b2 - a4 * b2 - b3 * a2 + a4 * b3 - a1 * b4) / ((-b4 + b3) * (-b4 + b2) * (-b3 + b2) * (-a4 * a1 * b3 + b2 * a4 * a1 - a1 * a2 * b4 - b2 * a3 * a1 + b4 * a3 * a1 + a1 * a2 * b3 + a3 * a2 * b4 - a4 * a2 * b3 + b2 * a3^2 - b2 * a3 * a2 - a3^2 * b4 + b3 * a4^2 + b2 * a4 * a2 - b2 * a4^2)))^(1/2), b = (1/2) * ((-a4 * b3 + a4 * b2 - b4 * a2 - a3 * b2 + a3 * b4 + b3 * a2) * (-a3 * b2 + a4 * b2 + a1 * b3 - a4 * b3 - a1 * b4 + a3 * b4) * (a3 * b4 - a3 * b2 + a1 * b2 + a2 * b2 - a4 * b2 - a1 * b3 + a4 * b3 - b4 * a2) * (a3 * b4 - a3 * b2 + a1 * b2 + a2 * b2 - a4 * b2 - b3 * a2 + a4 * b3 - a1 * b4))^(1/2) / (((-b4 + b3) * a2 + (b4 - b2) * a3 + (-b3 + b2) * a4) * a1 + ((b4 - b2) * a3 + (-b3 + b2) * a4) * a2 + (-b4 + b2) * a3^2 + (-b2 + b3) * a4^2), Xc = (1/2) * a1 + (1/2) * a2, Yc = (1/2) * (((b3^2 - b4^2) * a2 + (-b2^2 + b4^2) * a3 + (-b3^2 + b2^2) * a4) * a1 + ((-b2^2 + b4^2) * a3 + (-b3^2 + b2^2) * a4) * a2 + (b2^2 - b4^2) * a3^2 + (b3^2 - b2^2) * a4^2) / (((-b4 + b3) * a2 + (b4 - b2) * a3 + (-b3 + b2) * a4) * a1 + ((b4 - b2) * a3 + (-b3 + b2) * a4) * a2 + (-b4 + b2) * a3^2 + (-b2 + b3) *a4^2)] Answer 3: [a = -(1/2) * ((-a4 * b3 + a4 * b2 - b4 * a2 - a3 * b2 + a3 * b4 + b3 * a2) * (-a3 * b2 + a4 * b2 + a1 * b3 - a4 * b3 - a1 * b4 + a3 * b4) * (a3 * b4 - a3 * b2 + a1 * b2 + a2 * b2 - a4 * b2 - a1 * b3 + a4 * b3 - b4 * a2) * (a3 * b4 - a3 * b2 + a1 * b2 + a2 * b2 - a4 * b2 - b3 * a2 + a4 * b3 - a1 * b4) / ((-b4 + b3) * (-b4 + b2) * (-b3 + b2) * (-a4 * a1 * b3 + b2 * a4 * a1 - a1 * a2 * b4 - b2 * a3 * a1 + b4 * a3 * a1 + a1 * a2 * b3 + a3 * a2 * b4 - a4 * a2 * b3 + b2 * a3^2 - b2 * a3 * a2 - a3^2 * b4 + b3 * a4^2 + b2 * a4 * a2 - b2 * a4^2)))^(1/2), b = (1/2) * ((-a4 * b3 + a4 * b2 - b4 * a2 - a3 * b2 + a3 * b4 + b3 * a2) * (-a3 * b2 + a4 * b2 + a1 * b3 - a4 * b3 - a1 * b4 + a3 * b4) * (a3 * b4 - a3 * b2 + a1 * b2 + a2 * b2 - a4 * b2 - a1 * b3 + a4 * b3 - b4 * a2) * (a3 * b4 - a3 * b2 + a1 * b2 + a2 * b2 - a4 * b2 - b3 * a2 + a4 * b3 - a1 * b4))^(1/2) / (((-b4 + b3) * a2 + (b4 - b2) * a3 + (-b3 + b2) * a4) * a1 + ((b4 - b2) * a3 + (-b3 + b2) * a4) * a2 + (-b4 + b2) * a3^2 + (-b2 + b3) * a4^2), Xc = (1/2) * a1 + (1/2) * a2, Yc = (1/2) * (((b3^2 - b4^2) * a2 + (-b2^2 +b4^2) * a3 + (-b3^2 + b2^2) * a4) * a1 + ((-b2^2 + b4^2) * a3 + (-b3^2 + b2^2) * a4) * a2 + (b2^2 - b4^2) * a3^2 + (b3^2 - b2^2) * a4^2) / (((-b4 + b3) * a2 + (b4 - b2) * a3 + (-b3 + b2) * a4) * a1 + ((b4 - b2) * a3 + (-b3 + b2) * a4) * a2 + (-b4 + b2) * a3^2 + (-b2 + b3) * a4^2)] Answer 4: [a = (1/4) * 4^(1/2) * ((-a4 * b3 + a4 * b2 - b4 * a2 - a3 * b2 + a3 * b4 + b3 * a2) * (-a3 * b2 + a4 * b2 + a1 * b3-a4 * b3-a1 * b4 + a3 * b4) * (a3 * b4 - a3 * b2 + a1 * b2 + a2 * b2 - a4 * b2 - a1 * b3 + a4 * b3 - b4 * a2) * (a3 * b4 - a3 * b2 + a1 * b2 + a2 * b2 - a4 * b2 - b3 * a2 + a4 * b3 - a1 * b4)/((-b4 + b3) * (-b4 + b2) * (-b3 + b2) * (-a4 * a1 * b3 + b2 * a4 * a1 - a1 * a2 * b4 - b2 * a3 * a1 + b4 * a3 * a1 + a1 * a2 * b3 + a3 * a2 * b4 - a4 * a2 * b3 + b2 * a3^2 - b2 * a3 * a2 - a3^2 * b4 + b3 * a4^2 + b2 * a4 * a2 - b2 * a4^2)))^(1/2), b = -(1/2) * ((-a4 * b3 + a4 * b2 - b4 * a2 - a3 * b2 + a3 * b4 + b3 * a2) * (-a3 * b2 + a4 * b2 + a1 * b3 - a4 * b3 - a1 * b4 + a3 * b4) * (a3 * b4 - a3 * b2 + a1 * b2 + a2 * b2 - a4 * b2 - a1 * b3 + a4 * b3 - b4 * a2) * (a3 * b4 - a3 * b2 + a1 * b2 + a2 * b2 - a4 * b2 - b3 * a2 + a4 * b3 - a1 * b4))^(1/2)/(((-b4 + b3) * a2 + (b4 - b2) * a3 + (-b3 + b2) * a4) * a1 + ((b4 - b2) * a3 + (-b3 + b2) * a4) * a2 + (-b4 + b2) * a3^2 + (-b2 + b3) * a4^2), Xc = (1/2) * a1 + (1/2) * a2, Yc = (1/2) * (((b3^2 - b4^2) * a2 + (-b2^2 + b4^2) * a3 + (-b3^2 + b2^2) * a4) * a1 + ((-b2^2 + b4^2) * a3 + (-b3^2 + b2^2) * a4) * a2 + (b2^2 - b4^2) * a3^2 + (b3^2 - b2^2) * a4^2)/(((-b4 + b3) * a2 + (b4 - b2) * a3 + (-b3 + b2) * a4) * a1 + ((b4 - b2) * a3 + (-b3 + b2) * a4) * a2 + (-b4 + b2) * a3^2 + (-b2 + b3) * a4^2)]
From: Roger Stafford on 29 Apr 2010 18:41 Walter Roberson <roberson(a)hushmail.com> wrote in message <hrd0jl$bsc$1(a)canopus.cc.umanitoba.ca>... > ...... > Xc = (1/2) * a1 + (1/2) * a2, > ..... There is something decidedly fishy about those answers, Walter. In each of the answers 2, 3, and 4, they gave Xc as the average between a1 and a2. However, it would be easy to place the points (a1,b1) and (a2,b2) on an ellipse so that their x-coordinates are well off to one side of the ellipse's center and not equal to its average. What gives? Roger Stafford
From: Roger Stafford on 29 Apr 2010 19:07 Gaurav, I should mention that the solution you obtain for the five coefficients may not actually represent an ellipse but rather a hyperbola or a parabola. If that is the case and there is no other column of S which has a zero singular value, then presumably there exists no ellipse which would run through those four given points. What you actually have here is the solution to a general four-point conic which is aligned with the coordinate axes in which the conic can be any one of these three types (or in some cases a degenerate conic.) Roger Stafford
From: GAURAV on 29 Apr 2010 19:26 Hi Roger and Walter, In my case the points are at the extremes. So, two points on either side are at the border of the volume which is going to be formed. 3 1 2 ... four points could be like this or 4 3 1 2... I doubt if some ellipse could be fit to these set of points.. 4 Anyways, I will try with the solved solution set provided by Walter and see what happens. Any one of the last three solution set would work ? And Roger, I need to form a surface enclosing it.. Be it ellipse or some closed surface. But on each slice along the height I have just four points to form a surface. Any other ideas? I wish I could give the small code to you and you could see the output and that would have made more sense. Can I have email id of both of you so that I can email you, if you guys dont mind? Thanks a lot for your help. Appreciate it. Regards, Gaurav.
From: Bruno Luong on 29 Apr 2010 19:28 "Roger Stafford" <ellieandrogerxyzzy(a)mindspring.com.invalid> wrote in message <hrd0f4$4o1$1(a)fred.mathworks.com>... > "GAURAV " <gsharda(a)engineering.uiowa.edu> wrote in message <hrct9s$bpa$1(a)fred.mathworks.com>... > > Hi Roger, > > Thanks for your reply.. > > > > Actually its an assumption I am making. > > I have two curves(orthogonal to each other) aligned in 3D ( not necessarily symmetrical ). > > The height (along Z axis) is the same. So, when I cut a slice for some Z, I have four points (two from each curve). > > Now I need to construct a volume from these two views. So from each slice I am trying to fit in an ellipse. I hope this makes sense. > > > > So, now I have four points which pass through ellipse and ellipse should not go out of this bound . > > So, I am looking to solve the ellipse equation and try to find out of the a,b,xc and yc required for the ellipse with angle=0. > > > > Can you suggest something? > > > > Regards, > > Gaurav. > > For the four-point problem you can avoid using one of the non-linear methods by writing your equation in the following linear form. Then use 'svd' to determine the five unknown coefficients: > > A*x^2 + C*y^2 + D*x + E*y + F = 0 > > Do this: > > x = [a1;a2;a3;a4]; > y = [b1;b2;b3;b4]; > M = [x.^2,y.^2,x,y,ones(4,1)]; > [U,S,V] = svd(M); > A = V(1,5); > C = V(2,5); > D = V(3,5); > E = V(4,5); > F = V(5,5); > A note on Roger's solution: I would prefer normalize the eqt by fixing F = 1, for example. This will replace the calculation of svd by solving a 4x4 linear system. Bruno
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 5 Prev: SOLVE 4 NONLINEAR EQUATIONS (HELP PLEASE) Next: Using interp1 for timeseries data |