Plotting the solutions of an equation (rotated ellipsoid)
1 view (last 30 days)
Show older comments
Here is the equaion
one equation with three unknowns, so we need to give two variables to get the third one. Here is what I have done to solve the equation and plot the solutions:
Eqn = 4*x^2 - (y - 1/3)*((3*3^(1/2)*(z - 1/6))/16 - (13*y)/16 + 13/48) - (z - 1/6)*((3*3^(1/2)*(y - 1/3))/16 - (7*z)/16 + 7/96) == 1;
S = solve(Eqn, [z, x, y], 'ReturnConditions', true);
Av1 = -.6; Bv1 = .6; Nv1=15; Av2 = -1; Bv2 = 2; Nv2=20;
[iv1, iv2] = meshgrid(linspace(Av1, Bv1, Nv1), linspace(Av2, Bv2, Nv2));
iv1 = iv1(:);
iv2 = iv2(:);
v1 = zeros(2,1); v2 = zeros(2,1); v3 = zeros(2,1);
sv1 = zeros(2,1); sv2 = zeros(2,1); sv3 = zeros(2,1);
counter = 1;
for i = 1: length(iv1)
Zv = subs(S.zv, S.parameters, [iv2(i), iv1(i)]);
if isreal(Zv(1))
v1(counter) = iv1(i);
v2(counter) = iv2(i);
v3(counter) = max(Zv);
sv1(counter) = iv1(i);
sv2(counter) = iv2(i);
sv3(counter) = min(Zv);
counter = counter +1;
end
end
V = [v1, v2, v3]; %these are the points on the upper part of rotated ellipsiod
sV = [sv1, sv2, sv3]; %these are the points on the upper part of rotated ellipsiod
v1lin = linspace( min(v1), max(v1), 100);
v2lin = linspace(min(v2), max(v2), 100);
[Xv, Yv] = meshgrid(v1lin, v2lin);
Zv = griddata(v1,v2,v3,Xv,Yv, 'cubic');
sv1lin = linspace( min(sv1), max(sv1), 100);
sv2lin = linspace(min(sv2), max(sv2), 100);
[sXv, sYv] = meshgrid(sv1lin, sv2lin);
sZv = griddata(sv1,sv2,sv3,sXv,sYv, 'cubic');
figure
mesh(Xv, Yv, Zv)
xlabel('Xv')
ylabel('Yv')
zlabel('Zv')
hold on
axis tight
mesh(sXv, sYv, sZv)
title('The complete surface by using Griddata interpolate on V vectors')
figure
mesh(Xv, Yv, Zv)
xlabel('Xv')
ylabel('Yv')
zlabel('Zv')
hold on
axis tight
title('The half surface by using Griddata interpolate on V vectors')
As the obtained solutions are not uniformly distributed, I have used the griddata() to generate some uniformly spaced points to be able to plot the desired surface. However, the problem is that I cannot get to the complete rotated ellipsoid. Please see the attached photos. The blue points are the points which have been obtained by solving the equation. From mathematics, I know that the equation above is a rotated ellipsoid, but I cannot get there and always there is some part missing.
Is there any idea on how I can find some more points on the ellipsoid by solving the equation (or using some other techniques) which help me to plot the entire ellipsoid?
I should say that I have asked this question in another way here. However, as it has not received any notable attention, I tried to ask my question in a new way here.
Any help would be appreciated.
0 Comments
Answers (1)
Matt J
on 21 Sep 2021
Edited: Matt J
on 21 Sep 2021
If you have the center, radii, and yaw-pitch-roll angles (in degrees) of the ellipsoid, you can plot a data-free ellipsoidalFit object using,
The final section in the Examples tab at this link gives examples of this, but basically it is,
gtEllip=ellipsoidalFit.groundtruth([],center,radii,yaw_pitch_roll);
plot(gtEllip)
3 Comments
Matt J
on 22 Sep 2021
it is possible to set the color in your tool set
Yes, definitely. Plenty of examples of that at the link I gave you.
or if it is possible to have the figure as a mesh
Not directly, but you can use the gtEllip.sample() method to get surface points on the ellipse and then use alphaShape() to get a mesh, as we talked about in another thread today.
or to add the axis at the origin?
You can use line() to add lines to the plot.
See Also
Categories
Find more on Matrix Computations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!