필터 지우기
필터 지우기

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

조회 수: 25 (최근 30일)
Elisa
Elisa 2024년 7월 19일 9:40
댓글: Umar 대략 10시간 전
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
Elisa
Elisa 대략 13시간 전
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 대략 10시간 전

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

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Point Cloud Processing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by