How to get xyz coordinates from 3d surface?

11 visualizaciones (últimos 30 días)
youb mr
youb mr el 26 de Oct. de 2020
Respondida: Hitesh el 29 de Ag. de 2024
hello every one i'm working now in texture mapping so i want to get x,y,z coordinates of a 3d object of all faces of this object but i just now to get this coordinates just for one face how i can get all coordinate of all faces this is my code
nx = 120; % the size of the grid
ny = 120; % the size of the grid
x = linspace(min(v(:,1)),max(v(:,1)),nx);
y = linspace(min(v(:,2)),max(v(:,2)),ny);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Number of x values in uniform grid
[X, Y] = meshgrid(x, y); % Create meshes for xu and yu
Z = gridtrimesh(f,v,X,Y);
where V and f are the faces and vertex
how i can get all coordinate of all faces this is my code my 3d object have 5 faces ?

Respuestas (1)

Hitesh
Hitesh el 29 de Ag. de 2024
Hi Youb,
From my understanding, the "gridtrimesh(f,v,X,Y)" fits a surface of the form Z=F(X,Y) to the triangular mesh defined by faces and vertices of the 3D Object. Unfortunately, it might not offer the coordinates for faces of a 3D object.
For finding the coordinates of all faces of 3D object, you can simply iterate over each face and get the corresponding vertex coordinates. Please refer to below code for getting all face coordinates of 3D object.
for i = 1:size(F, 1)
faceVertices = F(i, :); % Get the vertex indices for the current face
faceCoordinates = V(faceVertices, :); % Get the coordinates for these vertices
fprintf('Face %d coordinates:\n', i);
disp(faceCoordinates);
end

Categorías

Más información sobre Surface and Mesh Plots 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!

Translated by