How Do I Move a Set of (x,y,z) Points so they Align with the X-Y Plane?

4 visualizaciones (últimos 30 días)
Bryan Sinkovec
Bryan Sinkovec el 15 de Dic. de 2015
Editada: Geoff Hayes el 17 de Dic. de 2015
Hi all,
I have a large set of (x,y,z) data points creating a “bumpy” (non-flat) surface that I am trying to get to “flatten out” onto the x-y plane without losing any integrity of the surface features.
I tried following the suggestion here http://www.mathworks.com/matlabcentral/answers/66051-how-do-i-move-a-cloud-of-points-in-3d-so-that-they-are-centered-along-the-x-axis, but the asker was specific to ask for their data to follow along the x axis. I am trying to get my data to fall along the x-y plane in whatever angle it originates at. It does not necessarily need to be centered at zero or anything (in my example it is, but I would not like it to), just flattened to the x-y plane using only the given (x,y,z) data.
With the help of the above suggestion, I’ve tried this code:
XYZ = [11 11 11
12 12 13
13 13 12
14 14 15
15 15 17
16 16 17
17 17 18
18 18 18
19 19 20
10 12 12
11 13 11
12 14 13
13 15 14
14 16 19
15 17 13
16 18 15
17 19 18
18 20 17
12 10 11
13 11 13
14 12 14
15 13 12
16 14 17
17 15 19
18 16 18
19 17 15
20 18 19];
X = XYZ(:,1);
Y = XYZ(:,2);
Z = XYZ(:,3);
% Plot the raw data
scatter3(X,Y,Z,'b','LineWidth',5) % blue dots
xlabel('X-Axis','FontSize',14,'FontWeight','bold')
ylabel('Y-Axis','FontSize',14,'FontWeight','bold')
zlabel('Z-Axis','FontSize',14,'FontWeight','bold')
xyz0=mean(XYZ);
A=bsxfun(@minus,XYZ,xyz0); % center the data at zero
% Find the direction of most variance using SVD and rotate the data to make
% that the x-axis
[U,S,V]=svd(A,0);
A_rot = A*V; % V(:,1) is the direction of most variance
hold on
scatter3(A_rot(:,1),A_rot(:,2),A_rot(:,3),'g','LineWidth',5); % green dots
This code centers the data at (0,0,0), flattens it out, and rotates it in the direction of most variance (close to the x-axis) while making use of the svd function. I’m looking to see if I can keep the plot in the same position at its same x-y position, but flatten it down from its z position. I don’t believe I can simply adjust the data by a specific angle, because other surfaces may not be at a nice easy angle and I will not always know what the angle is. It simply needs to be moved down with the same surface features into the x-y plane.
If anybody can help me out on this, it would be very much appreciated, and thank you in advance.

Respuestas (0)

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by