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 float GetMinimumSpacing(const std::vector<Point>& array_geometry); | |
Andrew MacDonald
2015/10/19 22:35:07
Add a comment.
aluebs-webrtc
2015/10/20 00:17:07
Done.
| |
36 | |
34 template<typename T> | 37 template<typename T> |
35 float Distance(CartesianPoint<T> a, CartesianPoint<T> b) { | 38 float Distance(CartesianPoint<T> a, CartesianPoint<T> b) { |
36 return std::sqrt((a.x() - b.x()) * (a.x() - b.x()) + | 39 return std::sqrt((a.x() - b.x()) * (a.x() - b.x()) + |
37 (a.y() - b.y()) * (a.y() - b.y()) + | 40 (a.y() - b.y()) * (a.y() - b.y()) + |
38 (a.z() - b.z()) * (a.z() - b.z())); | 41 (a.z() - b.z()) * (a.z() - b.z())); |
39 } | 42 } |
40 | 43 |
41 template <typename T> | 44 template <typename T> |
42 struct SphericalPoint { | 45 struct SphericalPoint { |
43 SphericalPoint(T azimuth, T elevation, T radius) { | 46 SphericalPoint(T azimuth, T elevation, T radius) { |
44 s[0] = azimuth; | 47 s[0] = azimuth; |
45 s[1] = elevation; | 48 s[1] = elevation; |
46 s[2] = radius; | 49 s[2] = radius; |
47 } | 50 } |
48 T azimuth() const { return s[0]; } | 51 T azimuth() const { return s[0]; } |
49 T elevation() const { return s[1]; } | 52 T elevation() const { return s[1]; } |
50 T distance() const { return s[2]; } | 53 T distance() const { return s[2]; } |
51 T s[3]; | 54 T s[3]; |
52 }; | 55 }; |
53 | 56 |
54 using SphericalPointf = SphericalPoint<float>; | 57 using SphericalPointf = SphericalPoint<float>; |
55 | 58 |
56 } // namespace webrtc | 59 } // namespace webrtc |
57 | 60 |
58 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_BEAMFORMER_ARRAY_UTIL_H_ | 61 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_BEAMFORMER_ARRAY_UTIL_H_ |
OLD | NEW |