Skip to content

Instantly share code, notes, and snippets.

View M-Haris72's full-sized avatar

Haris M-Haris72

View GitHub Profile
@M-Haris72
M-Haris72 / Interpolate_points.py
Created February 15, 2025 07:45
This function returns interpolated points between two given points based on the specified number of interpolations. It can be used when interpolation of points within a given range is required.
def interpolate_points(list_of_points, num_of_time_interpolations):
interpolated_points = []
for i in range(len(points) - 1):
x1, y1 = points[i]
x2, y2 = points[i + 1]
interpolated_points.append((x1, y1))
for j in range(1, num_interpolations + 1):
t = j / (num_interpolations + 1)
x_new = x1 + (x2 - x1) * t
y_new = y1 + (y2 - y1) * t