-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMatrix_array.py
53 lines (41 loc) · 1.76 KB
/
Matrix_array.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import numpy as np
class Matrix_array:
def __init__(self,r_a,element_distance,row_elements,column_elements):
#
# Generates coordinates for a 2D array. Uni_distance is the uniform distance between the
# array-elements.
#
# r_a is the vector pointing to the middle of the array
#
#
#
# r_prime is a vector on the form
# x_1 x_2 ... x_n
# r_prime = y_1 y_2 ... y_n, where n = rows*columns
# z_1 z_2 ... z_n
#
self.__row_elements = row_elements
self.__column_elements = column_elements
self.__uni_distance = element_distance
self.__elements = row_elements * column_elements
self.__r_prime = np.zeros((3,self.__elements))
# place all microphone elements at the right position
element_index = 0
for i in range(row_elements):
for j in range(column_elements):
self.__r_prime[0,element_index] = i*self.__uni_distance + r_a[0]
self.__r_prime[1,element_index] = j*self.__uni_distance + r_a[1]
element_index += 1
# center matrix in origin (0,0)
self.__r_prime[0,:] = self.__r_prime[0,:] - self.__row_elements*self.__uni_distance/2 + self.__uni_distance/2
self.__r_prime[1,:] = self.__r_prime[1,:] - self.__column_elements*self.__uni_distance/2 + self.__uni_distance/2
def get_r_prime(self):
return self.__r_prime
def get_uni_distance(self):
return self.__uni_distance
def get_elements(self):
return self.__elements
def get_row_elements(self):
return self.__row_elements
def get_column_elements(self):
return self.__column_elements