I have a point cloud data in x,y,z co-ordinates. I want to generate surface with rectangular mesh of defined mesh size (i.e. length and breadth specified).
43 views (last 30 days)
Show older comments
I have a point cloud data in x,y,z co-ordinates. I want to generate surface with rectangular mesh element of defined mesh size (i.e. length and breadth specified). Its not necessary to use available points as vertices. I just need rectangular grid and coordinates of its vertices.
Can anyone help me with this.?
Thanks.
0 Comments
Answers (1)
Ameer Hamza
on 20 Apr 2020
You can use the griddata() to convert the linear vectors x, y, and z into a grid. Try this example
X = rand(100,3); % random points
x = X(:,1); % seperate them into x, y, and z variables
y = X(:,2);
z = X(:,3);
xg = linspace(min(x), max(x), 100); % coordinates of grid
yg = linspace(min(x), max(x), 100); % coordinates of grid
[Xg, Yg] = meshgrid(xg, yg); % X and Y grids
Zg = griddata(x, y, z, Xg, Yg);
surf(Xg, Yg, Zg);
griddata() can output NaN at the edge of the grid because actual data is unavailable there. If you want to interpolate to the edges(), then you can try: https://www.mathworks.com/help/matlab/ref/scatteredinterpolant.html
4 Comments
Ameer Hamza
on 21 Apr 2020
Following will create a 3D grid fitting the point cloud
X = rand(100,3); % random points
x = X(:,1); % seperate them into x, y, and z variables
y = X(:,2);
z = X(:,3);
xg = linspace(min(x), max(x), 100); % coordinates of grid
yg = linspace(min(y), max(y), 100);
zg = linspace(min(z), max(z), 100);
[Xg, Yg, Zg] = meshgrid(xg, yg, zg); % X and Y grids
Xg, Yg, and Zg are 3D arrays. If you want to get the coordinates of grid in a linear form, then run this
coordinate_grid = [Xg(:) Yg(:) Zg(:)];
I am not sure about the 4-th column about point id. Can you explain it further?
See Also
Categories
Find more on Point Cloud Processing 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!