Chromium Code Reviews| 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 | 15 |
| 16 namespace webrtc { | 16 namespace webrtc { |
| 17 | 17 |
| 18 // Coordinates in meters. | 18 // Coordinates in meters. |
| 19 template<typename T> | 19 template<typename T> |
| 20 struct CartesianPoint { | 20 struct CartesianPoint { |
| 21 CartesianPoint(T x, T y, T z) { | 21 CartesianPoint(T x, T y, T z) { |
| 22 c[0] = x; | 22 c[0] = x; |
| 23 c[1] = y; | 23 c[1] = y; |
| 24 c[2] = z; | 24 c[2] = z; |
| 25 } | 25 } |
| 26 T x() const { | 26 T x() const { |
|
Andrew MacDonald
2015/06/25 01:32:31
Put these methods all on one line to be consistent
| |
| 27 return c[0]; | 27 return c[0]; |
| 28 } | 28 } |
| 29 T y() const { | 29 T y() const { |
| 30 return c[1]; | 30 return c[1]; |
| 31 } | 31 } |
| 32 T z() const { | 32 T z() const { |
| 33 return c[2]; | 33 return c[2]; |
| 34 } | 34 } |
| 35 T c[3]; | 35 T c[3]; |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 typedef CartesianPoint<float> Point; | 38 using Point = CartesianPoint<float>; |
| 39 | 39 |
| 40 template<typename T> | 40 template<typename T> |
| 41 float Distance(CartesianPoint<T> a, CartesianPoint<T> b) { | 41 float Distance(CartesianPoint<T> a, CartesianPoint<T> b) { |
| 42 return std::sqrt((a.x() - b.x()) * (a.x() - b.x()) + | 42 return std::sqrt((a.x() - b.x()) * (a.x() - b.x()) + |
| 43 (a.y() - b.y()) * (a.y() - b.y()) + | 43 (a.y() - b.y()) * (a.y() - b.y()) + |
| 44 (a.z() - b.z()) * (a.z() - b.z())); | 44 (a.z() - b.z()) * (a.z() - b.z())); |
| 45 } | 45 } |
| 46 | 46 |
| 47 template <typename T> | |
| 48 struct SphericalPoint { | |
| 49 SphericalPoint(T azimuth, T elevation, T distance) { | |
|
Andrew MacDonald
2015/06/25 01:32:31
Michael used radius rather than distance elsewhere
| |
| 50 s[0] = azimuth; | |
| 51 s[1] = elevation; | |
| 52 s[2] = distance; | |
| 53 } | |
| 54 T azimuth() const { return s[0]; } | |
| 55 T elevation() const { return s[1]; } | |
| 56 T distance() const { return s[2]; } | |
| 57 T s[3]; | |
| 58 }; | |
| 59 | |
| 60 using SphericalPointf = SphericalPoint<float>; | |
|
Andrew MacDonald
2015/06/25 01:32:31
Just "using SphericalPoint" to be consistent with
| |
| 61 | |
| 47 } // namespace webrtc | 62 } // namespace webrtc |
| 48 | 63 |
| 49 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_BEAMFORMER_ARRAY_UTIL_H_ | 64 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_BEAMFORMER_ARRAY_UTIL_H_ |
| OLD | NEW |