Révision b4aef3d7
b/modules/screening.py | ||
---|---|---|
5 | 5 |
logger = logging.getLogger('DockOnSurf') |
6 | 6 |
|
7 | 7 |
|
8 |
def get_vect_angle(v1, v2, degrees=False): |
|
9 |
"""Computes the angle between two vectors. |
|
10 |
|
|
11 |
@param v1: The first vector. |
|
12 |
@param v2: The second vector. |
|
13 |
@param degrees: Whether the result should be in radians (True) or in |
|
14 |
degrees (False). |
|
15 |
@return: The angle in radians if degrees = False, or in degrees if |
|
16 |
degrees =True |
|
17 |
""" |
|
18 |
v1_u = v1 / np.linalg.norm(v1) |
|
19 |
v2_u = v2 / np.linalg.norm(v2) |
|
20 |
angle = np.arccos(np.clip(np.dot(v1_u, v2_u), -1.0, 1.0)) |
|
21 |
return angle if not degrees else angle * 180 / np.pi |
|
22 |
|
|
23 |
|
|
8 | 24 |
def vect_avg(vects): |
9 | 25 |
"""Computes the element-wise mean of a set of vectors. |
10 | 26 |
|
Formats disponibles : Unified diff