Example usage

Here we show you how to use CoordGeomPy functions in a project. The package contains four functions that help with different geometric calculations.

Imports

from coordgeompy.coordgeompy import dist_pll_lines_2d
from coordgeompy.coordgeompy import get_distance
from coordgeompy.coordgeompy import is_intersection_3d
from coordgeompy.coordgeompy import is_orthogonal

Finding distance between two parallel lines dist_pll_lines_2d

This function will help a user find distance between two parallel lines with equation y = mx + b. The function requires three inputs: m (slope), b1 and b2 (intercepts from line 1 and line 2 respectively).
Note: Two parallel lines will have the same slope m.

m = 2
b1 = 4
b2 = -1
dist_pll_lines_2d(m, b1, b2)
2.23606797749979
m = 3.0
b1 = 4.5
b2 = 2.5
dist_pll_lines_2d(m, b1, b2)
0.6324555320336759

Finding distance between two parallel lines get_distance

This function allows a user to calculate the the distance between two n dimensional vectors. Possible metrics that can be used with this function includes: Euclidean, Manhattan, Chebyshev, or Minkowski

x1 = [1, 2, 3, 4]
x2 = [5, 6, 7, 8]
get_distance(x1, x2, metric="Euclidean")
8.0
get_distance(x1, x2, metric="Manhattan")
16

Finding distance between two parallel lines is_intersection_3d

This function determines whether two infinite lines intersect in 3-dimensional space. Note that if two parallel lines are provided, they will be considered as NOT intersecting. Also note that this function expects integer values for x, y, z coordinates. Values will be rounded if integer values are not provided.

m1 = (1, 0, 0)
m2 = (0, 1, 0)
b1 = (0, 0, 0)
b2 = (0, 0, 0)
is_intersection_3d(m1, b1, m2, b2)
True
m3 = (1, 3, -1)
m4 = (2, 1, 4)
b3 = (0, -2, 4)
b4 = (0, 3, -3)
is_intersection_3d(m3, m4, b3, b4)
False

Finding distance between two parallel lines is_orthogonal

This function determines whether whether two infinite lines are perpendicular in n-dimensional space.

m1 = (1, 0)
m2 = (0, 1)
is_orthogonal(m1, m2)
True
m3 = (0, 0, 1)
m4 = (1, 1, 1)
is_orthogonal(m3, m4)
False