def extend(self, start, length): if length == 0: return start direction = sign(length) length = abs(length) next_value = start - start % 1 + (direction > 0) difference = norm(self[start] - self[next_value]) length -= difference # while length > 0: if (next_value > len(self) and direction > 0) or (next_value < 0 and direction < 0): break start = next_value next_value += direction difference = norm(self[next_value] - self[start]) length -= difference # Length is smaller than zero length = length return next_value + direction * length * abs(next_value - start) / difference
def get_positions(self, start=0, stop=None, step=None): stop = stop if stop is not None else len(self) - 1 start = start if start is not None else 0 if step is not None and step < 0: start, stop = stop, start if start == stop: return [start] step = sign(stop - start) if step > 0: start_round = max(int(start) + 1, 0) stop_round = min( int(stop) + (1 if stop % 1 > 0 else 0), len(self) - 1) else: start_round = min( int(start) - (0 if start % 1 > 0 else 1), len(self) - 1) stop_round = max(int(stop), 0) values = [start] + list(range(start_round, stop_round, step)) + [stop] return values
def get_length(self, first=0, second=None): """ Get the (normative) Length of a Part of the Vectorlist. """ if not second: second = len(self) - 1 direction = sign(float(second - first)) length = 0 next_value = int(first - first % 1 + (direction > 0)) # Just to fasten up if next_value > len(self) and direction < 0: next_value = len(self) elif next_value < 0 < direction: next_value = 0 while next_value * direction < second * direction: length += norm(self[next_value] - self[first]) first = next_value next_value += direction # Fasten up aswell if (next_value > len(self) and direction > 0) or (next_value < 0 and direction < 0): break return length + norm(self[second] - self[first])
def get_length(self, first=0, second=None): """ Get the (normative) Length of a Part of the Vectorlist. """ if second is None: second = len(self) - 1 direction = sign(float(second - first)) length = 0 next_value = int(first - first % 1 + (direction > 0)) # Just to fasten up if next_value > len(self) and direction < 0: next_value = len(self) elif next_value < 0 < direction: next_value = 0 while next_value * direction < second * direction: length += norm(self[next_value] - self[first]) first = next_value next_value += direction # Fasten up aswell if (next_value > len(self) and direction > 0) or (next_value < 0 and direction < 0): break return length + norm(self[second] - self[first])