Skip to content

Commit 5cc14b0

Browse files
authored
PR #12731 from Eran: WTLAL (float3) move to rsutils
2 parents 20eaa4d + c58b204 commit 5cc14b0

37 files changed

Lines changed: 435 additions & 289 deletions

common/calibration-model.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ void calibration_model::draw_float(std::string name, float& x, const float& orig
3838
ImGui::PopStyleColor();
3939
}
4040

41-
void calibration_model::draw_float4x4(std::string name, librealsense::float3x3& feild,
42-
const librealsense::float3x3& original, bool& changed)
41+
void calibration_model::draw_float4x4(std::string name, float3x3& feild,
42+
const float3x3& original, bool& changed)
4343
{
4444
ImGui::SetCursorPosX(10);
4545
ImGui::Text("%s:", name.c_str()); ImGui::SameLine();

common/calibration-model.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
// 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.
43
#pragma once
54

65
#include <librealsense2/rs.hpp>
76
#include "notifications.h"
7+
#include <rsutils/number/float3.h>
88

9-
namespace librealsense
10-
{
11-
struct float3x3;
12-
}
139

1410
namespace rs2
1511
{
1612
class ux_window;
1713

1814
class calibration_model
1915
{
16+
using float3x3 = rsutils::number::float3x3;
17+
2018
public:
2119
calibration_model(rs2::device dev, std::shared_ptr<notifications_model> not_model);
2220

@@ -27,7 +25,7 @@ namespace rs2
2725
void open() { to_open = true; }
2826

2927
private:
30-
void draw_float4x4(std::string name, librealsense::float3x3& feild, const librealsense::float3x3& original, bool& changed);
28+
void draw_float4x4(std::string name, float3x3 & feild, const float3x3& original, bool& changed);
3129
void draw_float(std::string name, float& x, const float& orig, bool& changed);
3230

3331
rs2::device dev;

common/float2.h

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,14 @@
11
// 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.
43
#pragma once
54

6-
#include <cmath> // sqrt, sqrtf
5+
#include <rsutils/number/float3.h>
76

87

98
namespace rs2 {
109

1110

12-
struct float2
13-
{
14-
float x, y;
15-
16-
float length() const { return sqrt( x * x + y * y ); }
17-
18-
float2 normalize() const { return { x / length(), y / length() }; }
19-
};
20-
21-
inline float dot( const float2 & a, const float2 & b )
22-
{
23-
return a.x * b.x + a.y * b.y;
24-
}
11+
using rsutils::number::float2;
2512

2613

2714
} // namespace rs2

common/float3.h

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,14 @@
11
// 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.
43
#pragma once
54

6-
#include <cmath> // sqrt, sqrtf
5+
#include <rsutils/number/float3.h>
76

87

98
namespace rs2 {
109

1110

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;
4912

5013

5114
} // namespace rs2

common/measurement.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ float measurement::calculate_area(std::vector<float3> poly)
184184
auto a = poly[1] - poly[0];
185185
auto b = poly[2] - poly[0];
186186
auto n = cross(a, b);
187-
return std::abs( total * n.normalize() ) / 2;
187+
return std::abs( total * n.normalized() ) / 2;
188188
}
189189

190190
void draw_sphere(const float3& pos, float r, int lats, int longs)
@@ -461,10 +461,10 @@ void measurement::draw(ux_window& win)
461461

462462
auto axis1 = cross(vec3d{ _normal.x, _normal.y, _normal.z }, vec3d{ 0.f, 1.f, 0.f });
463463
auto faxis1 = float3 { axis1.x, axis1.y, axis1.z };
464-
faxis1.normalize();
464+
faxis1.normalized();
465465
auto axis2 = cross(vec3d{ _normal.x, _normal.y, _normal.z }, axis1);
466466
auto faxis2 = float3 { axis2.x, axis2.y, axis2.z };
467-
faxis2.normalize();
467+
faxis2.normalized();
468468

469469
matrix4 basis = matrix4::identity();
470470
basis(0, 0) = faxis1.x;

common/opengl3.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// License: Apache 2.0. See LICENSE file in root directory.
2-
// Copyright(c) 2020 Intel Corporation. All Rights Reserved.
3-
2+
// Copyright(c) 2024 Intel Corporation. All Rights Reserved.
43
#pragma once
54

65
#include "matrix4.h"
@@ -130,10 +129,6 @@ namespace rs2
130129
vbo_type _type;
131130
};
132131

133-
struct float3;
134-
struct float2;
135-
struct int3;
136-
137132
struct obj_mesh;
138133

139134
class vao

common/rect.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// 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.
43
#pragma once
54

65
#include "float2.h"
76

87
#include <algorithm> // max,min
8+
#include <cmath> // floor
99

1010

1111
namespace rs2 {

common/rendering.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ namespace rs2
160160
auto p2 = p[(i+1) % p.size()];
161161
if ((p2 - p1).length() < 1e-3) return false;
162162

163-
p1 = p1.normalize();
164-
p2 = p2.normalize();
163+
p1 = p1.normalized();
164+
p2 = p2.normalized();
165165

166166
angles.push_back(acos((p1 * p2) / sqrt(p1.length() * p2.length())));
167167
}

common/viewer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1414,7 +1414,7 @@ namespace rs2
14141414
// up = cross(cross(look, world_up), look)
14151415
{
14161416
float3 look = { target.x - pos.x, target.y - pos.y, target.z - pos.z };
1417-
look = look.normalize();
1417+
look = look.normalized();
14181418

14191419
float world_up[3] = { 0.0f, 1.0f, 0.0f };
14201420

src/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ target_sources(${LRS_TARGET}
132132
"${CMAKE_CURRENT_LIST_DIR}/device_hub.h"
133133
"${CMAKE_CURRENT_LIST_DIR}/environment.h"
134134
"${CMAKE_CURRENT_LIST_DIR}/firmware-version.h"
135+
"${CMAKE_CURRENT_LIST_DIR}/float3.h"
135136
"${CMAKE_CURRENT_LIST_DIR}/fourcc.h"
136137
"${CMAKE_CURRENT_LIST_DIR}/log.h"
137138
"${CMAKE_CURRENT_LIST_DIR}/error-handling.h"
@@ -146,6 +147,7 @@ target_sources(${LRS_TARGET}
146147
"${CMAKE_CURRENT_LIST_DIR}/metadata-parser.h"
147148
"${CMAKE_CURRENT_LIST_DIR}/option.h"
148149
"${CMAKE_CURRENT_LIST_DIR}/platform-camera.h"
150+
"${CMAKE_CURRENT_LIST_DIR}/pose.h"
149151
"${CMAKE_CURRENT_LIST_DIR}/sensor.h"
150152
"${CMAKE_CURRENT_LIST_DIR}/hid-sensor.h"
151153
"${CMAKE_CURRENT_LIST_DIR}/uvc-sensor.h"

0 commit comments

Comments
 (0)