Skip to main content

Rational Trigonometry

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rat_trig-0.3.tar.gz (90.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rat_trig-0.3-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file rat_trig-0.3.tar.gz.

File metadata

  • Download URL: rat_trig-0.3.tar.gz
  • Upload date:
  • Size: 90.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rat_trig-0.3.tar.gz
Algorithm Hash digest
SHA256 5071f11a7f7657c97f1924fa7cb9c804a2bbd986851020e2613f400323b1af27
MD5 029f941e38093cbccefbe7bad2fd7731
BLAKE2b-256 d1f517ed91090364f63bb41b1b0f5ee1adb693e15784cda9ed68b8f84a944fbe

See more details on using hashes here.

Provenance

The following attestation bundles were made for rat_trig-0.3.tar.gz:

Publisher: python-publish.yml on luk036/rat-trig

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rat_trig-0.3-py3-none-any.whl.

File metadata

  • Download URL: rat_trig-0.3-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rat_trig-0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7448702c17dcf4e59900b2a39286b73ad8934f83a6ed685236909c5bf8f2616d
MD5 3bb1e16a3633ef3c896eb7174ac50044
BLAKE2b-256 40df100ada4368c715a180218a933bbe8089e1d8bb1207ee4e95e329466a09a6

See more details on using hashes here.

Provenance

The following attestation bundles were made for rat_trig-0.3-py3-none-any.whl:

Publisher: python-publish.yml on luk036/rat-trig

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page