Borrar filtros
Borrar filtros

Getting xyz coordinates for a specific point on stl cad model

60 visualizaciones (últimos 30 días)
Ahmed Tawfik
Ahmed Tawfik el 14 de Dic. de 2022
Respondida: Nithin Kumar el 4 de Sept. de 2023
In my project i need to create a path for welding robot. First step is by selecting the welding space by selecting a set of xyz points. i have tried the buttondownfcn, but it represent the point on a plane not on the 3d object. i need to be able to select points from the stl model on th object itself to create the path or to highlight it.also, i have tried alot iof functions but i don't know how to do it.
if anyone could help me i would be grateful.
thanks.
  2 comentarios
Rik
Rik el 14 de Dic. de 2022
Each face is defined by vertices, which each are defined by xyz coordinates. So finding the coordinates of a corner is as simple as an indexing operation. What exactly did you try to solve this part of the problem?
Askic V
Askic V el 18 de En. de 2023
If you have stl model in ascii and if you open that file in txt editor, you can see something like this:
facet normal 0.000000e+00 0.000000e+00 1.000000e+00
outer loop
vertex -5.000000e+01 -5.000000e+01 6.000000e+02
vertex 5.000000e+01 -5.000000e+01 6.000000e+02
vertex -5.000000e+01 5.000000e+01 6.000000e+02
endloop
endfacet
facet normal -0.000000e+00 0.000000e+00 1.000000e+00
outer loop
vertex -5.000000e+01 5.000000e+01 6.000000e+02
vertex 5.000000e+01 -5.000000e+01 6.000000e+02
vertex 5.000000e+01 5.000000e+01 6.000000e+02
endloop
endfacet
Just as Rik said, verices are defined by xyz coordinates. So, there are only a finite number of points and its coordinates that are saved in the stl file. I guess what you're trying to do is to click anywhere on the object and get its 3D coordinates, but standard Matlab functionality can return only coordinates that are already saved and necessary to create stl object.
You can look at this, but I'm not sure if that will help you:
Good luck.

Iniciar sesión para comentar.

Respuestas (1)

Nithin Kumar
Nithin Kumar el 4 de Sept. de 2023
Hi Ahmed,
I understand that you want to know the process of generating XYZ coordinates for a specific point on an STL CAD model in MATLAB. To get XYZ coordinates, kindly refer to the following steps:
1. Load the STL file: Use the "stlread" function in MATLAB to import the STL file into your workspace. This function reads the vertices and faces of the 3D model.
[vertices, faces] = stlread('your_model.stl');
2. Identify the specific point: Determine the coordinates of the point you are interested in, either by its index in the vertices array or by specifying its XYZ coordinates.
3. Access the coordinates: Once you know the index or coordinates of the point, you can access its XYZ coordinates from the `vertices` array.
In case you have the index of the point, kindly refer to the following code snippet -
pointIndex = 42; % Replace with the actual index of your point
xyzCoordinates = vertices(pointIndex, :);
In case you have the XYZ coordinates of the point which you want to find, kindly refer to the following code snippet -
desiredCoordinates = [x, y, z]; % Replace with the actual coordinates
% Find the closest point in the vertices array
distances = sqrt(sum((vertices - desiredCoordinates).^2, 2));
[minDistance, pointIndex] = min(distances);
xyzCoordinates = vertices(pointIndex, :);
Now, the "xyzCoordinates" variable will contain the XYZ coordinates of the specific point on the STL CAD model.
For more information regarding "stlread" function, kindly refer to the following documentation:
I hope this provides you with the required information regarding your query.
Regards,
Nithin Kumar.

Community Treasure Hunt

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

Start Hunting!

Translated by