-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmat.py
More file actions
24 lines (20 loc) · 703 Bytes
/
mat.py
File metadata and controls
24 lines (20 loc) · 703 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#
# biblioteka za 2d geometriju
#
import math
def pomeriTacku(A, B, d):
''' Vraca koordinate tacke koja je pomerana od tacke A do tacke B duz prave koje ove dve tacke cine '''
alpha = math.atan2(B[1]-A[1], B[0]-A[0])
ax = d*math.cos(alpha)
ay = d*math.sin(alpha)
return (A[0]+ax, A[1]+ay)
def dist(A, B):
''' Udaljenost izmedju tacaka'''
return ( (A[0]-B[0])**2 + (A[1]-B[1])**2 )**0.5
def nadjiCentar(A, B):
''' Vraca koordinate tacke koja je u centru duzi [AB] '''
return pomeriTacku(A,B,dist(A,B)/2)
def nadjiNormalu(A, B, d):
alpha = math.atan2(B[1]-A[1],B[0]-A[0])
beta = math.pi/2 - alpha
return (A[0] + d*math.cos(beta), A[1]-d*math.sin(beta) )