Simple immutable vectors.
Project description
Package: generalvector
Vectors, featuring Vec and Vec2, inspired by Expression 2* in Wiremod inside Garry's Mod.
The vectors are immutable, so any time a value inside one is changed it returns a new vector.
The bulk of the code is written twice, with one verion in vector and one version in vector2. I've begun adding new functions into general instead which both vectors inherit from, to make the code DRY. The GeneralVector class can take an arbitrary amount of axis which allows us to easily add, for example, a Vec4 in the future if all code is moved to general.
*https://github.com/wiremod/wire/wiki/Expression-2
Installation
pip install generalvector
Features
Module | Name | Explanation |
---|---|---|
vector | Vec | Immutable vector |
vector2 | Vec2 | Immutable vector2 |
Vector methods
Name | Explanation |
---|---|
absolute | Return this vector with absolute values. |
confineTo | Confine this vector to an area, but unlike clamp it subtracts axis * n to create an 'infinite' area effect. |
sanitize | Sanitize this vector with a bunch of optional flags. |
clamp | Get this vector clamped between two values as a new vector. |
distance | Return distance between two Vectors. |
hex | Get a hex based on each value. Rounded and clamped between 0 and 255. |
inrange | Return whether this vector is between two other vectors. |
length | Get the length of this vector using pythagorean theorem. |
max | Get a new vector containing the maximum value for each value in the two vectors. |
min | Get a new vector containing the minimum value for each value in the two vectors. |
normalized | Get this vector normalized by dividing each value by it's length. |
range | Get a range from two vectors. |
round | Get this vector with each value rounded. |
Usage example
from generalvector import Vec, Vec2
assert Vec(3) + 2 == Vec(5, 5, 5)
assert Vec2(3, 4).length() == 5
Releases
generalvector 1.5
- Moved test folder to inside generalvector package
generalvector 1.4
- Updated readme
Todo
- Move everything to general.py
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
generalvector-1.5.1.tar.gz
(9.8 kB
view hashes)
Built Distribution
Close
Hashes for generalvector-1.5.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | da95277d43cf52de595a25a6976f8ec1fe9c4b9c9bfced39a992232f8ae800da |
|
MD5 | a61eb5b5a1eb84929e78398b60c3d3f5 |
|
BLAKE2b-256 | 3023b64d5cb4042642a4d6196d48f00b72b0fe0c8dfbaba7895019afc7c4016d |