MATLAB Answers

Translate rotate and scale STL surfaces

101 views (last 30 days)
Nataliya Perevoshchikova
Nataliya Perevoshchikova on 30 Jan 2019
Edited: Brice Kabore on 11 May 2020
I imported three STL files (3d) as patch data. I merged nodes. These objects can be plotted with faces and vertices. My next step is to rotate, translate and scale one surface to two surfaces based on vertices. Vizually, I know where should be insertion points of fitted surface to two surfaces.
What would be steps to perform these operations?
  1 Comment
Brice Kabore
Brice Kabore on 11 May 2020
For translation
[V, F]=stlread("isopoison.stl"); %although the new stlread version gives a different structure
P=(8,0,0)% translate in x by 8
V = V+ P
For scaling
V=V*scale% or V(:,1)=V(:,1)*scale
For rotatation you can use this function basically creating a rotation matrix that will be multiplied by V which contain your vertices indice is the axis, 1 for x axis 2 for y ...
function vertex = rotation(V, indice, angle)
% [V, F]=stlread("isopoison.stl");
% angle=-pi/2;
Rz = [ cos(angle), -sin(angle), 0 ;
sin(angle), cos(angle), 0 ;
0, 0, 1 ];
Ry = [ cos(angle), 0, sin(angle) ;
0, 1, 0 ;
-sin(angle), 0, cos(angle) ];
Rx = [ 1, 0, 0 ;
0, cos(angle), -sin(angle);
0, sin(angle), cos(angle) ];
vertex = V*Rx;
vertex = V*Ry;
vertex = V*Rz;

Sign in to comment.

Answers (1)

KSSV on 30 Jan 2019
You need to know about geometric here

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!