How to put a deformation onto a 3d stl object?

18 Ansichten (letzte 30 Tage)
Neville
Neville am 11 Aug. 2017
Verschoben: DGM am 7 Mai 2023
So I have a 3d stl object that I've put into a matlab file by using a function called stlread.m (I found it on mathworks).
Anyways, I need to model a deformation on the stl object based upon the data I have from a 16x16 tactile sensor. I've been trying to use mogi.m to model the deformation onto my stl file, but it's not quite looking the way I want to.
My question is, does anyone know how to create deformations on 3D stl objects in matlab (I guess manipulate them in a way) or how to create specific deformations onto the body using data that I've acquired?
This is what i have thus far:
%S2M2
%
%
clear
clc
filename = '/home/kelm/uegabe/Alle/Muringayi/Tactile Sensor Robot Measurements/S2M2/Tiefe-47.txt';
m = importdata(filename);
m(:,1) = [];
m(mean(m, 2) < 50, :) = []; %delete all rows whose mean is less than 50
m(14:end,:) = [];
% Finds which row has the maximum sum value and stores the index into a
% variable called Final_indi
var = 0;
for i =1:size(m,1)
maxLine = max(sum(m(i,:)));
if maxLine > var
var = maxLine;
Final_indi = i;
end
end
%Puts the maxLine into a 16x16 matrix
row = 1;
column = 1;
m_ = m(Final_indi,:);
for i = 1:length(m_)
matrix(row,column) = m_(i);
column = column + 1;
if column == 17
if row < 16
row = row +1;
end
column = 1;
end
end
fv = stlread('cover_material_10.stl');
patch(fv,'FaceColor', [.8 .8 1.0], ...
'EdgeColor', 'none', ...
'FaceLighting', 'gouraud', ...
'AmbientStrength', 0.15);
%Add a camera light, and tone down the specular highlighting
camlight('headlight');
material('dull');
%Fix the axes scaling, and sets a nice view angle
axis('image');
view([60 90 27]);
[X, Y] = meshgrid(-8 : 1 : 8 );
[th,rho] = cart2pol(X,Y);
[ur, uz] = mogi (rho, 1, 0.1, 1e5, 10e9, 0.25);
[Ux, uy] = pol2cart (th, ur);
ps = 1e8;
surf(X+Ux*ps,Y+uy*ps,uz*ps)
  2 Kommentare
Mehran Kiani
Mehran Kiani am 27 Feb. 2021
Verschoben: DGM am 7 Mai 2023
Did you find any solution for it? Appriciate if you can share it
Simson Hutagalung
Simson Hutagalung am 24 Jun. 2022
How to generate deformation colormap 2D in matlab with data from excel?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Daniel Norling
Daniel Norling am 7 Mai 2023
Bearbeitet: Daniel Norling am 7 Mai 2023
Hello You can deform stl objects by: read the triangulation object from the stl file, using stlread. The triangulation object contains a connectivity matrix T and the x, y and z coordinates. The x, y and z coordinates defines the nodes. The connectivity matrix contains the indexes of the node triplets forming the triangles, but not the coordinate values. Leave the T matrix as it is. To make deformations on the the object we can move the nodes, which means alter the coordinates of the nodes, but keeping the node indexes unaltered. Let's say we want to move all nodes with x coordinate > 5 in some way. i = find(x>5); xnew = x; ynew = y; znew = z; xnew(i) = x(i) + 2; ynew(i) = y(i) - 1; znew(i) = z(i) + 3;
Now save the new object using stlwrite and T, xnew, ynew, znew. A crude example. Moving the nodes according to some smooth function f(x, y, z) might be closer to what you want but the same principle applies. You can also scale and rotate objects by moving nodes, without any change to the connectivity T. If the nodes move too differently compared to how the neighboring nodes move, the triangles might intersect or the surface might intersect itself. The triangulation and the stl format has no problem with this but you might have. Or your slicer software for 3Dprinting might have. Use trisurf(T, xnew, ynew, znew) to see the result of your node movements. Using axis vis3d might help
Good luck

Community Treasure Hunt

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

Start Hunting!

Translated by