-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 14a5785
Showing
14 changed files
with
1,165 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# files from code editors | ||
|
||
.vscode | ||
.idea | ||
|
||
|
||
# temporary cache files | ||
|
||
src/__pycache__ | ||
src/vectogebra/__pycache__ | ||
test/__pycache__ | ||
|
||
# dist and build can be created by running $ python -m build | ||
dist | ||
build | ||
src/vectogebra.egg-info | ||
|
||
# NOTE: to publish the files on PyPI, submit only the dist directory | ||
# Everytime we decide to finalize the release, | ||
# we should update the version in the setup.cfg file and setup.py file. | ||
# should update the dist directory | ||
# by running $ python -m build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# CHANGELOG | ||
|
||
record of major changes to the project including bug fixes will be stored here. | ||
|
||
## [0.0.6] | ||
|
||
### the library is now comlpetely functional. | ||
|
||
- optimised the directory structure. | ||
- importing vector class is now easy. | ||
- resolved the issue of angle between parallel vectors. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Mohammad Maasir | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,213 @@ | ||
# vectogebra v 0.0.6 | ||
|
||
### Python module for vector algebra | ||
|
||
easy to use vector algebra library for python, that lets ypu work with vectors in an efficient way. | ||
apart from core vector object, many other vector operations are supported. | ||
these can be imported from vectogebra.utilities. | ||
|
||
this library was made by keeping its applications in Physics in mind (Mechanics, Optics, etc.) | ||
|
||
- does not depend on any external libraries except math library. | ||
- fully functional | ||
- easy to use | ||
- supports nearly all vector operations | ||
- beginner friendly | ||
- physics friendly | ||
- Open for modifications | ||
|
||
--- | ||
|
||
Author: _Mohammad Maasir_ | ||
|
||
License: _MIT_ | ||
|
||
date-created: _8th of May, 2022_ | ||
|
||
--- | ||
|
||
# 💥 Install | ||
|
||
`pip install vectogebra` | ||
|
||
### ⭐ Start by importing the vector class | ||
|
||
`import vectogebra.vector as vect` | ||
|
||
_OR_ | ||
|
||
`from vectogebra import vector as vect` | ||
|
||
### ⭐ Also import useful utility functions | ||
|
||
`import vectogebra.utitlies as vut` | ||
|
||
_OR_ | ||
|
||
`from vectogebra import utilities as vut` | ||
|
||
--- | ||
|
||
# 🔥 Description of the module | ||
|
||
## Create a vector object : | ||
|
||
`v1 = vect(1,2,3)` | ||
|
||
--- | ||
|
||
## 🔢 Algebric operations : | ||
|
||
### 1. Addition | ||
|
||
consider two(or more) vectors : a,b,... | ||
their sum will be given by : | ||
`s = a + b + ...` | ||
sum `s` will also be a vector object. | ||
|
||
### 2. Subctraction | ||
|
||
Vectors can be subtracted using the minus (`-`) operator. | ||
|
||
example : | ||
|
||
`s = a - b + c - d + ...` | ||
|
||
resultant `s` will also be a vector object. | ||
|
||
### 3. Dot product / scalar product and scalar multiplication | ||
|
||
the `*` operator will be used for dot product, or multiplication by a scalar. | ||
|
||
example : | ||
|
||
`p = a * b * c * d * ...` is same as "a dot b dot c dot ...". | ||
|
||
`p = 5*v` is same as "scalar 5 multiplied to vector v". | ||
|
||
### 4. Cross product / vector multiplication | ||
|
||
the `^` operator will be used for cross product, or vector product. | ||
|
||
example : | ||
|
||
`p = a^b` is same as "p equals a cross b". | ||
|
||
### 5. division by a scalar | ||
|
||
simply divide a vector by a scalar. | ||
NOTE : division by zero or division vector is not supported. | ||
|
||
example : | ||
|
||
`p = v / 5` is same as "p equals v divided by 5". | ||
|
||
--- | ||
|
||
## ❌✔️ Logical operations : | ||
|
||
--- | ||
|
||
### 1. Equality | ||
|
||
`a == b` returnes True when a and b are equal in magnitude and direction. else, it returns False | ||
|
||
### 2. Inequality | ||
|
||
`a != b` have its usual meaning | ||
|
||
### 3. grater / lesser | ||
|
||
the **magnitude** of the vectors can be compared using common logical operators. | ||
|
||
``` | ||
# a and b are vectors | ||
a > b | ||
a < b | ||
a >= b | ||
a <= b | ||
``` | ||
|
||
--- | ||
|
||
## Attributes of the vector object | ||
|
||
--- | ||
|
||
### Components | ||
|
||
1. `v1.x` **OR** `vi.i` | ||
2. `v1.y` **OR** `vi.j` | ||
3. `v1.z` **OR** `vi.k` | ||
|
||
### Magnitude | ||
|
||
4. `v1.magnitude` **OR** `vi.mod` | ||
|
||
### Magnitude squared (useful when precesion is required) | ||
|
||
5. `v1.magnitude_squared` **OR** `v1.mod_squared` | ||
|
||
### Type | ||
|
||
6. `v1.type` ==different from type(v1)== | ||
|
||
--- | ||
|
||
## 🚀 Vectogebra's Utitlies (vut) | ||
|
||
--- | ||
|
||
### 1. `vut.angle(v1,v2)` | ||
|
||
### 2. `vut.dot(v1,v2)` | ||
|
||
### 3. `vut.cross(v1,v2)` | ||
|
||
### 4. `vut.magnitude(v1)` | ||
|
||
### 5. `vut.unit(v1)` | ||
|
||
### 6. `vut.is_perpendicular(v1,v2)` | ||
|
||
### 7. `vut.is_parallel(v1,v2)` | ||
|
||
### 8. `vut.scalar_component_parallel(v1,v2)` | ||
|
||
### 9. `vut.scalar_component_perpendicular(v1,v2)` | ||
|
||
### 10. `vut.vector_component_parallel(v1,v2)` | ||
|
||
### 11. `vut.vector_component_perpendicular(v1,v2)` | ||
|
||
### 12. `vut.unit_vector(v)` **OR** `vut.direction(v)` ==Returns the unit vector parallel to v== | ||
|
||
### 13. `vut.dot(v1,v2)` ==dot product== | ||
|
||
### 14. `vut.cross(v1,v2)` ==cross product== | ||
|
||
### 15. `vut.parallelogram_area(v1,v2)` ==returns parallelogram area formed vy joining v1 and v2 tail to tail== | ||
|
||
### 16. `vut.box(a,b,c)` ==Box product== | ||
|
||
### 17. `vut.collinear(a,b,c)` ==returns true if a,b,c are collinear== | ||
|
||
### 18. `vut.vector_to_list(v)` ==returns a list of the components of v== | ||
|
||
### 19. `vut.vector_to_dict(v)` ==returns a dictionary of the components of v== | ||
|
||
### 20. `vut.vector_to_tuple(v)` ==returns a tuple of the components of v== | ||
|
||
### 21. `vut.list_to_vector(l)` ==returns a vector object from a list of components== | ||
|
||
### 22. `vut.dict_to_vector(d)` ==returns a vector object from a dictionary of components== | ||
|
||
### 23. `vut.tuple_to_vector(t)` ==returns a vector object from a tuple of components== | ||
|
||
--- | ||
|
||
### ❤️ vectorogebra is open source and free to use. | ||
|
||
--- | ||
|
||
_Copyright (c) 2022 Mohammad Maasir_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[build-system] | ||
requires = ["setuptools>=42"] | ||
build-backend = "setuptools.build_meta" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# NOTE:- | ||
# every time you want to compile(build/ditributre) | ||
# change the version | ||
# and run $ python -m build | ||
|
||
[metadata] | ||
name = vectogebra | ||
version = 0.0.6 | ||
author = Mohammad Maasir | ||
license = MIT | ||
author_email = [email protected] | ||
description = Python library for vector class and utilities for vector algebra. | ||
long_description = file: README.md | ||
long_description_content_type = text/markdown | ||
url = https://github.com/maasir554/vectogebra | ||
project_urls = | ||
Bug Tracker = https://github.com/maasir554/vectogebra/issues | ||
classifiers = | ||
Programming Language :: Python :: 3 | ||
License :: OSI Approved :: MIT License | ||
Operating System :: OS Independent | ||
|
||
[options] | ||
package_dir = | ||
= src | ||
packages = find: | ||
python_requires = >=3.6 | ||
|
||
[options.packages.find] | ||
where = src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# NOTE:- | ||
# every time you want to compile(build/ditributre) | ||
# change the version | ||
# and run $ python -m build | ||
import setuptools | ||
|
||
with open("README.md", "r", encoding="utf-8") as fh: | ||
long_description = fh.read() | ||
|
||
setuptools.setup( | ||
name="vectogebra", | ||
version="0.0.6", | ||
author="Mohammad Maasir", | ||
license="MIT", | ||
author_email="[email protected]", | ||
description="Package that helps you work with vector algebra !", | ||
long_description=long_description, | ||
long_description_content_type="text/markdown", | ||
url="https://github.com/maasir554/vectogebra", | ||
project_urls={ | ||
"Bug Tracker": "https://github.com/maasir554/vectogebra/issues", | ||
}, | ||
classifiers=[ | ||
"Programming Language :: Python :: 3", | ||
"License :: OSI Approved :: MIT License", | ||
"Operating System :: OS Independent", | ||
], | ||
package_dir={"": "src"}, | ||
packages=setuptools.find_packages(where="src"), | ||
python_requires=">=3.6", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
""" | ||
file under vectogebra - python module for vector algebra | ||
vectogrbra/__init__.py | ||
------------------------- | ||
This module contains the 'vector' class. | ||
------------------------------------------------- | ||
copyright: (C) 2022 Mohammad Maasir | ||
license: MIT License (see LICENSE in project's main directory) | ||
------------------------------------------------- | ||
date created: 9th of May, 2022 (3:09 AM) | ||
last modified: 9th of May, 2022 | ||
------------------------------------------------- | ||
contributor(s): Mohammad Maasir | ||
------------------------------------------------- | ||
github: github.com/maasir554 | ||
""" | ||
|
||
# importing vector class from vector.py | ||
# the dot is necessary to avoid name conflict. | ||
# from .vector import vector | ||
|
||
# exception handling is best solution to any problem | ||
# here in | ||
try: | ||
from .vector import vector # this import is for the build version | ||
except : | ||
pass # simply ignore the error and the module will be imported | ||
# pass will simply ignore the import command here and test files will import the module by | ||
# the local command written in them | ||
|
||
|
||
""" | ||
to use vector object class, in your file, write: import vectogerbra.vector as v | ||
then you can use the vector class in your file | ||
example: v1 = v(1,2,3) | ||
to import the vector class in your file, you can use the following: | ||
## import vectogerbra.vector as v [or any other alias name you want] | ||
## from vectogerbra import vector as v [or any other alias name you want] | ||
""" | ||
|
||
# importing utility functions from utilities.py | ||
|
||
# from .utilities import * | ||
|
Oops, something went wrong.