ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
CVMath.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
14 
15 #include "CVConst.h"
16 
17 namespace cloudViewer {
19 
23 inline bool LessThanEpsilon(float x) { return x < ZERO_TOLERANCE_F; }
24 
26 
30 inline bool LessThanEpsilon(double x) { return x < ZERO_TOLERANCE_D; }
31 
33 
37 inline bool GreaterThanEpsilon(float x) { return x > ZERO_TOLERANCE_F; }
38 
40 
44 inline bool GreaterThanEpsilon(double x) { return x > ZERO_TOLERANCE_D; }
45 
48 
52 inline bool GreaterThanSquareEpsilon(double x) {
53  return x > ZERO_SQUARED_TOLERANCE_D;
54 }
55 
58 
62 inline bool LessThanSquareEpsilon(double x) {
63  return x < ZERO_SQUARED_TOLERANCE_D;
64 }
65 
67 
71 inline float RadiansToDegrees(int radians) {
72  return static_cast<float>(radians) * (180.0f / static_cast<float>(M_PI));
73 }
74 
76 
80 inline float RadiansToDegrees(float radians) {
81  return radians * (180.0f / static_cast<float>(M_PI));
82 }
83 
85 
89 inline double RadiansToDegrees(double radians) {
90  return radians * (180.0 / M_PI);
91 }
92 
94 
98 inline float DegreesToRadians(int degrees) {
99  return static_cast<float>(degrees) * (static_cast<float>(M_PI) / 180.0f);
100 }
101 
103 
107 inline float DegreesToRadians(float degrees) {
108  return degrees * (static_cast<float>(M_PI) / 180.0f);
109 }
110 
112 
116 inline double DegreesToRadians(double degrees) {
117  return degrees * (M_PI / 180.0);
118 }
119 } // namespace cloudViewer
constexpr float ZERO_TOLERANCE_F
Definition: CVConst.h:43
constexpr double M_PI
Pi.
Definition: CVConst.h:19
constexpr double ZERO_SQUARED_TOLERANCE_D
Definition: CVConst.h:53
constexpr double ZERO_TOLERANCE_D
Definition: CVConst.h:49
Generic file read and write utility for python interface.
float RadiansToDegrees(int radians)
Convert radians to degrees.
Definition: CVMath.h:71
bool GreaterThanEpsilon(float x)
Test a floating point number against our epsilon (a very small number).
Definition: CVMath.h:37
bool LessThanSquareEpsilon(double x)
Definition: CVMath.h:62
bool GreaterThanSquareEpsilon(double x)
Definition: CVMath.h:52
float DegreesToRadians(int degrees)
Convert degrees to radians.
Definition: CVMath.h:98
bool LessThanEpsilon(float x)
Test a floating point number against our epsilon (a very small number).
Definition: CVMath.h:23