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 #include <vector> |
16 | 16 |
17 namespace webrtc { | 17 namespace webrtc { |
18 | 18 |
19 // Coordinates in meters. | 19 // Coordinates in meters. The convention used is: |
20 // x: the horizontal dimension, with positive to the right from the camera's | |
21 // perspective. | |
22 // y: the depth dimension, with positive forward from the camera's | |
23 // perspective. | |
24 // z: the vertical dimension, with positive upwards. | |
20 template<typename T> | 25 template<typename T> |
21 struct CartesianPoint { | 26 struct CartesianPoint { |
22 CartesianPoint(T x, T y, T z) { | 27 CartesianPoint(T x, T y, T z) { |
23 c[0] = x; | 28 c[0] = x; |
24 c[1] = y; | 29 c[1] = y; |
25 c[2] = z; | 30 c[2] = z; |
26 } | 31 } |
27 T x() const { return c[0]; } | 32 T x() const { return c[0]; } |
28 T y() const { return c[1]; } | 33 T y() const { return c[1]; } |
29 T z() const { return c[2]; } | 34 T z() const { return c[2]; } |
30 T c[3]; | 35 T c[3]; |
31 }; | 36 }; |
32 | 37 |
33 using Point = CartesianPoint<float>; | 38 using Point = CartesianPoint<float>; |
34 | 39 |
35 float GetMinimumSpacing(const std::vector<Point>& array_geometry); | 40 float GetMinimumSpacing(const std::vector<Point>& array_geometry); |
36 | 41 |
37 template<typename T> | 42 template<typename T> |
38 float Distance(CartesianPoint<T> a, CartesianPoint<T> b) { | 43 float Distance(CartesianPoint<T> a, CartesianPoint<T> b) { |
39 return std::sqrt((a.x() - b.x()) * (a.x() - b.x()) + | 44 return std::sqrt((a.x() - b.x()) * (a.x() - b.x()) + |
40 (a.y() - b.y()) * (a.y() - b.y()) + | 45 (a.y() - b.y()) * (a.y() - b.y()) + |
41 (a.z() - b.z()) * (a.z() - b.z())); | 46 (a.z() - b.z()) * (a.z() - b.z())); |
42 } | 47 } |
43 | 48 |
49 // The convention used: | |
50 // azimuth: Zero is to the right from the camera's perspective, with positive | |
Andrew MacDonald
2015/10/20 03:00:08
nit: to be consistent with above, no capitalizatio
aluebs-webrtc
2015/10/21 01:41:40
Done.
| |
51 // angles in radians towards the front of the camera. | |
Andrew MacDonald
2015/10/20 03:00:08
with positive angles counter-clockwise.
aluebs-webrtc
2015/10/21 01:41:40
My only concern with using "counter-clockwise" is
Andrew MacDonald
2015/10/21 22:59:46
Right. Another option is to define these in terms
| |
52 // elevation: Zero is horizontal, with positive angles in radians upwards. | |
53 // radius: Distance from the camera in meters. | |
44 template <typename T> | 54 template <typename T> |
45 struct SphericalPoint { | 55 struct SphericalPoint { |
46 SphericalPoint(T azimuth, T elevation, T radius) { | 56 SphericalPoint(T azimuth, T elevation, T radius) { |
47 s[0] = azimuth; | 57 s[0] = azimuth; |
48 s[1] = elevation; | 58 s[1] = elevation; |
49 s[2] = radius; | 59 s[2] = radius; |
50 } | 60 } |
51 T azimuth() const { return s[0]; } | 61 T azimuth() const { return s[0]; } |
52 T elevation() const { return s[1]; } | 62 T elevation() const { return s[1]; } |
53 T distance() const { return s[2]; } | 63 T distance() const { return s[2]; } |
54 T s[3]; | 64 T s[3]; |
55 }; | 65 }; |
56 | 66 |
57 using SphericalPointf = SphericalPoint<float>; | 67 using SphericalPointf = SphericalPoint<float>; |
58 | 68 |
59 } // namespace webrtc | 69 } // namespace webrtc |
60 | 70 |
61 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_BEAMFORMER_ARRAY_UTIL_H_ | 71 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_BEAMFORMER_ARRAY_UTIL_H_ |
OLD | NEW |