Blender V5.3
BLI_math_base_c.hh File Reference

Go to the source code of this file.

Namespaces

namespace  blender
 BMesh Iterators.

Macros

#define NAN_FLT   (*((float *)(&NAN_INT)))
#define BLI_ASSERT_UNIT_EPSILON   0.0002f
#define BLI_ASSERT_UNIT_EPSILON_DB   0.0002
#define BLI_ASSERT_UNIT_V3(v)
#define BLI_ASSERT_UNIT_V2(v)
#define BLI_ASSERT_UNIT_QUAT(q)
#define BLI_ASSERT_ZERO_M3(m)
#define BLI_ASSERT_ZERO_M4(m)
#define BLI_ASSERT_UNIT_M3(m)

Functions

MINLINE float blender::pow2f (float x)
MINLINE float blender::pow3f (float x)
MINLINE float blender::pow4f (float x)
MINLINE float blender::pow7f (float x)
MINLINE float blender::sqrt3f (float f)
MINLINE double blender::sqrt3d (double d)
MINLINE float blender::sqrtf_signed (float f)
MINLINE float blender::interpf (float target, float origin, float t)
MINLINE double blender::interpd (double target, double origin, double t)
MINLINE float blender::ratiof (float min, float max, float pos)
MINLINE double blender::ratiod (double min, double max, double pos)
MINLINE int blender::square_s (short a)
MINLINE int blender::square_i (int a)
MINLINE unsigned int blender::square_uint (unsigned int a)
MINLINE float blender::square_f (float a)
MINLINE int blender::cube_i (int a)
MINLINE float blender::cube_f (float a)
MINLINE float blender::min_ff (float a, float b)
MINLINE float blender::max_ff (float a, float b)
MINLINE double blender::min_dd (double a, double b)
MINLINE double blender::max_dd (double a, double b)
MINLINE int blender::min_ii (int a, int b)
MINLINE int blender::max_ii (int a, int b)
MINLINE uint blender::min_uu (uint a, uint b)
MINLINE uint blender::max_uu (uint a, uint b)
MINLINE int blender::clamp_i (int value, int min, int max)
MINLINE float blender::clamp_f (float value, float min, float max)
MINLINE int blender::compare_ff (float a, float b, float max_diff)
MINLINE uint blender::ulp_diff_ff (float a, float b)
MINLINE int blender::compare_ff_relative (float a, float b, float max_diff, int max_ulps)
MINLINE bool blender::compare_threshold_relative (float value1, float value2, float thresh)
MINLINE float blender::increment_ulp (float value)
MINLINE float blender::decrement_ulp (float value)
MINLINE float blender::signf (float f)
MINLINE int blender::signum_i_ex (float a, float eps)
MINLINE int blender::signum_i (float a)
MINLINE float blender::power_of_2 (float f)
MINLINE int blender::integer_digits_f (float f)
MINLINE int blender::integer_digits_d (double d)
MINLINE int blender::integer_digits_i (int i)
MINLINE int blender::is_power_of_2_i (int n)
MINLINE unsigned int blender::log2_floor_u (unsigned int x)
MINLINE unsigned int blender::log2_ceil_u (unsigned int x)
MINLINE int blender::power_of_2_max_i (int n)
MINLINE int blender::power_of_2_min_i (int n)
MINLINE unsigned int blender::power_of_2_max_u (unsigned int x)
MINLINE int blender::divide_round_i (int a, int b)
MINLINE uint blender::divide_ceil_u (uint a, uint b)
MINLINE uint64_t blender::divide_ceil_ul (uint64_t a, uint64_t b)
MINLINE uint blender::ceil_to_multiple_u (uint a, uint b)
MINLINE uint64_t blender::ceil_to_multiple_ul (uint64_t a, uint64_t b)
MINLINE int blender::mod_i (int i, int n)
MINLINE float blender::floored_fmod (float f, float n)
MINLINE float blender::round_to_even (float f)
MINLINE unsigned char blender::round_fl_to_uchar (float a)
MINLINE short blender::round_fl_to_short (float a)
MINLINE int blender::round_fl_to_int (float a)
MINLINE unsigned int blender::round_fl_to_uint (float a)
MINLINE int blender::round_db_to_int (double a)
MINLINE unsigned char blender::round_fl_to_uchar_clamp (float a)
MINLINE int blender::round_fl_to_int_clamp (float a)
MINLINE unsigned char blender::round_db_to_uchar_clamp (double a)
MINLINE short blender::round_db_to_short_clamp (double a)
MINLINE int blender::round_db_to_int_clamp (double a)
int blender::pow_i (int base, int exp)
double blender::double_round (double x, int ndigits)
float blender::floor_power_of_10 (float f)
float blender::ceil_power_of_10 (float f)

Variables

static const int NAN_INT = 0x7FC00000

Detailed Description

