OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_BEAMFORMER_ARRAY_UTIL_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_BEAMFORMER_ARRAY_UTIL_H_ |
12 #define WEBRTC_MODULES_AUDIO_PROCESSING_BEAMFORMER_ARRAY_UTIL_H_ | 12 #define WEBRTC_MODULES_AUDIO_PROCESSING_BEAMFORMER_ARRAY_UTIL_H_ |
13 | 13 |
14 #include <cmath> | 14 #include <cmath> |
| 15 #include <vector> |
15 | 16 |
16 namespace webrtc { | 17 namespace webrtc { |
17 | 18 |
18 // Coordinates in meters. | 19 // Coordinates in meters. |
19 template<typename T> | 20 template<typename T> |
20 struct CartesianPoint { | 21 struct CartesianPoint { |
21 CartesianPoint(T x, T y, T z) { | 22 CartesianPoint(T x, T y, T z) { |
22 c[0] = x; | 23 c[0] = x; |
23 c[1] = y; | 24 c[1] = y; |
24 c[2] = z; | 25 c[2] = z; |
25 } | 26 } |
26 T x() const { return c[0]; } | 27 T x() const { return c[0]; } |
27 T y() const { return c[1]; } | 28 T y() const { return c[1]; } |
28 T z() const { return c[2]; } | 29 T z() const { return c[2]; } |
29 T c[3]; | 30 T c[3]; |
30 }; | 31 }; |
31 | 32 |
32 using Point = CartesianPoint<float>; | 33 using Point = CartesianPoint<float>; |
33 | 34 |
| 35 // Returns the minimum distance between any two Points in the given |
| 36 // |array_geometry|. |
| 37 float GetMinimumSpacing(const std::vector<Point>& array_geometry); |
| 38 |
34 template<typename T> | 39 template<typename T> |
35 float Distance(CartesianPoint<T> a, CartesianPoint<T> b) { | 40 float Distance(CartesianPoint<T> a, CartesianPoint<T> b) { |
36 return std::sqrt((a.x() - b.x()) * (a.x() - b.x()) + | 41 return std::sqrt((a.x() - b.x()) * (a.x() - b.x()) + |
37 (a.y() - b.y()) * (a.y() - b.y()) + | 42 (a.y() - b.y()) * (a.y() - b.y()) + |
38 (a.z() - b.z()) * (a.z() - b.z())); | 43 (a.z() - b.z()) * (a.z() - b.z())); |
39 } | 44 } |
40 | 45 |
41 template <typename T> | 46 template <typename T> |
42 struct SphericalPoint { | 47 struct SphericalPoint { |
43 SphericalPoint(T azimuth, T elevation, T radius) { | 48 SphericalPoint(T azimuth, T elevation, T radius) { |
44 s[0] = azimuth; | 49 s[0] = azimuth; |
45 s[1] = elevation; | 50 s[1] = elevation; |
46 s[2] = radius; | 51 s[2] = radius; |
47 } | 52 } |
48 T azimuth() const { return s[0]; } | 53 T azimuth() const { return s[0]; } |
49 T elevation() const { return s[1]; } | 54 T elevation() const { return s[1]; } |
50 T distance() const { return s[2]; } | 55 T distance() const { return s[2]; } |
51 T s[3]; | 56 T s[3]; |
52 }; | 57 }; |
53 | 58 |
54 using SphericalPointf = SphericalPoint<float>; | 59 using SphericalPointf = SphericalPoint<float>; |
55 | 60 |
56 } // namespace webrtc | 61 } // namespace webrtc |
57 | 62 |
58 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_BEAMFORMER_ARRAY_UTIL_H_ | 63 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_BEAMFORMER_ARRAY_UTIL_H_ |
OLD | NEW |