MCPcopy Create free account
hub / github.com/Meshcapade/difflocks / pad_strand

Function pad_strand

utils/strand_util.py:164–186  ·  view source on GitHub ↗
(strand, num_strand_points=100)

Source from the content-addressed store, hash-verified

162
163
164def pad_strand(strand, num_strand_points=100):
165 num_ori_points = strand.shape[0]
166 if num_ori_points > num_strand_points:
167 return strand[:num_strand_points]
168
169 num_pad = num_strand_points - num_ori_points
170 last_delta = strand[-1] - strand[-2]
171 offsets = np.arange(num_pad) + 1
172 offsets = offsets[:, None]
173 last_delta = last_delta[None, :]
174 offsets = offsets * last_delta
175 # padded_strand = np.zeros_like(offsets) + strand[-1]
176 padded_strand = offsets + strand[-1]
177 padded_strand = np.concatenate((strand, padded_strand), axis=0)
178
179 ori_time = np.linspace(0, 1, num_ori_points)
180 strd_len, delta_len = get_strand_length(strand) # modify time by length
181 ori_time[1:] = delta_len / strd_len
182 ori_time = np.add.accumulate(ori_time)
183
184 padded_time = 1. + (np.arange(num_pad) + 1) * (1. / num_ori_points)
185 padded_time = np.concatenate((ori_time, padded_time), axis=0)
186 return padded_strand, padded_time
187
188
189def natural_cubic_spline_coeffs(t, x):

Callers

nothing calls this directly

Calls 1

get_strand_lengthFunction · 0.85

Tested by

no test coverage detected