function [L,B,C] = xyz2lbc(Xc,Yc,Zc,R)if( (length(Xc) ~= length(Yc)) | (length(Xc) ~= length(Zc)) ) error('size');endif(nargin == 3) R = zeros(1,length(Xc)-2); elseif(length(R) == 1) R = ones(1,length(Xc)-2).*R; elseif(length(R) ~= length(Xc)-2) error('R not match'); endfor i = 1:length(Xc)-2 V1 = [Xc(i)-Xc(i+1) ; Yc(i)-Yc(i+1) ; Zc(i)-Zc(i+1)]; V2 = [Xc(i+2)-Xc(i+1) ; Yc(i+2)-Yc(i+1) ; Zc(i+2)-Zc(i+1)]; V1l = Vlength(V1); V2l = Vlength(V2); C(i) = pi - acos(dot(V1,V2) / (V1l*V2l)); planeV(i,:) = cross(V1,V2)'; if(i>1) Y(i) = Y(i) - R(i)*tan(C(i)/2); Y(i+1) = V2l - R(i)*tan(C(i)/2); PV1l = Vlength(planeV(i-1,:)); PV2l = Vlength(planeV(i,:)); s=sign(V1 .* cross(planeV(i-1,:),planeV(i,:))'); B(i) = acos(dot(planeV(i-1,:),planeV(i,:))/(PV1l*PV2l))*s(1); else Y(i) = V1l - R(i)*tan(C(i)/2); Y(i+1) = V2l - R(i)*tan(C(i)/2); B(i) = 0; end end
MATLAB: How can i get this function to work with this spreadsheet
functionspreadsheet
Best Answer