Professional vector mathematics toolkit for school, engineering, and scientific Python workflows
Project description
Vectorian
Vectorian is a practical Python library for vector mathematics. It supports school-level vector algebra, coordinate geometry, 3D transformations, and numerical vector calculus in a small package that is easy to install and use.
Installation
pip install Vectorian-arjungangwar
For local development:
pip install -e ".[dev]"
pytest
Quick Start
from vectorian import Vector, Vector3D, dot, cross, angle_between
u = Vector(1, 2, 3)
v = Vector(4, 5, 6)
print(u + v) # (5.0000, 7.0000, 9.0000)
print(dot(u, v)) # 32.0
print(u.magnitude()) # 3.741657386...
print(angle_between(u, v, radians=False))
i = Vector3D(1, 0, 0)
j = Vector3D(0, 1, 0)
print(cross(i, j)) # Vector3D(0.0000, 0.0000, 1.0000)
Vector Algebra
from vectorian import (
Vector,
are_parallel,
direction_cosines,
gram_schmidt,
projection,
scalar_projection,
)
a = Vector(3, 4)
b = Vector(1, 0)
print(a.normalize())
print(projection(a, b))
print(scalar_projection(a, b))
print(direction_cosines(a))
print(are_parallel(Vector(2, 4), Vector(1, 2)))
basis = gram_schmidt([Vector(1, 1, 0), Vector(1, 0, 1)])
Coordinate Geometry Helpers
These helpers cover common CBSE/ISC/NCERT vector and 3D geometry tasks: section formula, midpoint, distance, collinearity, coplanarity, areas, and volumes.
from vectorian import (
Vector,
Vector3D,
are_collinear,
are_coplanar,
centroid,
midpoint,
section_point,
tetrahedron_volume,
triangle_area,
vector_between,
)
a = Vector(0, 0)
b = Vector(6, 6)
print(midpoint(a, b)) # (3.0000, 3.0000)
print(section_point(a, b, 1, 2)) # internal ratio 1:2
print(vector_between(a, b))
print(triangle_area(Vector(0, 0), Vector(4, 0), Vector(0, 3)))
p = Vector3D(0, 0, 0)
q = Vector3D(1, 0, 0)
r = Vector3D(0, 1, 0)
s = Vector3D(0, 0, 1)
print(are_collinear(Vector(0, 0), Vector(1, 1), Vector(2, 2)))
print(are_coplanar(p, q, r, Vector3D(2, 2, 0)))
print(tetrahedron_volume(p, q, r, s))
print(centroid([p, q, r, s]))
3D Transformations
from vectorian import Vector3D, rotate_vector, spherical_to_cartesian
v = Vector3D(1, 0, 0)
print(rotate_vector(v, "z", 90))
print(v.rotate_around_axis(Vector3D(0, 0, 1), 90))
print(spherical_to_cartesian(1, 1.57079632679, 0))
Vector Calculus
from vectorian import Vector3D, VectorField, gradient, divergence, curl
def f(x, y, z):
return x*x + y*y + z*z
print(gradient(f, 1, 1, 1))
field = VectorField(
lambda x, y, z: x,
lambda x, y, z: y,
lambda x, y, z: z,
)
print(divergence(field.P, field.Q, field.R, 1, 1, 1))
print(curl(field.P, field.Q, field.R, 1, 1, 1))
Main Features
- N-dimensional vectors with arithmetic, norms, dot products, projections, direction ratios, direction cosines, and NumPy conversion.
- 2D scalar cross product and 3D vector cross product.
Vector3Dhelpers for rotations, spherical/cylindrical coordinates, reflections, triple products, and axis angles.- Coordinate geometry helpers for section formula, midpoint, centroid, distance, triangle area, tetrahedron volume, collinearity, and coplanarity.
- Linear algebra helpers including Gram-Schmidt, rank, determinants, and linear independence checks.
- Numerical vector calculus: gradient, divergence, curl, Laplacian, directional derivative, Jacobian, Hessian, line integrals, scalar fields, and vector fields.
License
MIT License. See LICENSE 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
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 vectorian_arjungangwar-0.1.0.tar.gz.
File metadata
- Download URL: vectorian_arjungangwar-0.1.0.tar.gz
- Upload date:
- Size: 14.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e9392f36fff497d8de17e2717debe3e3be37704d9bf56f455c9fd403d9a3a51a
|
|
| MD5 |
560f98e2ce3a3e2b2d23a0995ae89904
|
|
| BLAKE2b-256 |
a5bb492dec7b39a201c0400f02ae97488a0494a054fc6d538f007628e7b9d494
|
File details
Details for the file vectorian_arjungangwar-0.1.0-py3-none-any.whl.
File metadata
- Download URL: vectorian_arjungangwar-0.1.0-py3-none-any.whl
- Upload date:
- Size: 16.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bea3578e860950b879fb855c31e3f2bf626c4087f6b8b93d6a2ff75f102d6ed3
|
|
| MD5 |
99e11945c09066768f2784f734dedb11
|
|
| BLAKE2b-256 |
dd7432594a2a1d39faadbaa7159f931208039862495a13278b2f9f2c1b9f0849
|