function F = calculate_F_vertex(these_plane_angles,these_fold_angles) %#codegen assert(isa(these_plane_angles, 'double')); assert(isa(these_fold_angles, 'double')); assert (all(size(these_plane_angles)<=[1 100])); assert (all(size(these_fold_angles)<=[100 1])); % Compute F at a possibly open vertex using plane angles and fold angles valence = length(these_fold_angles); % go through and construct edges,normals and matrices ej = [1 0 0];% First edge lies along x axis, second edge lies in x y plane njp1 = [0 0 1]; %normal_2 = e1 x e2 lies along z axis Bj = axis_angle(ej,these_fold_angles(1)); Cjp1 = axis_angle(njp1,these_plane_angles(1)); ej = (Cjp1*ej')'; F = Cjp1*Bj; for j = 2:valence % runs over edges Bj = axis_angle(ej,these_fold_angles(j)); % rotate about next edge with fold angle njp1 = (Bj*njp1')'; Cjp1 = axis_angle(njp1,these_plane_angles(j)); ej = (Cjp1*ej')'; F=Cjp1*Bj*F; end end function R = axis_angle(n, theta) % let's try this faster code from vrrotvec2mat.m s = sin(theta); c = cos(theta); t = 1 - c; x = n(1); y = n(2); z = n(3); R = [ ... t*x*x + c, t*x*y - s*z, t*x*z + s*y; ... t*x*y + s*z, t*y*y + c, t*y*z - s*x; ... t*x*z - s*y, t*y*z + s*x, t*z*z + c ... ]; end