-
Notifications
You must be signed in to change notification settings - Fork 4
/
Deform2DConformal.m
66 lines (49 loc) · 1.55 KB
/
Deform2DConformal.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Smoothed Quadratic Energies on Meshes
%% J. Martinez Esturo, C. Rössl, and H. Theisel
%%
%% ACM Transactions on Graphics 2014
%%
%% Copyright J. Martinez Esturo 2014 (MIT License)
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
classdef Deform2DConformal < Deform2D
%DEFOR2DMCONFORMAL
properties
se = []
constrSolver = []
end
methods
function obj = Deform2DConformal(mesh, beta)
%% Constructor
obj = obj@Deform2D(mesh, beta);
obj.name = 'ASAP';
end
function init(obj, hidxs)
mesh = obj.mesh;
%% Setup material behaviour term
% conformal <=> as-similar-as-possible
Mwq = eye(4) - 0.5 .* [1, 0, 0,1;
0, 1,-1,0;
0,-1, 1,0;
1, 0, 0,1];
Mq = blockfill(4,4,mesh.nt,repmat(Mwq,1,mesh.nt));
%% Setup integrated / smoothed system
E = Mq*mesh.GGP;
en = size(E,1) / mesh.nt;
obj.se = obj.smootherf(mesh,obj.beta, en, 2,1);
obj.se.updateLHS(E);
%% Setup solver
% constrained handle indices
obj.hidxs = hidxs;
cidxs = reshape([(hidxs-1)*2+1; (hidxs-1)*2+2],1,[]);
obj.constrSolver = obj.csolverf(obj.se.AAs,cidxs,obj.se.bbs);
end
function [converged,u] = deform(obj, hcoords, ~)
converged = true; u = [];
if(isempty(obj.hidxs)), return; end
mesh = obj.mesh;
u = obj.constrSolver.solve(reshape(hcoords,[],1));
mesh.p = reshape(u,2,[]);
end
end
end