Tiny 2D vector helpers, no NumPy, no classes.
Project description
tinyvec2d
Tiny 2D vector helpers for Python.
No NumPy.
No classes.
Just tuples and math.
Why does this exist?
Because sometimes you just want to do simple 2D vector math without:
- installing NumPy
- dealing with arrays
- using classes or operator overloading
- pulling heavy dependencies
This is especially useful in constrained environments (for example, mobile Python like Pydroid3) or small scripts where NumPy is overkill.
This is a hobby project, made for convenience, not for performance or completeness.
What is a vector?
A vector is simply a tuple:
(x, y)
Example:
v = (3.0, 4.0)
All functions:
- take tuples as input
- return new tuples
- never mutate data
Features
- 2D vectors only
- pure Python
- depends only on the standard
mathmodule - explicit, functional API
- predictable behavior
Included operations:
- vector addition and subtraction
- scalar multiplication and division
- dot product
- length and distance
- normalization
Example usage
from tinyvec2d import add, length, normalize, scalar_mul
v = (3, 4)
w = (1, 2)
add(v, w) # (4, 6)
length(v) # 5.0
normalize(v) # (0.6, 0.8)
scalar_mul(v, 2) # (6, 8)
Design choices
-
No classes
Vectors are plain tuples. This keeps things simple and transparent. -
No operator overloading
Functions like add(v, w) are explicit and easy to read. -
No NumPy
This is not meant to replace NumPy. It exists for cases where NumPy is inconvenient or unavailable. -
Fail fast
Invalid inputs raise errors instead of trying to guess what you meant.
What this is NOT
- A full linear algebra library
- A physics engine
- A performance-oriented solution
- A NumPy replacement
If you need high performance, broadcasting, or large arrays, use NumPy.
Stability
The API is small and may change. This project prioritizes simplicity over long-term backward compatibility.
License
MIT License
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 tinyvec2d-0.1.0.tar.gz.
File metadata
- Download URL: tinyvec2d-0.1.0.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e6f6b2f4ae78495b9a9070452701f76c051add027996f517e6e33167f980776f
|
|
| MD5 |
1ebb3421feccf00934220b6c7850aee9
|
|
| BLAKE2b-256 |
d9c8727c8b38ac904eb571f1149f1b6b69011c176faab78926c3322d3982771c
|
File details
Details for the file tinyvec2d-0.1.0-py3-none-any.whl.
File metadata
- Download URL: tinyvec2d-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d777364563806eb530b261f5a73ca6373e473205c2123765a63f51a83297d0d
|
|
| MD5 |
93b175a3f7b77ffcfef7b4794973f776
|
|
| BLAKE2b-256 |
848d4ad7c02a1072fa9d668f6f7043a66673c392069681bc5890b0df6cbc44c3
|