1 function new_paths = interp_paths(ps,p_param)
2 %function adds new points along paths
6 %save easy named variables from struct
8 pts(:,3) = ps.points(:,3);
12 %number of new points on segment
17 new_grid_pts = ps.grid_pts;
18 new_points = ps.points;
19 new_points2 = ps.points;
27 if pl >= min_path_points
28 %fprintf('\n Making new points, path %d\n',i)
35 %two points in space, p and q
36 p_i = idx(p(j-1),1);%+rm*round(randn);
37 p_j = idx(p(j-1),2);%+rm*round(randn);
38 q_i = idx(p(j),1);%+rm*round(randn);
39 q_j = idx(p(j),2);%+rm*round(randn);
40 %distance between points in path
41 dist = ps.raw_dist(p(j-1),p(j));
44 np = round(dist/pt_dist)+1;
45 %fprintf('Segment %d distance: %f new points: %d \n',j-1,dist,np);
46 %linear interpolation of new points along the line
47 new_lats = linspace(pts(p(j-1),1),pts(p(j),1),np)' ...
49 new_lons = linspace(pts(p(j-1),2),pts(p(j),2),np)' ...
51 new_time = linspace(pts(p(j-1),3),pts(p(j),3),np)';
52 %average confidence of each endpoint on segment
53 new_conf = mean(ps.points(j-1,4),ps.points(j,4))*ones(np,1);
54 new_frps = linspace(ps.points(j-1,4),ps.points(j,4),np)';
55 new_gran = ps.points(j-1,6)*ones(np,1);
56 news = [news;[new_lats,new_lons,new_time]];
57 %new_grids = [new_grids ;fixpoints2grid(ps.red,[new_lats,new_lons])];
58 %figure(33),hold on,scatter3(new_points(:,3),new_points(:,4),new_time)
60 new_points=[new_points;[new_lats(2:end-1),new_lons(2:end-1), ...
61 new_time(2:end-1),new_conf(2:end-1),new_frps(2:end-1),new_gran(2:end-1)]];
62 %new_grid_pts = [new_grid_pts; [new_grids(2:end-1,3),new_grids(2:end-1,4)]];
63 %new_idx = [new_idx; [new_grids(2:end-1,1),new_grids(2:end-1,2)]];
64 %adding row position of new path points in case its needed
66 idx_end = length(new_points);
67 idx_start = idx_end-np+3;
68 %new_p = [new_p(1:j-1) idx_start:idx_end new_p(j:end)];
69 new_p = [new_p(1:find(new_p==p(j-1))) idx_start:idx_end new_p(find(new_p==p(j)):end)];
74 %interpolate the whole path with spline
75 new_paths.paths(i).p = new_p;
77 pplat = csaps(ps.points(p,3),ps.points(p,1),p_param,new_points(new_p,3));
78 pplon = csaps(ps.points(p,3),ps.points(p,2),p_param,new_points(new_p,3));
79 new_points(new_p,1)=pplat;
80 new_points(new_p,2)=pplon;
83 new_grids = fixpoints2grid(ps.red,[new_points(:,1),new_points(:,2)]);
84 new_paths.grid_pts = [new_grids(:,3),new_grids(:,4)];
85 new_paths.idx = [new_grids(:,1),new_grids(:,2)];
86 new_paths.points = new_points;