function H = bp_hinges(tri) % BP_HINGES Hinges across the interior edges of a triangle mesh. % H = bp_hinges(tri) returns rows [i j k l] for sys.hinges (append a % stiffness column kh): j-k is an edge shared by two triangles, and i and % l are the third beads of those triangles. A hinge resists changes of the % angle between its two triangles from their angle at the rest positions, % so any rest shape (flat, domed, bell-shaped) is free of stress. t = tri; % each triangle edge, sorted, with the opposite bead E3 = [sort(t(:, [1 2]), 2), t(:, 3); sort(t(:, [2 3]), 2), t(:, 1); sort(t(:, [3 1]), 2), t(:, 2)]; [~, ord] = sortrows(E3(:, 1:2)); E3 = E3(ord, :); pair = find(all(E3(1:end-1, 1:2) == E3(2:end, 1:2), 2)); H = [E3(pair, 3), E3(pair, 1), E3(pair, 2), E3(pair + 1, 3)]; end