|
1 | 1 | // License: Apache 2.0. See LICENSE file in root directory. |
2 | | -// Copyright(c) 2021 Intel Corporation. All Rights Reserved. |
3 | | - |
| 2 | +// Copyright(c) 2024 Intel Corporation. All Rights Reserved. |
4 | 3 | #pragma once |
5 | 4 |
|
6 | | -#include <cmath> // sqrt, sqrtf |
| 5 | +#include <rsutils/number/float3.h> |
7 | 6 |
|
8 | 7 |
|
9 | 8 | namespace rs2 { |
10 | 9 |
|
11 | 10 |
|
12 | | -struct float3 |
13 | | -{ |
14 | | - float x, y, z; |
15 | | - |
16 | | - float length() const { return sqrt( x * x + y * y + z * z ); } |
17 | | - |
18 | | - float3 normalize() const { return ( length() > 0 ) ? float3{ x / length(), y / length(), z / length() } : *this; } |
19 | | -}; |
20 | | - |
21 | | -inline float3 cross( const float3 & a, const float3 & b ) |
22 | | -{ |
23 | | - return { a.y * b.z - b.y * a.z, a.x * b.z - b.x * a.z, a.x * b.y - a.y * b.x }; |
24 | | -} |
25 | | - |
26 | | -inline float operator*(const float3& a, const float3& b) { |
27 | | - return a.x * b.x + a.y * b.y + a.z * b.z; |
28 | | -} |
29 | | - |
30 | | -inline float3 operator*( const float3 & a, float t ) |
31 | | -{ |
32 | | - return { a.x * t, a.y * t, a.z * t }; |
33 | | -} |
34 | | - |
35 | | -inline float3 operator/( const float3 & a, float t ) |
36 | | -{ |
37 | | - return { a.x / t, a.y / t, a.z / t }; |
38 | | -} |
39 | | - |
40 | | -inline float3 operator+( const float3 & a, const float3 & b ) |
41 | | -{ |
42 | | - return { a.x + b.x, a.y + b.y, a.z + b.z }; |
43 | | -} |
44 | | - |
45 | | -inline float3 operator-( const float3 & a, const float3 & b ) |
46 | | -{ |
47 | | - return { a.x - b.x, a.y - b.y, a.z - b.z }; |
48 | | -} |
| 11 | +using rsutils::number::float3; |
49 | 12 |
|
50 | 13 |
|
51 | 14 | } // namespace rs2 |
0 commit comments