Rational Trigonometry
Project description
📐 rat-trig
Rational Trigonometry - A Python implementation of Wildberger's Rational Trigonometry
What is Rational Trigonometry?
Rational Trigonometry is a revolutionary approach to classical trigonometry, developed by Norman Wildberger. It replaces the traditional notions of distance and angle with quadrance (squared distance) and spread (squared sine of angle), allowing for:
- Exact calculations using rational numbers
- No irrational numbers or transcendental functions
- Simpler algebraic relationships
- Better suited for computational geometry and computer graphics
Installation
pip install rat-trig
For development:
git clone https://github.com/luk036/rat-trig.git
cd rat-trig
pip install -e .
Quick Start
from fractions import Fraction
from rat_trig import archimedes, spread, quad
# Calculate quadrance (squared distance)
vector = [3, 4]
print(f"Quadrance: {quad(vector)}") # Output: 25
# Calculate spread between two vectors
v1 = [1, 2]
v2 = [3, 4]
print(f"Spread: {spread(v1, v2)}") # Output: 4/125
# Apply Archimedes' formula to a triangle
q1, q2, q3 = Fraction(1, 2), Fraction(1, 4), Fraction(1, 6)
A = archimedes(q1, q2, q3)
print(f"Quadrea: {A}") # Output: 23/144
Core Functions
Geometric Operations
quad(vector)- Calculate quadrance (squared distance) of a vectordot(v1, v2)- Dot product of two vectorscross(v1, v2)- Cross product of two vectors
Trigonometric Operations
spread(v1, v2)- Calculate spread between two vectors (squared sine of angle)archimedes(q1, q2, q3)- Archimedes' formula for triangle quadreaspread_law(q1, q2, q3)- Law of spreads for trianglestriple_quad_formula(q1, q2, s3)- Triple quad formula relating quadrances and spreads
Features
- ✅ Exact arithmetic with
Fractionsupport - ✅ Multiple numeric types - works with
int,float, orFraction - ✅ 99% test coverage with comprehensive unit tests
- ✅ Type hints throughout the codebase
- ✅ Well-documented with docstrings and examples
Documentation
Full documentation is available at https://rat-trig.readthedocs.io.
Testing
Run tests:
pytest
With coverage:
pytest --cov rat_trig
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
License
MIT License - see LICENSE for details.
Acknowledgments
This project was developed using PyScaffold and is based on Norman Wildberger's work on Rational Trigonometry.
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 rat_trig-0.2.tar.gz.
File metadata
- Download URL: rat_trig-0.2.tar.gz
- Upload date:
- Size: 92.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb14e988cc25aecf6d871dbcc98be5c9c8481b47695b3b45a6a7669efab1d13d
|
|
| MD5 |
57d747a9c7cddab4b2e361e61e6a12d0
|
|
| BLAKE2b-256 |
5322b88cf0a33619b2bbc1f40bca418295451d47f317abfd331a55478fd40e99
|
Provenance
The following attestation bundles were made for rat_trig-0.2.tar.gz:
Publisher:
python-publish.yml on luk036/rat-trig
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rat_trig-0.2.tar.gz -
Subject digest:
fb14e988cc25aecf6d871dbcc98be5c9c8481b47695b3b45a6a7669efab1d13d - Sigstore transparency entry: 1910619766
- Sigstore integration time:
-
Permalink:
luk036/rat-trig@a405a723ce6a6f316b894dba6244431cc80ef3ff -
Branch / Tag:
refs/tags/0.2 - Owner: https://github.com/luk036
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@a405a723ce6a6f316b894dba6244431cc80ef3ff -
Trigger Event:
release
-
Statement type:
File details
Details for the file rat_trig-0.2-py3-none-any.whl.
File metadata
- Download URL: rat_trig-0.2-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c532166fe575e58abd7d98d05b3027f8a0ebf923d47018a17db7d9310850c405
|
|
| MD5 |
0da26b62bb0027fe89f7bd7aab886036
|
|
| BLAKE2b-256 |
c148daab4fd759fe2df7b399fecbba2d452274ba90427e45c65f0d32339bcc05
|
Provenance
The following attestation bundles were made for rat_trig-0.2-py3-none-any.whl:
Publisher:
python-publish.yml on luk036/rat-trig
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rat_trig-0.2-py3-none-any.whl -
Subject digest:
c532166fe575e58abd7d98d05b3027f8a0ebf923d47018a17db7d9310850c405 - Sigstore transparency entry: 1910620420
- Sigstore integration time:
-
Permalink:
luk036/rat-trig@a405a723ce6a6f316b894dba6244431cc80ef3ff -
Branch / Tag:
refs/tags/0.2 - Owner: https://github.com/luk036
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@a405a723ce6a6f316b894dba6244431cc80ef3ff -
Trigger Event:
release
-
Statement type: