function trilist=addtriangle(trilist,pointlist,v1,v2,v3) % function trilist=addtriangle(trilist,pointlist,v1,v2,v3) % % Triangle defined by pionts pointlist(:,v1),pointlist(:,v2),pointlist(:,v3) % is checked for aspect and, if ok, added to list trilist. % trilist is an 3xN matrix d1=getdistsq(pointlist(:,v1),pointlist(:,v2)); d2=getdistsq(pointlist(:,v2),pointlist(:,v3)); d3=getdistsq(pointlist(:,v3),pointlist(:,v1)); % tweak this value to determine the maximum aspect ration of a triangle % to add - squared because we're using distance-squared t = 8^2; if (d1>t*d2) | (d1>t*d3) | (d2>t*d1) | (d2>t*d3) | (d3>t*d1) | (d3>t*d2), return; end newtri = [ v1 ; v2 ; v3 ]; trilist = [trilist newtri];