Plotting Ellipsoids on XYZ graphs.
16 views (last 30 days)
Show older comments
Hi, Im new to here. I wanted to ask for assitance in plotting ellipsoids onto XYZ plots based on Excel data. The data shows details for seismic events but the analysis needs to be just looking into the data as points on a XYZ graph. I have no experience with Matlab and any help would be greatly appreciated.
The first column is to identify the point; Column B is the time of the event; Column C-E is the location of the point. Column D reflects the amount of energy released. Colums G-R are for eigenvalues and eigenvectors.
Each ellipsoid is described by the 3 semi-major axes, named 1, 2, 3 in our file.
The 3 columns Axis 1, Axis 2, Axis 3 are the length (eigenvalues) of the 3 semi-major axis in metres.
The next 9 columns define the semi-major axis vectors (eigenvectors), so for example [Vector 1 X, Vector 1 Y, Vector 1 Z] define the 3 direction cosines (XYZ) of the Axis 1 vector.
So for example:
Axis 1 of the ellipsoid for Trigger ID 1 (screenshot below) has half-length 61m. It has vector orientation [-0.97, -0.06, 0.25], which can be imagined as a 3D line between point [0,0,0] and [-0.97, -0.6, 0.25].
I want to see if its possible to write something to convert them into XYZ points on an ellipsoid surface.
Or Find the Max value for Axis 1, Axis 2, Axis 3 – which tells you the maximum location uncertainty in metres for each event. This will normally be Axis 3.
If you then look at Vector 3 Z it will usually be close to +1.0 or -1.0 (which are the maximum and minimum values). If it is close to +/- 1.0 it means that the axis is near vertical. If it is close to 0.0 then it is horizontal.
Surface monitoring networks normally have the greatest location uncertainty in depth.
These specific eigenvectors mean:
[X=0.0, Y=+/-1.0, Z=0.0] would be North/South (ie: the Y component is largest).
[X=+/-1.0, Y=0.0, Z=0.0] would be East/West (ie: X biggest)
[X=0.0, Y=0.0, Z=+/-1.0] would be vertical
I have 600+ rows and the aim is to look at the elliposids to make interpretations on there orientation and their distrubtion. Thank you for any help.
0 Comments
Answers (2)
Matt J
on 8 Nov 2023
You can plot an arbitrarily oriented ellipsoid using this FEX download
center=[1,2,3];
radii=[10,20,30];
yaw_pitch_roll=[45,45,30]
e=ellipsoidalFit.groundtruth([],center,radii,yaw_pitch_roll);
plot(e)
0 Comments
Nathan Hardenberg
on 7 Nov 2023
For extracting the data from the Excel Sheet you can use build in Matlab functions, like the readtable()-function. I won't go into detail with this in my answer.
The more challenging part is plotting the ellipsoids. I wrote some code that does what you want, if I understood correctly. All used Excel-colums are represented as a Matlab-vector. First the ellipsoids are calculated in x, y and z coordinates and plotted with the surf()-function. The resulting ellipsoid-object then gets rotated accordingly.
Note that in the code there is a sanity check, to test if the rotation worked correctly. The plotted like should be drawn out of the "top" of the ellipsoid (where all lines meet). In your second example this does not quit work right. A guess might be that due to rounding errors of the vector-data the resulting rotation matrix is not a "real" rotation matrix. The calculated rotation will always be a true rotation and therefore might be a bit different. If the values in you sheet are higher precision, this should not be a problem and the lines should be correct.
Hope this helps you with your task
% Data
X = [729; 622; 400];
Y = [155; 534; 300];
Z = [-3727; -3928; -4000];
ax1 = [61; 61; 90];
ax2 = [117; 92; 20];
ax3 = [128; 128; 20];
v1X = [-0.97; 0.87; 0];
v1Y = [-0.06; -0.44; 0];
v1Z = [0.25; -0.22; 1];
v2X = [0.08; -0.39; 1];
v2Y = [0.84; -0.89; 0];
v2Z = [0.54; 0.24; 0];
v3X = [-0.24; 0.30; 0];
v3Y = [0.54; 0.12; 1];
v3Z = [-0.80; 0.95; 0];
% configure figure for plotting
figure(1); clf; axis equal; grid on; hold on;
xlabel("x"); ylabel("y"); zlabel("z");
view(3);
% loop to itterate over each ellipsoid
for k = 1:length(X)
% calculate ellipsoid
[x,y,z] = ellipsoid(X(k), Y(k), Z(k), ax1(k), ax2(k), ax3(k));
s = surf(x,y,z,"FaceColor","flat"); % plot it
% ==> ROTATE ACCORDINGLY <==
% create rotation matrix from your given vectors
rotm = [
v1X(k), v2X(k), v3X(k);
v1Y(k), v2Y(k), v3Y(k);
v1Z(k), v2Z(k), v3Z(k);
];
quat = rotm2quat(rotm); % convert to quaternion
angle = rad2deg(2*acos(quat(1))); % get angle and
direction = quat(2:4); % axis
% rotate the ellipsoid
rotate(s, direction, angle, [X(k); Y(k); Z(k)]);
% sanity check (for testing purposes only)
V = [X(k); Y(k); Z(k)] + [v3X(k); v3Y(k); v3Z(k)]*150;
plot3([X(k); V(1)],[Y(k); V(2)],[Z(k); V(3)])
end
0 Comments
See Also
Categories
Find more on 3-D Scene Control 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!