Filter löschen
Filter löschen

Extracting profiles from a point cloud surface along the mazimum dip of the plane

25 Ansichten (letzte 30 Tage)
Elisa
Elisa am 19 Jul. 2024 um 9:40
Kommentiert: Umar vor etwa 10 Stunden
Dear all,
Based on the result of this code (blue cloud rotated), I need to extract a series of profiles (with a fixed diastance) to get the Z values of all the points constituting the profile. These profiles should be extracted from vertical planes oriented according to the maximum slope of the cloud.
Thanks in advance!!
you have other ideas, they are accepted!! I have included a sketch of what I would like.
clear all
close all
clc
load('XYZ');
X = XYZ(:,1);
Y = XYZ(:,2);
Z = XYZ(:,3);
xyz0=mean(XYZ,1);
A=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
[~,~,V]=svd(A,0);
a=cross(V(:,3),[0;0;1]);
T=makehgtform('axisrotate', a, -atan2(norm(a),V(3,3)));
R=T(1:3,1:3);
A_rot = A*R;
A_rot = A_rot + [xyz0(1) xyz0(2) 0]; % move so the centers are aligned in z-diection
% Plot the raw data
close all
scatter3(X,Y,Z,0.1,"magenta")
hold on
scatter3(A_rot(:,1),A_rot(:,2),A_rot(:,3),0.1,'blue');
xlabel('X-Axis','FontSize',14,'FontWeight','bold')
ylabel('Y-Axis','FontSize',14,'FontWeight','bold')
zlabel('Z-Axis','FontSize',14,'FontWeight','bold')
axis equal
  3 Kommentare
Elisa
Elisa vor etwa 13 Stunden
dear @Umar thank you so much!! i get an error: "At least one END is missing. The statement beginning here does not have a matching end. "
Umar
Umar vor etwa 10 Stunden

Hi Elisa,

I have updated the code, please execute the code and let me know if this is what you are looking for.

load('XYZ');

X = XYZ(:,1);

Y = XYZ(:,2);

Z = XYZ(:,3);

xyz0=mean(XYZ,1);

A=XYZ-xyz0; % center the data at zero

% Find the direction of most variance using SVD and rotate the data

[~, ~, V] = svd(A, 0);

a = cross(V(:,3), [0;0;1]);

T = makehgtform('axisrotate', a, -atan2(norm(a), V(3,3)));

R = T(1:3, 1:3);

A_rot = A * R;

A_rot = A_rot + [xyz0(1) xyz0(2) 0];

% Determine the slope of the cloud and extract profiles

slope = max(abs(diff(A_rot(:,3))));

fixed_distance = 0.1; % Set the fixed distance for profile extraction

% Extract profiles based on the slope

for i = 1:size(A_rot, 1) if abs(diff(A_rot(i,3))) == slope profile_points = A_rot(i, :);

        % Extract points at fixed distance along the slope
        for j = 1:fixed_distance:slope
            % Calculate the points along the profile
            profile_points = [profile_points; A_rot(i, 1:2) A_rot(i, 3) + j];
        end
        % Process the profile_points data as needed
        disp(profile_points);
    end
end

% Plot the raw data and extracted profiles

close all

scatter3(X, Y, Z, 0.1, "magenta") hold on scatter3(A_rot(:,1), A_rot(:,2), A_rot(:,3), 0.1, 'blue'); xlabel('X-Axis', 'FontSize', 14, 'FontWeight', 'bold') ylabel('Y-Axis', 'FontSize', 14, 'FontWeight', 'bold') zlabel('Z-Axis', 'FontSize', 14, 'FontWeight', 'bold') axis equal

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by