Abbreviations

  • fl = float.
  • db = double.
  • v2 = vec2 = vector 2.
  • v3 = vec3 = vector 3.
  • v4 = vec4 = vector 4.
  • vn = vec4q = vector N dimensions, passed as an arg, after the vector..
  • qt = quat = quaternion.
  • dq = dquat = dual quaternion.
  • m2 = mat2 = matrix 2x2.
  • m3 = mat3 = matrix 3x3.
  • m4 = mat4 = matrix 4x4.
  • eul = euler rotation.
  • eulO = euler with order.
  • plane = plane 4, (vec3, distance).
  • plane3 = plane 3, (same as a plane with a zero 4th component).

Function Type Abbreviations

For non float versions of functions (which typically operate on floats), use single suffix abbreviations.

  • _d = double
  • _i = int
  • _u = unsigned int
  • _char = char
  • _uchar = unsigned char

Variable Names

  • f = single value
  • a, b, c = vectors
  • r = result vector
  • A, B, C = matrices
  • R = result matrix

Definition in file BLI_math_base_c.hh.

Macro Definition Documentation

◆ BLI_ASSERT_UNIT_EPSILON

#define BLI_ASSERT_UNIT_EPSILON   0.0002f
Note
0.0001 is too small because normals may be converted from short's: see #34322.

Definition at line 308 of file BLI_math_base_c.hh.

Referenced by blender::axis_dominant_v3_to_m3(), blender::axis_dominant_v3_to_m3_negate(), and blender::quat_split_swing_and_twist().

◆ BLI_ASSERT_UNIT_EPSILON_DB

#define BLI_ASSERT_UNIT_EPSILON_DB   0.0002

Definition at line 309 of file BLI_math_base_c.hh.

◆ BLI_ASSERT_UNIT_M3

#define BLI_ASSERT_UNIT_M3 ( m)

◆ BLI_ASSERT_UNIT_QUAT

#define BLI_ASSERT_UNIT_QUAT ( q)

◆ BLI_ASSERT_UNIT_V2

#define BLI_ASSERT_UNIT_V2 ( v)

◆ BLI_ASSERT_UNIT_V3

#define BLI_ASSERT_UNIT_V3 ( v)
Value:
{ \
const float _test_unit = len_squared_v3(v); \
BLI_assert(!(fabsf(_test_unit - 1.0f) >= BLI_ASSERT_UNIT_EPSILON) || \
!(fabsf(_test_unit) >= BLI_ASSERT_UNIT_EPSILON)); \
} \
(void)0
Note
Checks are flipped so NAN doesn't assert. This is done because we're making sure the value was normalized and in the case we don't want NAN to be raising asserts since there is nothing to be done in that case.

Definition at line 315 of file BLI_math_base_c.hh.

Referenced by blender::angle_normalized_v3v3(), blender::axis_angle_normalized_to_mat3_ex(), blender::axis_angle_normalized_to_quat(), blender::axis_dominant_v3_to_m3(), blender::axis_dominant_v3_to_m3_negate(), blender::BLI_bvhtree_ray_cast_all_ex(), blender::BLI_bvhtree_ray_cast_ex(), blender::BM_mesh_edgeloops_calc_order(), blender::closest_to_plane3_normalized_v3(), blender::closest_to_plane_normalized_v3(), blender::ed::transform::createSpaceNormalTangent(), blender::cubic_tangent_factor_circle_v3(), blender::ed::sculpt_paint::brushes::do_clay_brush(), blender::ED_armature_ebone_roll_to_vector(), blender::bke::mesh::face_normal_calc(), blender::interp_v3_v3v3_slerp(), blender::legacy_vec_roll_to_mat3_normalized(), blender::mid_v3_v3v3_angle_weighted(), blender::nearly_parallel_normalized(), blender::project_plane_normalized_v3_v3v3(), blender::project_v3_v3v3_normalized(), blender::reflect_v3_v3v3(), blender::rotate_normalized_v3_v3v3fl(), blender::rotation_between_vecs_to_mat3(), blender::shell_v3v3_mid_normalized_to_dist(), blender::shell_v3v3_normalized_to_dist(), blender::ed::transform::snap_object_project_view3d_ex(), blender::vec_roll_to_mat3_normalized(), and blender::view3d_horizon_angle_calc().

◆ BLI_ASSERT_ZERO_M3

#define BLI_ASSERT_ZERO_M3 ( m)
Value:
{ \
BLI_assert(dot_vn_vn((const float *)m, (const float *)m, 9) != 0.0); \
} \
(void)0

Definition at line 339 of file BLI_math_base_c.hh.

◆ BLI_ASSERT_ZERO_M4

#define BLI_ASSERT_ZERO_M4 ( m)
Value:
{ \
BLI_assert(dot_vn_vn((const float *)m, (const float *)m, 16) != 0.0); \
} \
(void)0

Definition at line 345 of file BLI_math_base_c.hh.

Referenced by blender::ED_view3d_check_mats_rv3d().

◆ NAN_FLT

Variable Documentation

◆ NAN_INT

const int NAN_INT = 0x7FC00000
static

Definition at line 56 of file BLI_math_base_c.hh.