matlab生成点云

祥瑞哈哈哈 / 2023-04-28 / 原文

clc;clear all;close all;
N = 1000; % # Number of points
V = [-10, 0; 0, 10; 10, 0]; % # Triangle vertices, pairs of (x, y)
t = sqrt(rand(N, 1));
s = rand(N, 1);
P = (1 - t) * V(1, :) + bsxfun(@times, ((1 - s) * V(2, :) + s * V(3, :)), t);

u = mean(P,1); %equivalent to u = Ud' * r_m
w1=repmat( sum( P .* repmat(u,[N 1]) ) ,[N 1])
scatter(P(:, 1), P(:, 2), '.')
P = P./ repmat( sum( P .* repmat(u,[N 1]) ) ,[N 1]);%d是终端数,x./的话应该是缩放。

scatter(P(:, 1), P(:, 2), '.')