sb = [[495,901,137];
      [448, 407, 136]]
top =[[531 ,396, 141];
      [506, 396, 187];
      [458, 396, 212];
      [400, 396, 203];
      [368, 396, 165];
      [371, 396, 109];
      [408, 396, 64];
      [463, 375, 62];
      [513, 381, 88]]


syms x
syms y
syms z
pb = sb(2,:)
pt = sb(1,:)
ps = top(1,:)
%r = 93.1
%r2 = 93.1
h = sqrt((pt(1)-pb(1))^2 + (pt(2) - pb(2))^2 + (pt(3) - pb(3))^2)
dis = 96
count = floor(h/dis)
%angle = 40
pall = []
v1 = ps - pt
v2 = pt - pb

ratio = dis/h
vector = []
for i = 1:9

%eqn1 = sum(v1.*[x,y,z]) == r^2*cosd(angle)
%eqn2 = sum(v2.*[x,y,z]) == 0
%eqn3 = (x)^2 + y^2 + z^2 == r^2
%eqn4 = sum(v2.*cross(v1,[x,y,z])) > 0
%[a,b,c]= solve(eqn1,eqn2,eqn3,eqn4)
%v1 = [vpa(a,7),vpa(b,7),vpa(c,7)]
vector = [vector;top(i,:)-pt]
end

mark = pt
for i = 1:count
pp = pt - ratio*i*v2
mark = [mark;pp]
end
summary = []
for i = 1:9
pp = mark + vector(i,:)
summary = [summary;pp]
end

vpa(summary,7)

object = 1
contour = 1
fileID = fopen('exp.txt','w');
for i = 1: length(summary)
fprintf(fileID,'%d %d %3.2f %3.2f %3.2f\n',object,contour,summary(i,1),summary(i,2),summary(i,3));
end
fclose(fileID);
