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.
Release files for Vectorian-arjungangwar 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| vectorian_arjungangwar-0.1.0.tar.gz | 14.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| vectorian_arjungangwar-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 31.5 kB
Release files / vectorian_arjungangwar-0.1.0.tar.gz
| Download URL | vectorian_arjungangwar-0.1.0.tar.gz |
|---|---|
| Size | 14.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e9392f36fff497d8de17e2717debe3e3be37704d9bf56f455c9fd403d9a3a51a
|
|
BLAKE2b-256 checksum How to use checksums |
a5bb492dec7b39a201c0400f02ae97488a0494a054fc6d538f007628e7b9d494
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Release files / vectorian_arjungangwar-0.1.0-py3-none-any.whl
| Download URL | vectorian_arjungangwar-0.1.0-py3-none-any.whl |
|---|---|
| Size | 16.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bea3578e860950b879fb855c31e3f2bf626c4087f6b8b93d6a2ff75f102d6ed3
|
|
BLAKE2b-256 checksum How to use checksums |
dd7432594a2a1d39faadbaa7159f931208039862495a13278b2f9f2c1b9f0849
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|