-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFixedBoundaryConditions.m
40 lines (34 loc) · 1.06 KB
/
FixedBoundaryConditions.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
classdef FixedBoundaryConditions <BoundaryConditions
% Object representing fixed point-constraint (i.e., "classic" Tutte)
% boundary conditions.
properties
poses;
inds;
end
methods
function obj=FixedBoundaryConditions(inds,poses)
if size(inds,1)==1
inds=inds';
end
obj.inds=inds;
if size(poses,2)~=3
poses=poses';
end
obj.poses=poses;
end
function [A,b]=constraints(obj,NV)
temp=(1:length(obj.inds))';
I=[temp temp+length(obj.inds) temp+2*length(obj.inds)];
J=[obj.inds*3-2 obj.inds*3-1 obj.inds*3];
V=ones(size(I));
I=I(:);
J=J(:);
V=V(:);
A=sparse(I,J,V,max(I),NV*3);
b=obj.poses(:);
end
function good=validSolution(obj,V)
good=max(max(abs(V(obj.inds,:)-obj.poses)));
end
end
end