Skip to main content

Project generated with PyScaffold Documentation Status Coverage Status

📐 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 vector
  • dot(v1, v2) - Dot product of two vectors
  • cross(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 quadrea
  • spread_law(q1, q2, q3) - Law of spreads for triangles
  • triple_quad_formula(q1, q2, s3) - Triple quad formula relating quadrances and spreads

Features

  • ✅ Exact arithmetic with Fraction support
  • ✅ Multiple numeric types - works with int, float, or Fraction
  • ✅ 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.

Metadata

Release files for rat-trig 0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rat-trig 0.5
File Size Uploaded Provenance Actions
rat_trig-0.5.tar.gz 89.1 kB With provenance Details for rat_trig-0.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for rat-trig 0.5
File Interpreter ABI Platform Actions
rat_trig-0.5-py3-none-any.whl Python 3 none any Details for rat_trig-0.5-py3-none-any.whl

Total release size: 96.1 kB

Release files / rat_trig-0.5.tar.gz

Download URL rat_trig-0.5.tar.gz
Size 89.1 kB
Tags Source
SHA-256 checksum
How to use checksums
89271283c22ab00d350aec958a3b21f3cc0971d6e37cbe1eaf447401a443f200
BLAKE2b-256 checksum
How to use checksums
0a9b8c10239f32aa21711104982f7045e1ebb0cc16218b253f0ca29db8c1e840
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 20, 2026.

Transparency log

Release files / rat_trig-0.5-py3-none-any.whl

Download URL rat_trig-0.5-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d2321d79b2f5997e3599f5cde320f9df12780021fe0b10b60c30dbae92144381
BLAKE2b-256 checksum
How to use checksums
d747b2c16438f35fead38a0c1d7c8d4e326a5aef0b4f8b5c240b3accc6fcc5f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 20, 2026.

Transparency log

Security for rat-trig 0.5

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.

Select from 2 files

Attestation for rat_trig-0.5.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 Nov 20, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page