@reagentx/

Point of View

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
def point(a, b):
    p = lambda : (a, b)
    p.x = a
    p.y = b
    return p
def fst(pt):
    return pt.x
def snd(pt):
    return pt.y
def sqr_dist(pt1, pt2):
    x1, y1 = fst(pt1), snd(pt1)
    x2, y2 = fst(pt2), snd(pt2)
    return ((x2 - x1) ** 2 + (y2 - y1) ** 2)
def line(pt1, pt2):
    x1, y1 = fst(pt1), snd(pt1)
    x2, y2 = fst(pt2), snd(pt2)
    # m = (y2 - y1) / (x2 - x1)
    # b = y1 - (m * x1)
    l = y1 - y2
    m = x2 - x1
    n = x1 * y2 - x2 * y1
    return [l, m, n]


foo = point(3, 5)
print(fst(foo))
print(snd(foo))
print(sqr_dist(point(22, 55), point(75, 66)))
print(line(point(20, 22), point(29, 10)))