Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(238)

Side by Side Diff: webrtc/modules/audio_processing/beamformer/array_util.h

Issue 1211703002: Created SphericalPoint in array_util.h (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Changed distance to radius Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 { return c[0]; }
27 return c[0]; 27 T y() const { return c[1]; }
28 } 28 T z() const { return c[2]; }
29 T y() const {
30 return c[1];
31 }
32 T z() const {
33 return c[2];
34 }
35 T c[3]; 29 T c[3];
36 }; 30 };
37 31
38 typedef CartesianPoint<float> Point; 32 using Point = CartesianPoint<float>;
39 33
40 template<typename T> 34 template<typename T>
41 float Distance(CartesianPoint<T> a, CartesianPoint<T> b) { 35 float Distance(CartesianPoint<T> a, CartesianPoint<T> b) {
42 return std::sqrt((a.x() - b.x()) * (a.x() - b.x()) + 36 return std::sqrt((a.x() - b.x()) * (a.x() - b.x()) +
43 (a.y() - b.y()) * (a.y() - b.y()) + 37 (a.y() - b.y()) * (a.y() - b.y()) +
44 (a.z() - b.z()) * (a.z() - b.z())); 38 (a.z() - b.z()) * (a.z() - b.z()));
45 } 39 }
46 40
41 template <typename T>
42 struct SphericalPoint {
43 SphericalPoint(T azimuth, T elevation, T radius) {
44 s[0] = azimuth;
45 s[1] = elevation;
46 s[2] = radius;
47 }
48 T azimuth() const { return s[0]; }
49 T elevation() const { return s[1]; }
50 T distance() const { return s[2]; }
51 T s[3];
52 };
53
54 using SphericalPointf = SphericalPoint<float>;
55
47 } // namespace webrtc 56 } // namespace webrtc
48 57
49 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_BEAMFORMER_ARRAY_UTIL_H_ 58 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_BEAMFORMER_ARRAY_UTIL_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698