Python library for 2d/3d coordinate geometry
Project description
utnamgeo
Python library to solve 2d/3d coordinate geometry
Installation
pip install utnamgeo
Requirements
pip install utnamtte
Documentation
Ways to import
Method 1
import utnamgeo
print(utnamgeo.area_3d(...))
Method 2
from utnamgeo import area_3d
print(area_3d(...))
Method 3
from utnamgeo import area_3d as xy
print(xy(...))
Method 4 ( my favourite)
from utnamgeo import *
print(area_3d(...))
Useful functions
area_2d
#returns area of triangle with vertices (x1, y1) (x2, y2) and (x3, y3)
area = area_2d(x1, y1, x2, y2, x3, y3)
area_3d
#returns area of triangle in 3d space with vertices (x1, y1, z1) (x2, y2, z2) and (x3, y3, z3)
area = area_3d(x1, y1, z1, x2, y2, z2, x3, y3, z3)
fop
# returns the x, y, z coordinates of the foot of perpendicular drawn from the point (x3, y3, z3) to the line joining (x1, y1, z1) and (x2, y2, z2)
xn, xd, yn, yd, zn, zd = fop(x1, y1, z1, x2, y2, z2, x3, y3, z3)
#returns numerator and denominator of the coordinates
gcd
# returns the HCF(highest common factor) or GCD( Greatest common divisor) {both meaning the same} of two numbers
hcf = gcd(a, b)
intersect
# returns the x, y, z, x(as fraction), y(as fraction), z(as fraction) coordinates of the point of intersection of two lines,
# line 1: x-x1/(a1n/a1d) = y-y1/(b1n/b1d) = z-z1/(c1n/c1d)
# line 2: x-x2/(a2n/a2d) = y-y/2(b2n/b2d) = z-z2/(c2n/c2d)
xn, xd, yn, yd, zn, zd = intersect(x1, y1, z1, x2, y2, z2, x3, y3, z3)
iscollinear
# returns whether the three points in 2d space are collinear or not
value = iscollinear(x1, y1, x2, y2, x3, y3)
# returns True if collinear and False if not
iscollinear_3d
# returns whether the three points in 3d space are collinear or not
value = iscollinear_3d(x1, y1, z1, x2, y2, z2, x3, y3, z3)
# returns True if collinear and False if not
perimeter_2d
#returns perimeter of triangle with vertices (x1, y1) (x2, y2) and (x3, y3)
peri = peri_2d(x1, y1, x2, y2, x3, y3)
perimeter_3d
#yreturns perimeter of triangle in 3d space with vertices (x1, y1, z1) (x2, y2, z2) and (x3, y3, z3)
peri = perimeter_3d(x1, y1, z1, x2, y2, z2, x3, y3, z3)
Centres
Centroid_2d
# Centroid_2d(x1, y1, x2, y2, x3, y3)
a = utnamgeo.Centroid_2d(0, 2, 3, 7, 6, 3)
print("x coordinate:", a.x)
print("y coordinate:", a.y)
Output:
x coordinate: 3
y coordinate: 4
Centroid_3d
# Centroid_3d(x1, y1, z1, x2, y2, z2, x3, y3, z3)
a = utnamgeo.Centroid_3d(0, 2, 11, 3, 7, 4, 6, 3, 6)
print("x coordinate:", a.x)
print("y coordinate:", a.y)
print("z coordinate:", a.z)
Output:
x coordinate: 3
y coordinate: 4
z coordinate: 7
Circumcentre_2d
# Circumcentre_2d(x1, y1, x2, y2, x3, y3)
a = utnamgeo.Circumcentre_2d(2, -5, 2, 7, 14, -5)
print("x coordinate:", a.x)
print("y coordinate:", a.y)
Output:
x coordinate: 8
y coordinate: 1
Circumcentre_3d
# Circumcentre_3d(x1, y1, z1, x2, y2, z2, x3, y3, z3)
a = utnamgeo.Circumcentre_3d(2, -5, -3, 2, 7, -3, 14, -5, 6)
print("x coordinate:", a.x)
print("y coordinate:", a.y)
print("z coordinate:", a.z)
Output:
x coordinate: 8
y coordinate: 1
z coordinate: 5
Excentre_2d
# Excentre_2d(x1, y1, x2, y2, x3, y3)
a = utnamgeo.Excentre_2d(2, -5, 2, 7, 14, -5)
print("x coordinate:", a.xa)
print("y coordinate:", a.ya)
Output:
x coordinate: 5.11625...
y coordinate: -1.1046...
Excentre_3d
# Excentre_3d(x1, y1, z1, x2, y2, z2, x3, y3, z3)
a = utnamgeo.Excentre_3d(2, -5, -3, 2, 7, -3, 14, -5, 6)
print("x coordinate:", a.xa)
print("y coordinate:", a.ya)
print("z coordinate:", a.za)
Output:
x coordinate: 5.11625...
y coordinate: -1.1046...
z coordinate: -0.6628...
Incentre_2d
# Incentre_2d(x1, y1, x2, y2, x3, y3)
a = utnamgeo.Incentre_2d(2,-5,2,7,14,-5)
print("x coordinate:", a.x)
print("y coordinate:", a.y)
Output:
x coordinate: 5.1162...
y coordinate: -1.1046...
z coordinate: -0.6628...
Incentre_3d
# Incentre_3d(x1, y1, z1, x2, y2, z2, x3, y3, z3)
a = utnamgeo.Incentre_3d(2, -5, -3, 2, 7, -3, 14, -5, 6)
print("x coordinate:", a.x)
print("y coordinate:", a.y)
print("z coordinate:", a.z)
print("In-radius: ", a.radius)
Output:
x coordinate: 5.1162...
y coordinate: -1.1046...
z coordinate: -0.6628...
In-radius: 3.8953...
Orthocentre_2d
# Orthocentre_2d(x1, y1, x2, y2, x3, y3)
a = utnamgeo.Orthocentre_2d(2,5,2,8,14,5)
print("x coordinate:", a.x)
print("y coordinate:", a.y)
Output:
x coordinate: 2
y coordinate: 5
Orthocentre_3d
# Orthocentre_3d(x1, y1, z1, x2, y2, z2, x3, y3, z3)
a = utnamgeo.Orthocentre_3d(2, -5, -3, 2, 7, -3, 14, -5, 6)
print("x coordinate:", a.x)
print("y coordinate:", a.y)
print("z coordinate:", a.z)
Output:
x coordinate: 2
y coordinate: -5
z coordinate: -3
▶️ Package's YouTube tutorial here
Change Log
0.0.2 (17/06/2023)
- Fixed Circumcentre_3d function
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
utnamgeo-0.0.3.tar.gz
(8.7 kB
view details)
Built Distribution
File details
Details for the file utnamgeo-0.0.3.tar.gz
.
File metadata
- Download URL: utnamgeo-0.0.3.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cded8695a092c5a387cf84df5721fe58000d58075763327b972d8ca95653140a |
|
MD5 | f681e988d80d81e665bee57833e2ce60 |
|
BLAKE2b-256 | 64104b3c51ffcbe9d67dd6021ce1bcabfc7a7417e7c741ee1af6338c490f9912 |
File details
Details for the file utnamgeo-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: utnamgeo-0.0.3-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0e070bf8f42a8bb4cde8fe98c9bd5daa703ef02773c7903b6771b9f56563033 |
|
MD5 | a7cb6e88e3a5fa5913661539c03de921 |
|
BLAKE2b-256 | 8749356e3c6af73f87d904468f8eaf5a08a2fc22b37ba563c7506960711bad94 |