How can I create a 2D array of 3D points
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
The purpose is to render 2D image of gestner waves
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/337258/image.png)
So I think these equations add Offset not only in vertical direction, but also squeeze points horizontally to make crests choppy
I know that meshgrid can create a group of evenly distributed grid points and we can assign a vertical values to each of the (x,y) discrete locations.
But this is far from drawing gestner waves.
I need to create a 2D array of points. Each element of the array is a point (or a point's 3D-location), and then I can offset each of these points and then visualize the surface.
If I write this code: points will be a 16384*3 array. Just storing 3d points in a row vector for 16384 times. I cannot access them via x,y,z index. How can I do that?
vector_of_x = 1:128;
vector_of_y = 1:128;
[X, Y] = meshgrid(vector_of_x, vector_of_y);
Z=zeros(128,128);
surf(X,Y);
points = [X(:), Y(:), Z(:)];
ptCloud = pointCloud(points);%%case
0 comentarios
Respuestas (1)
Jeremy Perez
el 28 de Ag. de 2020
Hi,
Read this:
What you want is creating a pxyt array with 3 pages.
Each page contains the values at each step t.
The code you know:
n = 128;
vector_of_x = 1:n;
vector_of_y = 1:n;
[X, Y] = meshgrid(vector_of_x, vector_of_y);
Z=zeros(n,n);
Your surface at t0:
pxyt = zeros(n,n);
pxyt(:, :, 1) = X(:, :);
pxyt(:, :, 2) = Y(:, :);
pxyt(:, :, 3) = Z(:, :);
Your surface at t:
% pxyt = myfunctionP(pxyt)
pxyt(:, :, 3) = rand(n,n);
X = pxyt(:, :, 1);
Y = pxyt(:, :, 2);
Z = pxyt(:, :, 3);
%figure()
%surf(X,Y,Z);
Your point at t:
p = [0;0;0];
kx = 1; % index x
ky = 1; % index y
p(:) = pxyt(kx, ky, :);
Hope it helps,
0 comentarios
Ver también
Categorías
Más información sobre Lighting, Transparency, and Shading 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!