geometric transformation of nodal points between two picewise linear curves

2 views (last 30 days)
Dear Matlab spezialists,
I need your help regarding the follwing problem:
I have a 2D mesh (finite elements, but does not matter) enclosed in two picewise linear curves (bold lines). That corresponds to the upper part of the picture.
I need to perform a geometrical transformation of the nodes of the mesh towards the shape of two different picewise linear curves (lower part of the picture).
The "new curves" may have the same number of segments if necessary for the solution. I can also also modify input curves and target curves, so that the segments are equally spaced.
My first idea was to perform that tranformation picewise in a loop over the segments of the input curves, but I don't know how to do it.
Hint: bending the mesh with a finite element simulation is not the solution as it would change certain characteristics of the mesh.
Can anybody assist?
Thanks in advance!!
mesh_transformation.png

Accepted Answer

chacoon
chacoon on 11 Feb 2019
Problem solved:
figure, plot(curve_input_top(:,1),curve_input_top(:,2),'*-b')
hold on
axis tight
plot(curve_input_bottom(:,1),curve_input_bottom(:,2),'*-b')
plot(curve_target_top(:,1),curve_target_top(:,2),'*-r')
plot(curve_target_bottom(:,1),curve_target_bottom(:,2),'*-r')
plot(nodes(:,1),nodes(:,2),'.c')
% do the transformation
new_nodes = [];
for i=1:length(curve_input_top)-1
% tform = fitgeotrans(movingPoints,fixedPoints,'polynomial',degree)
tform = fitgeotrans([curve_input_top(i:i+1,:);curve_input_bottom(i:i+1,:)],[curve_target_top(i:i+1,:);curve_target_bottom(i:i+1,:)],'affine');
%
segment_boundary_points = [ [curve_input_top(i:i+1,1) curve_input_top(i:i+1,2)+0.1]; [curve_input_bottom(i:i+1,1) curve_input_bottom(i:i+1,2)-0.1] ];
% create convex hull to get the order of the boundaries correctly
K = convhull(segment_boundary_points(:,1),segment_boundary_points(:,2));
% now find the nodes within the current segment
[in on] = inpolygon(nodes(:,1),nodes(:,2),segment_boundary_points(K,1),segment_boundary_points(K,2));
nodes2transform = nodes([in | on],:);
% do the picewise transformation
temp_new_nodes = [nodes2transform ones(size(nodes2transform,1),1)]*tform.T;
% update new nodeset
new_nodes = [new_nodes; temp_new_nodes(:,1:2)];
% plot the new nodes
plot(temp_new_nodes(:,1),temp_new_nodes(:,2),'+')
end
not yet nice, but does the trick!

More Answers (1)

chacoon
chacoon on 11 Feb 2019
I created a sample data set, which is attached and shown below:
blue = curve_input_top & curve_input_bottom
red = curve_target_top & curve_target_bottom
cyan = nodes (to be transformed)
example.png

Community Treasure Hunt

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

Start Hunting!