Loading repository dataβ¦
Loading repository dataβ¦
GiorgioMedico / repository
π InterpolatePy: A fast and precise Python library for production-ready trajectory planning, offering 20+ algorithms for CΒ² continuous splines, jerk-limited S-curves, and quaternion interpolation for robotics, animation, and scientific computing.
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
Production-ready trajectory planning and interpolation for robotics, animation, and scientific computing.
InterpolatePy provides 20+ algorithms for smooth trajectory generation with precise control over position, velocity, acceleration, and jerk. From cubic splines and B-curves to quaternion interpolation and S-curve motion profiles β everything you need for professional motion control.
β‘ Fast: Optional C++ backend with pybind11; pure-Python fallback uses vectorized NumPy π― Precise: Research-grade algorithms with CΒ² continuity and bounded derivatives π Visual: Built-in plotting for every algorithm π§ Complete: Splines, motion profiles, quaternions, and path planning in one library
pip install InterpolatePy
Requirements: Python β₯3.11, NumPy β₯2.3, SciPy β₯1.16, Matplotlib β₯3.10.5
This project uses uv for dependency and environment management.
git clone https://github.com/GiorgioMedico/InterpolatePy.git
cd InterpolatePy
uv sync # creates .venv with the default dev + test groups
To include the docs group as well: uv sync --all-groups.
import numpy as np
import matplotlib.pyplot as plt
from interpolatepy import CubicSpline, DoubleSTrajectory, StateParams, TrajectoryBounds
# Smooth spline through waypoints
t_points = [0.0, 5.0, 10.0, 15.0]
q_points = [0.0, 2.0, -1.0, 3.0]
spline = CubicSpline(t_points, q_points, v0=0.0, vn=0.0)
# Evaluate at any time
position = spline.evaluate(7.5)
velocity = spline.evaluate_velocity(7.5)
acceleration = spline.evaluate_acceleration(7.5)
# Built-in visualization
spline.plot()
# S-curve motion profile (jerk-limited)
state = StateParams(q_0=0.0, q_1=10.0, v_0=0.0, v_1=0.0)
bounds = TrajectoryBounds(v_bound=5.0, a_bound=10.0, j_bound=30.0)
trajectory = DoubleSTrajectory(state, bounds)
print(f"Duration: {trajectory.get_duration():.2f}s")
# Manual plotting (DoubleSTrajectory doesn't have built-in plot method)
t_eval = np.linspace(0, trajectory.get_duration(), 100)
results = [trajectory.evaluate(t) for t in t_eval]
positions = [r[0] for r in results]
velocities = [r[1] for r in results]
plt.figure(figsize=(10, 6))
plt.subplot(2, 1, 1)
plt.plot(t_eval, positions)
plt.ylabel('Position')
plt.title('S-Curve Trajectory')
plt.subplot(2, 1, 2)
plt.plot(t_eval, velocities)
plt.ylabel('Velocity')
plt.xlabel('Time')
plt.show()
| Category | Algorithms | Key Features | Use Cases |
|---|---|---|---|
| π΅ Splines | Cubic, B-Spline, Smoothing | CΒ² continuity, noise-robust | Waypoint interpolation, curve fitting |
| β‘ Motion Profiles | S-curves, Trapezoidal, Polynomial | Bounded derivatives, time-optimal | Industrial automation, robotics |
| π Quaternions | SLERP, SQUAD, Splines | Smooth rotations, no gimbal lock | 3D orientation control, animation |
| π― Path Planning | Linear, Circular, Frenet frames | Geometric primitives, tool orientation | Path following, machining |
π Complete Algorithms Reference β
Detailed technical documentation, mathematical foundations, and implementation details for all 22 algorithms
CubicSpline β Natural cubic splines with boundary conditionsCubicSmoothingSpline β Noise-robust splines with smoothing parameterCubicSplineWithAcceleration1/2 β Bounded acceleration constraintsBSpline β General B-spline curves with configurable degreeApproximationBSpline, CubicBSpline, InterpolationBSpline, SmoothingCubicBSplineDoubleSTrajectory β S-curve profiles with bounded jerkTrapezoidalTrajectory β Classic trapezoidal velocity profilesPolynomialTrajectory β 3rd, 5th, 7th order polynomialsLinearPolyParabolicTrajectory β Linear segments with parabolic blendsQuaternion β Core quaternion operations with SLERPQuaternionSpline β CΒ²-continuous rotation trajectoriesSquadC2 β Enhanced SQUAD with zero-clamped boundariesLogQuaternion β Logarithmic quaternion methodsSimpleLinearPath, SimpleCircularPath β 3D geometric primitivesFrenetFrame β Frenet-Serret frame computation along curvesLinearInterpolation β Basic linear interpolationTridiagonalInverse β Efficient tridiagonal system solverimport matplotlib.pyplot as plt
from interpolatepy import QuaternionSpline, Quaternion
# Define rotation waypoints
orientations = [
Quaternion.identity(),
Quaternion.from_euler_angles(0.5, 0.3, 0.1),
Quaternion.from_euler_angles(1.0, -0.2, 0.8)
]
times = [0.0, 2.0, 5.0]
# Smooth quaternion trajectory with CΒ² continuity
quat_spline = QuaternionSpline(times, orientations, interpolation_method="squad")
# Evaluate at any time
orientation, segment = quat_spline.interpolate_at_time(3.5)
# For angular velocity, use interpolate_with_velocity
orientation_with_vel, angular_velocity, segment = quat_spline.interpolate_with_velocity(3.5)
# QuaternionSpline doesn't have built-in plotting - manual visualization needed
plt.show()
import numpy as np
import matplotlib.pyplot as plt
from interpolatepy import CubicSmoothingSpline
# Fit smooth curve to noisy data
t = np.linspace(0, 10, 50)
q = np.sin(t) + 0.1 * np.random.randn(50)
# Use CubicSmoothingSpline with correct parameter name 'mu'
spline = CubicSmoothingSpline(t, q, mu=0.01)
spline.plot()
plt.show()
import numpy as np
import matplotlib.pyplot as plt
from interpolatepy import DoubleSTrajectory, StateParams, TrajectoryBounds
# Jerk-limited S-curve for smooth industrial motion
state = StateParams(q_0=0.0, q_1=50.0, v_0=0.0, v_1=0.0)
bounds = TrajectoryBounds(v_bound=10.0, a_bound=5.0, j_bound=2.0)
trajectory = DoubleSTrajectory(state, bounds)
print(f"Duration: {trajectory.get_duration():.2f}s")
# Evaluate trajectory
t_eval = np.linspace(0, trajectory.get_duration(), 1000)
results = [trajectory.evaluate(t) for t in t_eval]
positions = [r[0] for r in results]
velocities = [r[1] for r in results]
# Manual plotting
plt.figure(figsize=(12, 8))
plt.subplot(2, 1, 1)
plt.plot(t_eval, positions)
plt.ylabel('Position')
plt.title('Industrial S-Curve Motion Profile')
plt.grid(True)
plt.subplot(2, 1, 2)
plt.plot(t_eval, velocities)
plt.ylabel('Velocity')
plt.xlabel('Time')
plt.grid(True)
plt.show()
π€ Robotics Engineers: Motion planning, trajectory optimization, smooth control
π¬ Animation Artists: Smooth keyframe interpolation, camera paths, character motion
π¬ Scientists: Data smoothing, curve fitting, experimental trajectory analysis
π Automation Engineers: Industrial motion control, CNC machining, conveyor systems
C++ Backend:
InterpolatePy includes an optional compiled C++ extension for performance-critical workloads. The API is identical regardless of backend:
import interpolatepy
print(f"C++ backend: {interpolatepy.HAS_CPP}") # True if extension is available
Set INTERPOLATEPY_NO_CPP=1 to force pure-Python mode.
Typical Performance (pure-Python):
git clone https://github.com/GiorgioMedico/InterpolatePy.git
cd InterpolatePy
uv sync # creates .venv with dev + test groups
uv run pre-commit install
# Run tests
uv run pytest tests/
# Run tests with coverage
uv run pytest tests/ --cov=interpolatepy --cov-report=html --cov-report=term
# Code quality
uv run ruff format interpolatepy/
uv run ruff check interpolatepy/
uv run mypy interpolatepy/
# Run all pre-commit hooks
uv run pre-commit run --all-files
Contributions welcome! Please:
uv syncuv run pre-commit run --all-files before submittingFor major changes, open an issue first to discuss the approach.
β Star the repo if InterpolatePy helps your work!
π Report issues on GitHub Issues
π¬ Join discussions to share your use cases and feedback
MIT License β Free for commercial and academic use. See LICENSE for details.
If you use InterpolatePy in research, please cite:
@misc{InterpolatePy,
author = {Giorgio Medico},
title = {InterpolatePy: Trajectory Planning and Interpolation for Python},
year = {2025},
url = {https://github.com/GiorgioMedico/InterpolatePy}
}
This library implements algorithms from:
Robotics & Trajectory Planning:
Quaternion Interpolation:
Built with β€οΈ for the robotics and scientific computing community.