A vector library to contain and manipulate 2D and 3D points.
Project description
Usage
- To import everything:
import vectors
- To import only 2D and 3D points:
from vectors import Vector2, Vector3, Slope
- Create a 2D Vector:
v = Vector2(x, y)
- Create a 3D vector:
v = Vector3(x, y, z)
- Create a slope instance:
m = Slope(rise, run)
- Get point information:
_.x
or_.y
or if Vector3,_.z
- Get all points/rise and run as a tuple:
_.tuple()
- Get all points/rise and run as an array list:
_.list()
- Get all points/rise and run as a dictionary:
_.dict()
- Get rise over run from slope object as a string formated as
rise/run
:
_.string()
- Add two points:
vectors.add(<v1>, <v2>)
_.add(v)
- Subtract two points:
vectors.subtract(<v1>, <v2>)
_.subtract(v)
- Multiply two points:
vectors.multiply(<v1>, <v2>)
_.multiply(v)
- Divide two points:
vectors.divide(<v1>, <v2>)
_.divide(v)
- Simplify slope rise and run:
_.simplify()
- Generate a 2D vector matrix:
vectors.generate_square_matrix(<Vector2>, <Vector2>)
Usage Notes:
vectors.find_slope(<Vector2>, <Vector2>)
returns a Slope classvectors.generate_square_matrix(<Vector2>, <Vector2>)
increments by one. This means your given Vector2 objects should only contain ints, no double or floats.- You can add, subtract, multiply, and divide a
Vector2
and aVector3
(and vice versa). The output will be converted to a Vector3, using0 <operator> <second_param>.z
as the z value - IMPORTANT: Remember when dividing, you cannot divide by zero.
0 / 2
is valid, however2 / 0
is not. If your second parameter has a 0, you WILL get an error
Updates
11/18/2020 - 1.2.1
- Added inline math functions
- Added square matrix generation with
vectors.generate_square_matrix(<vector2>, <vector2>)
- Added
Slope
class - Added
vectors.find_slope(<Vector2>, <Vector2>)
,_.simplify()
, and_.string()
functions
11/18/2020 - 1.1.1-1.1.2
- Updated README.md
11/18/2020 - 1.1.0
- Added add, subtract, multiply, and dividing of Vector2 and Vector3
11/18/2020 - 1.0.0
- Fixed
Vector3.tuple()
showing as(x, y, x)
instead of(x, y, z)
11/17/2020 - 0.0.1
- Package published
Other Information
See my other projects at https://fosterreichert.com
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
python-vectors-1.2.1.tar.gz
(3.0 kB
view hashes)
Built Distribution
Close
Hashes for python_vectors-1.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25cb48e2abd011c37e7593589aa61a21123b03f7ec4e2b03d624ac676f6e73f0 |
|
MD5 | 208a2fec968038b30fb7fcb4ca0db0db |
|
BLAKE2b-256 | 2c2a7981da2bed217201164340a5d0b9e6fee61d677796c7c5e69f99870e1082 |