Two Points Interpolation Python
Calculate optimal trajectory (position, velocity, acceleration) between two points with kinematic constraints.
Overview
This library provides two trajectory planning algorithms:
- Constant Acceleration: Generates smooth trajectories with acceleration limits
- Constant Jerk: Generates even smoother trajectories with jerk (acceleration derivative) limits
Installation
From PyPI (when published)
pip install two-point-interpolation
From Source
git clone https://github.com/yuokamoto/two_points_interpolation_py.git
cd two_points_interpolation_py
pip install -e .
For Development
git clone https://github.com/yuokamoto/two_points_interpolation_py.git
cd two_points_interpolation_py
pip install -e ".[dev]"
# Install pre-commit hooks for automatic code formatting and type checking
pre-commit install
The pre-commit hooks will automatically run before each commit to:
- Format code with
autopep8 - Check types with
mypy(strict forconstant_accmodule) - Validate code style with
flake8 - Remove trailing whitespace
- Validate YAML files
You can also run the hooks manually on all files:
pre-commit run --all-files
Quick Start
Constant Acceleration
from two_point_interpolation import TwoPointInterpolation
# Create interpolator
interp = TwoPointInterpolation()
# Set start, end, and constraints
interp.init(p0=0.0, pe=100.0, acc_max=2.0, vmax=10.0, dec_max=4.0)
# Calculate trajectory
total_time = interp.calc_trajectory()
# Get state at any time
pos, vel, acc = interp.get_point(t=5.0)
Constant Jerk
from two_point_interpolation.constant_jerk import TwoPointInterpolationJerk
interp = TwoPointInterpolationJerk()
interp.init(p0=0.0, pe=100.0, amax=2.0, vmax=10.0, jmax=1.0)
total_time = interp.calc_trajectory()
pos, vel, acc, jerk = interp.get_point(t=5.0)
Note: Constant jerk implementation is currently under review. See TODO section below.
Examples
Run example scripts to see visualizations:
# Basic constant acceleration
python3 examples/example_constant_acc.py
# Constant jerk (smoother)
python3 examples/example_constant_jerk.py
Testing
The library includes a comprehensive YAML-based testing system.
Quick Start
# Run all tests
python -m pytest tests/test_yaml_cases.py -v
# Generate trajectory visualizations
python tests/generate_plots.py
# List available test categories
python tests/generate_plots.py --list
Detailed Documentation
For comprehensive testing information, debugging guides, and visualization usage:
📖 See tests/README.md for complete testing documentation
Project Structure
two_points_interpolation_py/
├── two_point_interpolation/ # Main package
│ ├── __init__.py # Package exports
│ ├── constant_acc.py # Acceleration-based planning (enhanced)
│ └── constant_jerk.py # Jerk-based planning (TODO: needs review)
├── examples/ # Example scripts
│ └── images/ # Generated plots
├── tests/ # YAML-based test suite (51+ tests)
│ ├── test_cases.yaml # Test case definitions
│ ├── test_case_loader.py # YAML parsing utilities
│ ├── test_yaml_cases.py # Test runner
│ ├── test_trajectory_properties.py # Property sweeps over input grids
│ ├── generate_plots.py # Visualization tool
│ └── plots/ # Generated test plots
└── docs/ # Documentation
├── CONSTANT_ACC_DERIVATION.md # Mathematical details
├── edge_cases_analysis.md # Edge cases and overspeed analysis
└── CHANGELOG.md # Version history
Example Results
Case 0: vmax not reached
Parameters: t0=1.0, p0=5, pe=15, acc_max=2.0, dec_max=3.0, vmax=10.0, v0=0, ve=0
Trajectory when the peak velocity is below vmax. Shows two phases: acceleration and deceleration.
Case 1: vmax reached
Parameters: t0=0, p0=0, pe=50, acc_max=2.0, dec_max=4.0, vmax=8.0, v0=2.0, ve=1.0
Trajectory when vmax is reached. Shows three phases: acceleration, constant velocity, and deceleration.
Initial velocity away from the target
Parameters: t0=0, p0=0, pe=10, acc_max=2.0, dec_max=3.0, vmax=5.0, v0=-3.0, ve=0
The body starts moving away from the target. The first phase accelerates toward the target, so it slows down, turns back at the marked point and speeds up toward the target; the trajectory then cruises at vmax and decelerates onto it. The slowing down before the turn is part of the acceleration phase, so it is bounded by acc_max, not dec_max.
Documentation
- Getting Started: This README
- Testing Guide: tests/README.md - Comprehensive testing documentation
- Mathematical Derivation: docs/CONSTANT_ACC_DERIVATION.md
- Edge Cases Analysis: docs/edge_cases_analysis.md
- Change History: docs/CHANGELOG.md
Known Issues & TODO
Constant Jerk Implementation Issues
The constant_jerk module requires significant improvements:
- API Contract Violation: The
ve(final velocity) parameter is accepted ininit()but never used in calculations - Debug Output:
calc_trajectory()prints debug information to stdout (should use logging or be removed) - Time Boundary Bug: Case 3 condition uses
4*t1+2*2*t2+t3instead of correct4*t1+2*t2+t3, causing phase transition errors - Missing Tests: No test coverage for constant jerk functionality
- Support acc_max != dec_max: Extend to support independent acceleration/deceleration limits
Other
- Add comprehensive test suite for
constant_jerkmodule - Verify mathematical correctness of jerk-based trajectories
Requirements
- Python 3.6+
- NumPy
- Matplotlib (for examples)
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
This software is provided "AS IS" without warranty of any kind.
Metadata
Release files for two-point-interpolation 1.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| two_point_interpolation-1.3.2.tar.gz | 51.0 kB | With provenance | Details for two_point_interpolation-1.3.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| two_point_interpolation-1.3.2-py3-none-any.whl | Python 3 | none | any | Details for two_point_interpolation-1.3.2-py3-none-any.whl |
Total release size: 73.0 kB
Release files / two_point_interpolation-1.3.2.tar.gz
| Download URL | two_point_interpolation-1.3.2.tar.gz |
|---|---|
| Size | 51.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3ff5be9699f621b58e1b0c972dda5786eea5d4c7eb06f2dcc386673b234dad19
|
|
BLAKE2b-256 checksum How to use checksums |
1e51b6cda893fd1cb6bd5087047b862b5866921b0b0ddb4d9d5626f3889f7517
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.
Transparency logRelease files / two_point_interpolation-1.3.2-py3-none-any.whl
| Download URL | two_point_interpolation-1.3.2-py3-none-any.whl |
|---|---|
| Size | 22.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
57550a54bd08b886d97de25c824fbddbba5b54b8e7cb776084f4cd5330084857
|
|
BLAKE2b-256 checksum How to use checksums |
fd123ddd4d1d8b4d91fa9af8b63e24c20edd7bca84cd97d66e59091296cb6ed8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.
Transparency logSecurity for two-point-interpolation 1.3.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for two_point_interpolation-1.3.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.