A Python library for tennis equipment physics and analytics
Project description
racket-lab
racket-lab is a Python library that bridges the gap between Tennis Equipment Physics and Software Engineering. It provides tools to calculate advanced racket properties like Recoil Weight and MGR/I (Maneuverability Index), simulates racket customization with scientific accuracy, and includes a recommendation engine for string tensions and racket matching.
🚀 Features
- Physics Engine: Calculate Recoil Weight and MGR/I (Maneuverability Index) with high precision.
- Customization Lab: Simulate adding weight (lead tape) at any position and instantly see the effects on Balance, Swingweight, and Recoil Weight using the Parallel Axis Theorem. Includes Immutability for safe chainable operations.
- Recommendation Advisor:
- Tension Calculator: Get scientifically backed tension suggestions based on string material (Poly, Gut, etc.), head size, and player injury history.
- Similarity Search: Find rackets in a database that maximize "feel" similarity to a target frame using weighted Euclidean distance.
📦 Installation
Install the package via pip:
pip install racket-lab
🛠 Usage
1. Physics & Customization
from racket_lab.racket import Racket
# 1. Initialize a racket (Mass in g, Balance in cm, Swingweight in kg·cm²)
pure_aero = Racket(name="Pure Aero", mass_g=300, balance_cm=32.0, swingweight=290)
print(f"Recoil Weight: {pure_aero.recoil_weight():.1f}") # Output: 144.8
# 2. Customize: Add 4g of lead tape at 12 o'clock (70cm from handle)
custom_spec = pure_aero.customize(mass_added_g=4, position_cm=70)
print(f"New Swingweight: {custom_spec.swingweight:.1f}") # Output: 304.4
print(f"New Balance: {custom_spec.balance_cm:.2f} cm") # Output: 32.49 cm
# Original instance remains unchanged (Immutable)
2. String Tension Advisor
from racket_lab.advisor import StringsAdvisor, StringMaterial, PlayerProfile
# Configure player profile
profile = PlayerProfile(has_injury_history=True, level="intermediate")
# Get recommendation for a Polyester string on a 100 sq in head
tension = StringsAdvisor.suggest_tension(
material=StringMaterial.POLYESTER,
head_size_sq_in=100,
profile=profile
)
print(f"Recommended Tension: {tension} lbs") # Returns lower tension for arm safety
3. Finding Similar Rackets
from racket_lab.advisor import RacketMatcher
# Find the closest match to 'pure_aero' in a list of candidate rackets
match = RacketMatcher.find_closest_match(pure_aero, candidate_rackets_list)
print(f"Most similar racket: {match.name}")
📚 Physics Background
- Recoil Weight: $SW - Mass_{kg} \times (Balance_{cm} - 10)^2$
- Describes the racket's resistance to angular acceleration (kicking back) upon contact. Higher RW = more stability.
- MGR/I: derived from double pendulum physics.
- describes how easily a racket can be maneuvered to generate racket head speed. Typical values range from 20.0 to 21.5.
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file racket_lab-0.1.0.tar.gz.
File metadata
- Download URL: racket_lab-0.1.0.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
100632c8037ebad62b606819b07a6cf81347473a4157169b667280aea4d46bb2
|
|
| MD5 |
85ff2085939e5bbfa3203157d29a70f4
|
|
| BLAKE2b-256 |
97266b2699e6bc2e24bf3b04eb5e8c4d385adf77fc491702170cae82fe732784
|
File details
Details for the file racket_lab-0.1.0-py3-none-any.whl.
File metadata
- Download URL: racket_lab-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d52d8450e3ffe8fb3a9576c49ade5c938befd5a6dce8c8c9337134d8d073815
|
|
| MD5 |
a9ad02efb06e661ca6b5fde20b7581d4
|
|
| BLAKE2b-256 |
79c2307f25bb6038ebcf2ce597508e724beb840a1c4c08cc462efd794505702b
|