Panda3D
Loading...
Searching...
No Matches
Macros | Functions
nearly_zero.h File Reference

PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University. More...

#include "dtoolbase.h"

Go to the source code of this file.

Macros

#define IS_NEARLY_EQUAL(value1, value2)    (IS_THRESHOLD_EQUAL(value1, value2, get_nearly_zero_value(value1)))
 
#define IS_NEARLY_ZERO(value)    (IS_THRESHOLD_ZERO(value, get_nearly_zero_value(value)))
 
#define IS_THRESHOLD_COMPEQ(value1, value2, threshold)    (cfloor(value1 / threshold + 0.5f) == cfloor(value2 / threshold + 0.5f))
 
#define IS_THRESHOLD_EQUAL(value1, value2, threshold)    (IS_THRESHOLD_ZERO((value1) - (value2), threshold))
 
#define IS_THRESHOLD_ZERO(value, threshold)    ((value) < (threshold) && (value) > -(threshold))
 
#define MAYBE_ZERO(value)    (IS_NEARLY_ZERO(value) ? 0 : (value))
 
#define NEARLY_ZERO(FLOATTYPE)   (get_nearly_zero_value((FLOATTYPE)0))
 

Functions

constexpr double get_nearly_zero_value (double)
 
constexpr float get_nearly_zero_value (float)
 
constexpr int get_nearly_zero_value (int)
 

Detailed Description

PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.

All rights reserved.

All use of this software is subject to the terms of the revised BSD license. You should have received a copy of this license along with this source code in a file named "LICENSE."

Author
drose
Date
2000-03-08

Definition in file nearly_zero.h.

Macro Definition Documentation

◆ IS_NEARLY_EQUAL

#define IS_NEARLY_EQUAL ( value1,
value2 )    (IS_THRESHOLD_EQUAL(value1, value2, get_nearly_zero_value(value1)))

Definition at line 73 of file nearly_zero.h.

◆ IS_NEARLY_ZERO

#define IS_NEARLY_ZERO ( value)     (IS_THRESHOLD_ZERO(value, get_nearly_zero_value(value)))

Definition at line 68 of file nearly_zero.h.

◆ IS_THRESHOLD_COMPEQ

#define IS_THRESHOLD_COMPEQ ( value1,
value2,
threshold )    (cfloor(value1 / threshold + 0.5f) == cfloor(value2 / threshold + 0.5f))

Definition at line 59 of file nearly_zero.h.

◆ IS_THRESHOLD_EQUAL

#define IS_THRESHOLD_EQUAL ( value1,
value2,
threshold )    (IS_THRESHOLD_ZERO((value1) - (value2), threshold))

Definition at line 52 of file nearly_zero.h.

◆ IS_THRESHOLD_ZERO

#define IS_THRESHOLD_ZERO ( value,
threshold )    ((value) < (threshold) && (value) > -(threshold))

Definition at line 47 of file nearly_zero.h.

◆ MAYBE_ZERO

#define MAYBE_ZERO ( value)     (IS_NEARLY_ZERO(value) ? 0 : (value))

Definition at line 79 of file nearly_zero.h.

◆ NEARLY_ZERO

#define NEARLY_ZERO ( FLOATTYPE)    (get_nearly_zero_value((FLOATTYPE)0))

Definition at line 65 of file nearly_zero.h.

Function Documentation

◆ get_nearly_zero_value() [1/3]

constexpr double get_nearly_zero_value ( double )
constexpr

Definition at line 28 of file nearly_zero.h.

◆ get_nearly_zero_value() [2/3]

constexpr float get_nearly_zero_value ( float )
constexpr

Definition at line 33 of file nearly_zero.h.

◆ get_nearly_zero_value() [3/3]

constexpr int get_nearly_zero_value ( int )
constexpr

Definition at line 38 of file nearly_zero.h.