Skip to main content

A lightweight, zero-dependency 2D vector library for Python.

Project description

ezvectors

A lightweight, high-performance, zero-dependency 2D vector library for Python.

ezvectors provides a robust Vector2 class with a simple and intuitive API for standard vector mathematics. It is highly optimized for fast hot loops, making it suitable for game development, physics engines, and geometry calculations.

Installation

You can install ezvectors via pip:

pip install ezvectors

Quick Start

from ezvectors import Vector2

# Initialization
v1 = Vector2(3, 4)
v2 = Vector2(5, 6)
v3 = Vector2((1, 2)) # From a tuple

# Math operations
print(v1 + v2)         # Vector2(8, 10)
print(v1 - (1, 1))     # Vector2(2, 3)
print(v1 * 2)          # Vector2(6, 8)
print(v2 / 2)          # Vector2(2.5, 3.0)

# Properties & Geometry
print(v1.magnitude())        # 5.0
print(v1.normalize())        # Vector2(0.6, 0.8)
print(v1.distance_to(v2))    # 2.8284271247461903
print(v1.dot(v2))            # 39
print(v1.cross(v2))          # -2

# Iteration and Unpacking
x, y = v1
print(f"X: {x}, Y: {y}")

# Advanced
print(v1.rotate_deg(90))     # Rotates vector by 90 degrees

Features

  • Zero Dependencies: Written purely in standard Python using math.
  • Highly Optimized: Utilizes Python __slots__ for low memory footprint and fast execution without redundant object allocations in critical loops.
  • Tuple Compatibility: Seamlessly integrates with standard Python tuples in mathematical operations (e.g., Vector2(1, 1) + (2, 2)).

License

This project is licensed under the MIT License. See the LICENSE.md file for details.

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

ezvectors-0.1.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

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

ezvectors-0.1.0-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file ezvectors-0.1.0.tar.gz.

File metadata

  • Download URL: ezvectors-0.1.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for ezvectors-0.1.0.tar.gz
Algorithm Hash digest
SHA256 22ecac65d7869aa6020a5e47b2174a172ad93d828ad62c8e216753c3216f3e0c
MD5 9cb1359462956f12e96f603ce229394b
BLAKE2b-256 b2c2469f59b3f684f9c5c02a4bdfa20519e8ff24581d504499c74f018be4f5ad

See more details on using hashes here.

File details

Details for the file ezvectors-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ezvectors-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for ezvectors-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1a848772d5627522bd3beb9f83a4ab9d8acecc07b029c21c7a71a787ba880e09
MD5 40a0e843b53151317c20e102e1f7e24d
BLAKE2b-256 a36fd9c4db4ae12cebc758931dc767e7fb1792d9c51acb8494361cdaed43114f

See more details on using hashes here.

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