Blender V4.3
blender::math Namespace Reference

Namespaces

namespace  detail
 
namespace  numbers
 
namespace  projection
 
namespace  tests
 

Classes

struct  AngleCartesianBase
 
struct  AngleFraction
 
struct  AngleRadianBase
 
struct  AssertUnitEpsilon
 
struct  AssertUnitEpsilon< QuaternionBase< U > >
 
class  Axis
 
struct  AxisAngleBase
 
class  AxisSigned
 
struct  CartesianBasis
 
struct  DualQuaternionBase
 
struct  Euler3Base
 
struct  EulerBase
 
struct  EulerXYZBase
 
struct  isect_result
 
struct  locus_entry_t
 
struct  QuaternionBase
 
struct  TypeTraits
 
struct  TypeTraits< float >
 

Typedefs

using AngleRadian = AngleRadianBase<float>
 
using AngleCartesian = AngleCartesianBase<float>
 
using AxisAngle = AxisAngleBase<float, AngleRadianBase<float>>
 
using AxisAngleCartesian = AxisAngleBase<float, AngleCartesianBase<float>>
 
using EulerXYZ = EulerXYZBase<float>
 
using Euler3 = Euler3Base<float>
 
Intermediate Types

Some functions need to have higher precision than standard floats for some operations.

using Quaternion = QuaternionBase<float>
 
using DualQuaternion = DualQuaternionBase<float>
 

Enumerations

enum  EulerOrder {
  XYZ = 1 , XZY , YXZ , YZX ,
  ZXY , ZYX
}
 
enum class  eCubicFilter { BSpline , Mitchell }
 

Functions

template<typename T >
T cos (const AngleRadianBase< T > &a)
 
template<typename T >
T sin (const AngleRadianBase< T > &a)
 
template<typename T >
T tan (const AngleRadianBase< T > &a)
 
template<typename T >
T cos (const AngleCartesianBase< T > &a)
 
template<typename T >
T sin (const AngleCartesianBase< T > &a)
 
template<typename T >
T tan (const AngleCartesianBase< T > &a)
 
template<typename T >
T cos (const AngleFraction< T > &a)
 
template<typename T >
T sin (const AngleFraction< T > &a)
 
template<typename T >
T tan (const AngleFraction< T > &a)
 
template<typename T >
bool is_zero (const T &a)
 
template<typename T >
bool is_any_zero (const T &a)
 
template<typename T >
T abs (const T &a)
 
template<typename T >
T sign (const T &a)
 
template<typename T >
T min (const T &a, const T &b)
 
template<typename T >
T max (const T &a, const T &b)
 
template<typename T >
void max_inplace (T &a, const T &b)
 
template<typename T >
void min_inplace (T &a, const T &b)
 
template<typename T >
T clamp (const T &a, const T &min, const T &max)
 
template<typename T >
T step (const T &edge, const T &value)
 
template<typename T >
T mod (const T &a, const T &b)
 
template<typename T >
T safe_mod (const T &a, const T &b)
 
template<typename T >
void min_max (const T &value, T &min, T &max)
 
template<typename T >
T safe_divide (const T &a, const T &b)
 
template<typename T >
T floor (const T &a)
 
template<typename T >
T round (const T &a)
 
template<typename T >
T mod_periodic (const T &a, const T &b)
 
template<typename T >
T ceil (const T &a)
 
template<typename T >
T distance (const T &a, const T &b)
 
template<typename T >
T fract (const T &a)
 
template<typename T >
T sqrt (const T &a)
 
template<typename T >
T rcp (const T &a)
 
template<typename T >
T safe_rcp (const T &a)
 
template<typename T >
T cos (const T &a)
 
template<typename T >
T sin (const T &a)
 
template<typename T >
T tan (const T &a)
 
template<typename T >
T acos (const T &a)
 
template<typename T >
T pow (const T &x, const T &power)
 
template<typename T >
T square (const T &a)
 
template<typename T >
T exp (const T &x)
 
template<typename T >
T safe_acos (const T &a)
 
float safe_acos_approx (float x)
 
template<typename T >
T asin (const T &a)
 
template<typename T >
T atan (const T &a)
 
template<typename T >
T atan2 (const T &y, const T &x)
 
template<typename T >
T hypot (const T &y, const T &x)
 
template<typename T , typename FactorT >
T interpolate (const T &a, const T &b, const FactorT &t)
 
template<typename T >
T midpoint (const T &a, const T &b)
 
template<eAlpha Alpha>
ColorSceneLinear4f< Alpha > interpolate (const ColorSceneLinear4f< Alpha > &a, const ColorSceneLinear4f< Alpha > &b, const float t)
 
template<eAlpha Alpha>
ColorSceneLinearByteEncoded4b< Alpha > interpolate (const ColorSceneLinearByteEncoded4b< Alpha > &a, const ColorSceneLinearByteEncoded4b< Alpha > &b, const float t)
 
float3 whitepoint_from_temp_tint (float temperature, float tint)
 
bool whitepoint_to_temp_tint (const float3 &white, float &temperature, float &tint)
 
float3x3 chromatic_adaption_matrix (const float3 &from_XYZ, const float3 &to_XYZ)
 
std::ostream & operator<< (std::ostream &stream, EulerOrder order)
 
uint16_t float_to_half (float v)
 
float half_to_float (uint16_t v)
 
void float_to_half_array (const float *src, uint16_t *dst, size_t length)
 
void half_to_float_array (const uint16_t *src, float *dst, size_t length)
 
void interpolate_nearest_border_byte (const uchar *buffer, uchar *output, int width, int height, float u, float v)
 
uchar4 interpolate_nearest_border_byte (const uchar *buffer, int width, int height, float u, float v)
 
void interpolate_nearest_border_fl (const float *buffer, float *output, int width, int height, int components, float u, float v)
 
float4 interpolate_nearest_border_fl (const float *buffer, int width, int height, float u, float v)
 
void interpolate_nearest_byte (const uchar *buffer, uchar *output, int width, int height, float u, float v)
 
uchar4 interpolate_nearest_byte (const uchar *buffer, int width, int height, float u, float v)
 
void interpolate_nearest_fl (const float *buffer, float *output, int width, int height, int components, float u, float v)
 
float4 interpolate_nearest_fl (const float *buffer, int width, int height, float u, float v)
 
void interpolate_nearest_wrap_byte (const uchar *buffer, uchar *output, int width, int height, float u, float v)
 
uchar4 interpolate_nearest_wrap_byte (const uchar *buffer, int width, int height, float u, float v)
 
void interpolate_nearest_wrap_fl (const float *buffer, float *output, int width, int height, int components, float u, float v)
 
float4 interpolate_nearest_wrap_fl (const float *buffer, int width, int height, float u, float v)
 
uchar4 interpolate_bilinear_border_byte (const uchar *buffer, int width, int height, float u, float v)
 
float4 interpolate_bilinear_border_fl (const float *buffer, int width, int height, float u, float v)
 
void interpolate_bilinear_border_fl (const float *buffer, float *output, int width, int height, int components, float u, float v)
 
uchar4 interpolate_bilinear_byte (const uchar *buffer, int width, int height, float u, float v)
 
float4 interpolate_bilinear_fl (const float *buffer, int width, int height, float u, float v)
 
void interpolate_bilinear_fl (const float *buffer, float *output, int width, int height, int components, float u, float v)
 
uchar4 interpolate_bilinear_wrap_byte (const uchar *buffer, int width, int height, float u, float v)
 
float4 interpolate_bilinear_wrap_fl (const float *buffer, int width, int height, float u, float v)
 
void interpolate_bilinear_wrap_fl (const float *buffer, float *output, int width, int height, int components, float u, float v, bool wrap_x, bool wrap_y)
 
uchar4 interpolate_cubic_bspline_byte (const uchar *buffer, int width, int height, float u, float v)
 
float4 interpolate_cubic_bspline_fl (const float *buffer, int width, int height, float u, float v)
 
void interpolate_cubic_bspline_fl (const float *buffer, float *output, int width, int height, int components, float u, float v)
 
uchar4 interpolate_cubic_mitchell_byte (const uchar *buffer, int width, int height, float u, float v)
 
float4 interpolate_cubic_mitchell_fl (const float *buffer, int width, int height, float u, float v)
 
void interpolate_cubic_mitchell_fl (const float *buffer, float *output, int width, int height, int components, float u, float v)
 
float3 rotate_direction_around_axis (const float3 &direction, const float3 &axis, float angle)
 
float3 rotate_around_axis (const float3 &vector, const float3 &center, const float3 &axis, float angle)
 
template<typename T , int Size>
bool almost_equal_relative (const VecBase< T, Size > &a, const VecBase< T, Size > &b, const T &epsilon_factor)
 
template<typename T , int Size>
VecBase< T, Size > abs (const VecBase< T, Size > &a)
 
template<typename T , int Size>
VecBase< T, Size > sign (const VecBase< T, Size > &a)
 
template<typename T , int Size>
VecBase< T, Size > min (const VecBase< T, Size > &a, const VecBase< T, Size > &b)
 
template<typename T , int Size>
VecBase< T, Size > max (const VecBase< T, Size > &a, const VecBase< T, Size > &b)
 
template<typename T , int Size>
VecBase< T, Size > clamp (const VecBase< T, Size > &a, const VecBase< T, Size > &min, const VecBase< T, Size > &max)
 
template<typename T , int Size>
VecBase< T, Size > clamp (const VecBase< T, Size > &a, const T &min, const T &max)
 
template<typename T , int Size>
VecBase< T, Size > step (const VecBase< T, Size > &edge, const VecBase< T, Size > &value)
 
template<typename T , int Size>
VecBase< T, Size > step (const T &edge, const VecBase< T, Size > &value)
 
template<typename T , int Size>
VecBase< T, Size > mod (const VecBase< T, Size > &a, const VecBase< T, Size > &b)
 
template<typename T , int Size>
VecBase< T, Size > mod (const VecBase< T, Size > &a, const T &b)
 
template<typename T , int Size>
VecBase< T, Size > safe_mod (const VecBase< T, Size > &a, const VecBase< T, Size > &b)
 
template<typename T , int Size>
VecBase< T, Size > safe_mod (const VecBase< T, Size > &a, const T &b)
 
template<typename T , int Size>
VecBase< T, Size > pow (const VecBase< T, Size > &x, const T &y)
 
template<typename T , int Size>
VecBase< T, Size > pow (const VecBase< T, Size > &x, const VecBase< T, Size > &y)
 
template<typename T , int Size>
VecBase< T, Size > square (const VecBase< T, Size > &a)
 
template<typename T , int Size>
VecBase< T, Size > exp (const VecBase< T, Size > &x)
 
template<typename T , int Size>
VecBase< T, Size > ceil_to_multiple (const VecBase< T, Size > &a, const VecBase< T, Size > &b)
 
template<typename T , int Size>
VecBase< T, Size > divide_ceil (const VecBase< T, Size > &a, const VecBase< T, Size > &b)
 
template<typename T , int Size>
void min_max (const VecBase< T, Size > &vector, VecBase< T, Size > &min, VecBase< T, Size > &max)
 
template<typename T , int Size>
VecBase< T, Size > safe_divide (const VecBase< T, Size > &a, const VecBase< T, Size > &b)
 
template<typename T , int Size>
VecBase< T, Size > safe_divide (const VecBase< T, Size > &a, const T &b)
 
template<typename T , int Size>
VecBase< T, Size > floor (const VecBase< T, Size > &a)
 
template<typename T , int Size>
VecBase< T, Size > round (const VecBase< T, Size > &a)
 
template<typename T , int Size>
VecBase< T, Size > ceil (const VecBase< T, Size > &a)
 
template<typename T , int Size>
VecBase< T, Size > sqrt (const VecBase< T, Size > &a)
 
template<typename T , int Size>
VecBase< T, Size > safe_sqrt (const VecBase< T, Size > &a)
 
template<typename T , int Size>
VecBase< T, Size > rcp (const VecBase< T, Size > &a)
 
template<typename T , int Size>
VecBase< T, Size > safe_rcp (const VecBase< T, Size > &a)
 
template<typename T , int Size>
VecBase< T, Size > fract (const VecBase< T, Size > &a)
 
template<typename T , int Size>
T dot (const VecBase< T, Size > &a, const VecBase< T, Size > &b)
 
template<typename T , int Size>
T length_manhattan (const VecBase< T, Size > &a)
 
template<typename T , int Size>
T length_squared (const VecBase< T, Size > &a)
 
template<typename T , int Size>
T length (const VecBase< T, Size > &a)
 
template<typename T , int Size>
bool is_unit_scale (const VecBase< T, Size > &v)
 
template<typename T , int Size>
T distance_manhattan (const VecBase< T, Size > &a, const VecBase< T, Size > &b)
 
template<typename T , int Size>
T distance_squared (const VecBase< T, Size > &a, const VecBase< T, Size > &b)
 
template<typename T , int Size>
T distance (const VecBase< T, Size > &a, const VecBase< T, Size > &b)
 
template<typename T , int Size>
VecBase< T, Size > reflect (const VecBase< T, Size > &incident, const VecBase< T, Size > &normal)
 
template<typename T , int Size>
VecBase< T, Size > refract (const VecBase< T, Size > &incident, const VecBase< T, Size > &normal, const T &eta)
 
template<typename T , int Size>
VecBase< T, Size > project (const VecBase< T, Size > &p, const VecBase< T, Size > &v_proj)
 
template<typename T , int Size>
VecBase< T, Size > normalize_and_get_length (const VecBase< T, Size > &v, T &out_length)
 
template<typename T , int Size>
VecBase< T, Size > normalize (const VecBase< T, Size > &v)
 
template<typename T >
VecBase< T, 3 > cross (const VecBase< T, 3 > &a, const VecBase< T, 3 > &b)
 
VecBase< float, 3 > cross_high_precision (const VecBase< float, 3 > &a, const VecBase< float, 3 > &b)
 
template<typename T >
VecBase< T, 3 > cross_poly (Span< VecBase< T, 3 > > poly)
 
template<typename T >
VecBase< T, 3 > cross_tri (const VecBase< T, 3 > &v1, const VecBase< T, 3 > &v2, const VecBase< T, 3 > &v3)
 
template<typename T >
VecBase< T, 3 > normal_tri (const VecBase< T, 3 > &v1, const VecBase< T, 3 > &v2, const VecBase< T, 3 > &v3)
 
template<typename T , typename FactorT , int Size>
VecBase< T, Size > interpolate (const VecBase< T, Size > &a, const VecBase< T, Size > &b, const FactorT &t)
 
template<typename T , int Size>
VecBase< T, Size > midpoint (const VecBase< T, Size > &a, const VecBase< T, Size > &b)
 
template<typename T , int Size>
VecBase< T, Size > faceforward (const VecBase< T, Size > &vector, const VecBase< T, Size > &incident, const VecBase< T, Size > &reference)
 
template<typename T >
int dominant_axis (const VecBase< T, 3 > &a)
 
template<typename T , int Size>
T reduce_max (const VecBase< T, Size > &a)
 
template<typename T , int Size>
T reduce_min (const VecBase< T, Size > &a)
 
template<typename T , int Size>
T reduce_add (const VecBase< T, Size > &a)
 
template<typename T , int Size>
T reduce_mul (const VecBase< T, Size > &a)
 
template<typename T , int Size>
T average (const VecBase< T, Size > &a)
 
template<typename T >
VecBase< T, 3 > orthogonal (const VecBase< T, 3 > &v)
 
template<typename T >
VecBase< T, 2 > orthogonal (const VecBase< T, 2 > &v)
 
template<typename T , int Size>
bool is_equal (const VecBase< T, Size > &a, const VecBase< T, Size > &b, const T epsilon=T(0))
 
template<typename T , int Size>
bool is_zero (const VecBase< T, Size > &a, const T epsilon=T(0))
 
template<typename T , int Size>
bool is_any_zero (const VecBase< T, Size > &a)
 
template<typename T , int Size>
bool is_unit (const VecBase< T, Size > &a, const T epsilon=T(10) *std::numeric_limits< T >::epsilon())
 
template<typename T , int Size>
isect_result< VecBase< T, Size > > isect_seg_seg (const VecBase< T, Size > &v1, const VecBase< T, Size > &v2, const VecBase< T, Size > &v3, const VecBase< T, Size > &v4)
 
template<typename T >
uint64_t vector_hash (const T &vec)
 
std::ostream & operator<< (std::ostream &stream, const Axis axis)
 
std::ostream & operator<< (std::ostream &stream, const AxisSigned axis)
 
std::ostream & operator<< (std::ostream &stream, const CartesianBasis &rot)
 
template<enum eCubicFilter filter>
static float4 cubic_filter_coefficients (float f)
 
template<typename T , eCubicFilter filter>
static void bicubic_interpolation (const T *src_buffer, T *output, int width, int height, int components, float u, float v)
 
template<bool border>
BLI_INLINE void bilinear_fl_impl (const float *buffer, float *output, int width, int height, int components, float u, float v, bool wrap_x=false, bool wrap_y=false)
 
template<bool border>
BLI_INLINE uchar4 bilinear_byte_impl (const uchar *buffer, int width, int height, float u, float v)
 
template<>
isect_result< float2isect_seg_seg (const float2 &v1, const float2 &v2, const float2 &v3, const float2 &v4)
 
template<>
isect_result< double2isect_seg_seg (const double2 &v1, const double2 &v2, const double2 &v3, const double2 &v4)
 
Conversion to Quaternions
template<typename T , typename AngleT >
QuaternionBase< Tto_quaternion (const AxisAngleBase< T, AngleT > &axis_angle)
 
template<typename T >
QuaternionBase< Tto_quaternion (const EulerXYZBase< T > &eul)
 
template<typename T >
QuaternionBase< Tto_quaternion (const Euler3Base< T > &eulO)
 
Conversion to Euler
template<typename T , typename AngleT >
Euler3Base< Tto_euler (const AxisAngleBase< T, AngleT > &axis_angle, EulerOrder order)
 
template<typename T , typename AngleT >
EulerXYZBase< Tto_euler (const AxisAngleBase< T, AngleT > &axis_angle)
 
template<typename T , typename AngleT = AngleRadian>
AxisAngleBase< T, AngleT > to_axis_angle (const QuaternionBase< T > &quat)
 
template<typename T >
EulerXYZBase< Tto_euler (const QuaternionBase< T > &quat)
 
template<typename T >
Euler3Base< Tto_euler (const QuaternionBase< T > &quat, EulerOrder order)
 
Axes
constexpr bool operator<= (const Axis::Value a, const Axis::Value b)
 
constexpr bool operator<= (const AxisSigned::Value a, const AxisSigned::Value b)
 
Axes Utilities
template<>
AxisSigned abs (const AxisSigned &axis)
 
int sign (const AxisSigned &axis)
 
AxisSigned cross (const AxisSigned a, const AxisSigned b)
 
template<typename T >
T to_vector (const Axis axis)
 
template<typename T >
T to_vector (const AxisSigned axis)
 
CartesianBasis
CartesianBasis from_orthonormal_axes (const AxisSigned forward, const AxisSigned up)
 
CartesianBasis rotation_between (const CartesianBasis &a, const CartesianBasis &b)
 
CartesianBasis rotation_between (const AxisSigned a_forward, const AxisSigned b_forward)
 
template<typename T >
VecBase< T, 3 > transform_point (const CartesianBasis &basis, const VecBase< T, 3 > &v)
 
CartesianBasis invert (const CartesianBasis &basis)
 
Conversion to axis angles
template<typename T , typename AngleT = AngleRadian>
AxisAngleBase< T, AngleT > to_axis_angle (const EulerXYZBase< T > &euler)
 
template<typename T , typename AngleT = AngleRadian>
AxisAngleBase< T, AngleT > to_axis_angle (const Euler3Base< T > &euler)
 
Matrix Operations
template<typename T , int Size>
MatBase< T, Size, Size > invert (const MatBase< T, Size, Size > &mat, bool &r_success)
 
template<typename T , int NumCol, int NumRow>
MatBase< T, NumCol, NumRow > transpose (const MatBase< T, NumRow, NumCol > &mat)
 
template<typename T , int NumCol, int NumRow>
MatBase< T, NumCol, NumRow > normalize (const MatBase< T, NumCol, NumRow > &a)
 
template<typename T , int NumCol, int NumRow, typename VectorT >
MatBase< T, NumCol, NumRow > normalize_and_get_size (const MatBase< T, NumCol, NumRow > &a, VectorT &r_size)
 
template<typename T , int Size>
T determinant (const MatBase< T, Size, Size > &mat)
 
template<typename T , int Size>
MatBase< T, Size, Size > adjoint (const MatBase< T, Size, Size > &mat)
 
template<typename T , int NumCol, int NumRow, typename VectorT >
MatBase< T, NumCol, NumRow > translate (const MatBase< T, NumCol, NumRow > &mat, const VectorT &translation)
 
template<typename T , int NumCol, int NumRow, typename RotationT >
MatBase< T, NumCol, NumRow > rotate (const MatBase< T, NumCol, NumRow > &mat, const RotationT &rotation)
 
template<typename T , int NumCol, int NumRow, typename VectorT >
MatBase< T, NumCol, NumRow > scale (const MatBase< T, NumCol, NumRow > &mat, const VectorT &scale)
 
template<typename T , int NumCol, int NumRow>
MatBase< T, NumCol, NumRow > interpolate_linear (const MatBase< T, NumCol, NumRow > &a, const MatBase< T, NumCol, NumRow > &b, T t)
 
template<typename T >
MatBase< T, 3, 3 > interpolate (const MatBase< T, 3, 3 > &a, const MatBase< T, 3, 3 > &b, T t)
 
template<typename T >
MatBase< T, 4, 4 > interpolate (const MatBase< T, 4, 4 > &a, const MatBase< T, 4, 4 > &b, T t)
 
template<typename T >
MatBase< T, 3, 3 > interpolate_fast (const MatBase< T, 3, 3 > &a, const MatBase< T, 3, 3 > &b, T t)
 
template<typename T >
MatBase< T, 4, 4 > interpolate_fast (const MatBase< T, 4, 4 > &a, const MatBase< T, 4, 4 > &b, T t)
 
template<typename T , int Size>
MatBase< T, Size, Size > pseudo_invert (const MatBase< T, Size, Size > &mat, T epsilon=1e-8)
 
Init helpers.
template<typename MatT >
MatT from_location (const typename MatT::loc_type &location)
 
template<typename MatT , int ScaleDim>
MatT from_scale (const VecBase< typename MatT::base_type, ScaleDim > &scale)
 
template<typename MatT , typename RotationT >
MatT from_rotation (const RotationT &rotation)
 
template<typename MatT , typename RotationT , typename VectorT >
MatT from_rot_scale (const RotationT &rotation, const VectorT &scale)
 
template<typename MatT , typename RotationT >
MatT from_loc_rot (const typename MatT::loc_type &location, const RotationT &rotation)
 
template<typename MatT , int ScaleDim>
MatT from_loc_scale (const typename MatT::loc_type &location, const VecBase< typename MatT::base_type, ScaleDim > &scale)
 
template<typename MatT , typename RotationT , int ScaleDim>
MatT from_loc_rot_scale (const typename MatT::loc_type &location, const RotationT &rotation, const VecBase< typename MatT::base_type, ScaleDim > &scale)
 
template<typename MatT , typename VectorT >
MatT from_orthonormal_axes (const VectorT forward, const VectorT up)
 
template<typename MatT , typename VectorT >
MatT from_orthonormal_axes (const VectorT location, const VectorT forward, const VectorT up)
 
template<typename MatT , typename VectorT >
MatT from_up_axis (const VectorT up)
 
template<typename MatT >
MatT orthogonalize (const MatT &mat, const Axis axis)
 
template<typename MatT , typename VectorT >
MatT from_origin_transform (const MatT &transform, const VectorT origin)
 
Conversion function.
template<typename T >
AngleRadianBase< Tto_angle (const MatBase< T, 2, 2 > &mat)
 
template<typename T >
EulerXYZBase< Tto_euler (const MatBase< T, 3, 3 > &mat)
 
template<typename T >
EulerXYZBase< Tto_euler (const MatBase< T, 4, 4 > &mat)
 
template<typename T >
Euler3Base< Tto_euler (const MatBase< T, 3, 3 > &mat, EulerOrder order)
 
template<typename T >
Euler3Base< Tto_euler (const MatBase< T, 4, 4 > &mat, EulerOrder order)
 
template<typename T >
EulerXYZBase< Tto_nearest_euler (const MatBase< T, 3, 3 > &mat, const EulerXYZBase< T > &reference)
 
template<typename T >
EulerXYZBase< Tto_nearest_euler (const MatBase< T, 4, 4 > &mat, const EulerXYZBase< T > &reference)
 
template<typename T >
Euler3Base< Tto_nearest_euler (const MatBase< T, 3, 3 > &mat, const Euler3Base< T > &reference)
 
template<typename T >
Euler3Base< Tto_nearest_euler (const MatBase< T, 4, 4 > &mat, const Euler3Base< T > &reference)
 
template<typename T >
QuaternionBase< Tto_quaternion (const MatBase< T, 3, 3 > &mat)
 
template<typename T >
QuaternionBase< Tto_quaternion (const MatBase< T, 4, 4 > &mat)
 
Quaternion to_quaternion_legacy (const float3x3 &mat)
 
template<bool AllowNegativeScale = false, typename T , int NumCol, int NumRow>
VecBase< T, 3 > to_scale (const MatBase< T, NumCol, NumRow > &mat)
 
template<bool AllowNegativeScale = false, typename T >
VecBase< T, 2 > to_scale (const MatBase< T, 2, 2 > &mat)
 
template<bool AllowNegativeScale = false, typename T >
void to_rot_scale (const MatBase< T, 2, 2 > &mat, AngleRadianBase< T > &r_rotation, VecBase< T, 2 > &r_scale)
 
template<bool AllowNegativeScale = false, typename T >
void to_loc_rot_scale (const MatBase< T, 3, 3 > &mat, VecBase< T, 2 > &r_location, AngleRadianBase< T > &r_rotation, VecBase< T, 2 > &r_scale)
 
template<bool AllowNegativeScale = false, typename T , typename RotationT >
void to_rot_scale (const MatBase< T, 3, 3 > &mat, RotationT &r_rotation, VecBase< T, 3 > &r_scale)
 
template<bool AllowNegativeScale = false, typename T , typename RotationT >
void to_loc_rot_scale (const MatBase< T, 4, 4 > &mat, VecBase< T, 3 > &r_location, RotationT &r_rotation, VecBase< T, 3 > &r_scale)
 
Transform functions.
template<typename T >
VecBase< T, 3 > transform_point (const MatBase< T, 3, 3 > &mat, const VecBase< T, 3 > &point)
 
template<typename T >
VecBase< T, 3 > transform_point (const MatBase< T, 4, 4 > &mat, const VecBase< T, 3 > &point)
 
template<typename T >
VecBase< T, 3 > transform_direction (const MatBase< T, 3, 3 > &mat, const VecBase< T, 3 > &direction)
 
template<typename T >
VecBase< T, 3 > transform_direction (const MatBase< T, 4, 4 > &mat, const VecBase< T, 3 > &direction)
 
template<typename MatT , typename VectorT >
VectorT project_point (const MatT &mat, const VectorT &point)
 
template<typename T >
VecBase< T, 3 > transform_point (const QuaternionBase< T > &q, const VecBase< T, 3 > &v)
 
Compare / Test
template<typename T , int Size>
bool is_negative (const MatBase< T, Size, Size > &mat)
 
template<typename T >
bool is_negative (const MatBase< T, 4, 4 > &mat)
 
template<typename T , int NumCol, int NumRow>
bool is_equal (const MatBase< T, NumCol, NumRow > &a, const MatBase< T, NumCol, NumRow > &b, const T epsilon=T(0))
 
template<typename MatT >
bool is_orthogonal (const MatT &mat)
 
template<typename MatT >
bool is_orthonormal (const MatT &mat)
 
template<typename MatT >
bool is_uniformly_scaled (const MatT &mat)
 
template<typename T , int NumCol, int NumRow>
bool is_zero (const MatBase< T, NumCol, NumRow > &mat)
 
Implementation.
template<typename T , int NumCol, int NumRow>
bool is_unit_scale (const MatBase< T, NumCol, NumRow > &m)
 
template<typename T , int Size>
MatBase< T, Size, Size > invert (const MatBase< T, Size, Size > &mat)
 
template<typename T , int NumCol, int NumRow, typename AngleT >
MatBase< T, NumCol, NumRow > rotate (const MatBase< T, NumCol, NumRow > &mat, const AxisAngleBase< T, AngleT > &rotation)
 
template<typename T , int NumCol, int NumRow, int SrcNumCol, int SrcNumRow, int SrcStartCol, int SrcStartRow, int SrcAlignment>
MatBase< T, NumCol, NumRow > normalize (const MatView< T, NumCol, NumRow, SrcNumCol, SrcNumRow, SrcStartCol, SrcStartRow, SrcAlignment > &a)
 
template<typename T , int NumCol, int NumRow, int SrcNumCol, int SrcNumRow, int SrcStartCol, int SrcStartRow, int SrcAlignment, typename VectorT >
MatBase< T, NumCol, NumRow > normalize_and_get_size (const MatView< T, NumCol, NumRow, SrcNumCol, SrcNumRow, SrcStartCol, SrcStartRow, SrcAlignment > &a, VectorT &r_size)
 
template<typename T >
QuaternionBase< Tnormalized_to_quaternion_safe (const MatBase< T, 3, 3 > &mat)
 
template<bool AllowNegativeScale, typename T , typename RotationT >
void to_loc_rot_scale_safe (const MatBase< T, 4, 4 > &mat, VecBase< T, 3 > &r_location, RotationT &r_rotation, VecBase< T, 3 > &r_scale)
 
template<typename T , int N, int NumRow>
VecBase< T, Nproject_point (const MatBase< T, N+1, NumRow > &mat, const VecBase< T, N > &point)
 
template float3 transform_point (const float3x3 &mat, const float3 &point)
 
template float3 transform_point (const float4x4 &mat, const float3 &point)
 
template float3 transform_direction (const float3x3 &mat, const float3 &direction)
 
template float3 transform_direction (const float4x4 &mat, const float3 &direction)
 
template float3 project_point (const float4x4 &mat, const float3 &point)
 
template float2 project_point (const float3x3 &mat, const float2 &point)
 
Quaternion functions.
template<typename T >
T dot (const QuaternionBase< T > &a, const QuaternionBase< T > &b)
 
template<typename T >
QuaternionBase< Tpow (const QuaternionBase< T > &q, const T &y)
 
template<typename T >
QuaternionBase< Tconjugate (const QuaternionBase< T > &a)
 
template<typename T >
QuaternionBase< Tcanonicalize (const QuaternionBase< T > &q)
 
template<typename T >
QuaternionBase< Tinvert (const QuaternionBase< T > &q)
 
template<typename T >
QuaternionBase< Tinvert_normalized (const QuaternionBase< T > &q)
 
template<typename T >
QuaternionBase< Tnormalize (const QuaternionBase< T > &q)
 
template<typename T >
QuaternionBase< Tnormalize_and_get_length (const QuaternionBase< T > &q, T &out_length)
 
template<typename T >
QuaternionBase< Tinterpolate (const QuaternionBase< T > &a, const QuaternionBase< T > &b, T t)
 
Test functions.
template<typename T >
bool is_zero (const QuaternionBase< T > &q)
 
template<typename T >
bool is_equal (const QuaternionBase< T > &a, const QuaternionBase< T > &b, const T epsilon=T(0))
 
template<typename T >
bool is_unit_scale (const QuaternionBase< T > &q)
 
Quaternion
template<typename T >
VecBase< T, 2 > interpolate_dot_slerp (const T t, const T cosom)
 
Dual-Quaternion
template<typename T >
DualQuaternionBase< Tnormalize (const DualQuaternionBase< T > &dual_quat)
 
template<typename T >
VecBase< T, 3 > transform_point (const DualQuaternionBase< T > &dq, const VecBase< T, 3 > &point, MatBase< T, 3, 3 > *r_crazy_space_mat=nullptr)
 
template<typename T >
DualQuaternionBase< Tto_dual_quaternion (const MatBase< T, 4, 4 > &mat, const MatBase< T, 4, 4 > &basemat)
 
template<typename T >
bool is_normalized (const DualQuaternionBase< T > &dq)
 
Rotation helpers
template<typename T , typename RotT >
QuaternionBase< Trotate (const QuaternionBase< T > &a, const RotT &b)
 
template<typename T , typename RotT , typename AngleT >
AxisAngleBase< T, AngleT > rotate (const AxisAngleBase< T, AngleT > &a, const RotT &b)
 
template<typename T , typename RotT >
EulerXYZBase< Trotate (const EulerXYZBase< T > &a, const RotT &b)
 
template<typename T , typename RotT >
Euler3Base< Trotate (const Euler3Base< T > &a, const RotT &b)
 
template<typename T >
QuaternionBase< Trotation_between (const QuaternionBase< T > &a, const QuaternionBase< T > &b)
 
template<typename T >
QuaternionBase< Tfrom_triangle (const VecBase< T, 3 > &v1, const VecBase< T, 3 > &v2, const VecBase< T, 3 > &v3, const VecBase< T, 3 > &normal)
 
template<typename T >
QuaternionBase< Tfrom_triangle (const VecBase< T, 3 > &v1, const VecBase< T, 3 > &v2, const VecBase< T, 3 > &v3)
 
template<typename T >
QuaternionBase< Tfrom_vector (const VecBase< T, 3 > &vector, const AxisSigned track_flag, const Axis up_flag)
 
template<typename T >
QuaternionBase< Tfrom_tracking (AxisSigned forward_axis, Axis up_axis)
 
template<typename T >
MatBase< T, 3, 3 > to_gimbal_axis (const Euler3Base< T > &rotation)
 
Angles
template<typename T >
AngleRadianBase< Tangle_of (const QuaternionBase< T > &q)
 
template<typename T >
AngleRadianBase< Tangle_of_signed (const QuaternionBase< T > &q)
 
template<typename T >
AngleRadianBase< Tangle_between (const QuaternionBase< T > &a, const QuaternionBase< T > &b)
 
template<typename T >
AngleRadianBase< Tangle_between (const VecBase< T, 3 > &a, const VecBase< T, 3 > &b)
 
template<typename T >
AngleFraction< Tangle_between (const AxisSigned a, const AxisSigned b)
 
template<typename T >
AngleRadianBase< Tangle_between_signed (const QuaternionBase< T > &a, const QuaternionBase< T > &b)
 
Conversion from Cartesian Basis
template<typename T >
QuaternionBase< Tto_quaternion (const CartesianBasis &rotation)
 
Explicit Template Instantiations
template EulerXYZ to_euler (const AxisAngle &)
 
template EulerXYZ to_euler (const AxisAngleCartesian &)
 
template EulerXYZ to_euler (const Quaternion &)
 
template Euler3 to_euler (const AxisAngle &, EulerOrder)
 
template Euler3 to_euler (const AxisAngleCartesian &, EulerOrder)
 
template Euler3 to_euler (const Quaternion &, EulerOrder)
 
template Quaternion to_quaternion (const AxisAngle &)
 
template Quaternion to_quaternion (const AxisAngleCartesian &)
 
template Quaternion to_quaternion (const Euler3 &)
 
template Quaternion to_quaternion (const EulerXYZ &)
 
template AxisAngleCartesian to_axis_angle (const Euler3 &)
 
template AxisAngleCartesian to_axis_angle (const EulerXYZ &)
 
template AxisAngleCartesian to_axis_angle (const Quaternion &)
 
Determinant
template float determinant (const float2x2 &mat)
 
template float determinant (const float3x3 &mat)
 
template float determinant (const float4x4 &mat)
 
template double determinant (const double2x2 &mat)
 
template double determinant (const double3x3 &mat)
 
template double determinant (const double4x4 &mat)
 
template bool is_negative (const float4x4 &mat)
 
template bool is_negative (const double4x4 &mat)
 
Adjoint
template float2x2 adjoint (const float2x2 &mat)
 
template float3x3 adjoint (const float3x3 &mat)
 
template float4x4 adjoint (const float4x4 &mat)
 
template double2x2 adjoint (const double2x2 &mat)
 
template double3x3 adjoint (const double3x3 &mat)
 
template double4x4 adjoint (const double4x4 &mat)
 
Inverse
template float2x2 invert (const float2x2 &mat, bool &r_success)
 
template float3x3 invert (const float3x3 &mat, bool &r_success)
 
template float4x4 invert (const float4x4 &mat, bool &r_success)
 
template double2x2 invert (const double2x2 &mat, bool &r_success)
 
template double3x3 invert (const double3x3 &mat, bool &r_success)
 
template double4x4 invert (const double4x4 &mat, bool &r_success)
 
template float2x2 pseudo_invert (const float2x2 &mat, float epsilon)
 
template float3x3 pseudo_invert (const float3x3 &mat, float epsilon)
 
template float4x4 pseudo_invert (const float4x4 &mat, float epsilon)
 
template double2x2 pseudo_invert (const double2x2 &mat, double epsilon)
 
template double3x3 pseudo_invert (const double3x3 &mat, double epsilon)
 
template double4x4 pseudo_invert (const double4x4 &mat, double epsilon)
 
Polar Decomposition
template<typename T >
static void polar_decompose (const MatBase< T, 3, 3 > &mat3, MatBase< T, 3, 3 > &r_U, MatBase< T, 3, 3 > &r_P)
 
Interpolate
template float3x3 interpolate (const float3x3 &a, const float3x3 &b, float t)
 
template double3x3 interpolate (const double3x3 &a, const double3x3 &b, double t)
 
template float4x4 interpolate (const float4x4 &a, const float4x4 &b, float t)
 
template double4x4 interpolate (const double4x4 &a, const double4x4 &b, double t)
 
template float3x3 interpolate_fast (const float3x3 &a, const float3x3 &b, float t)
 
template double3x3 interpolate_fast (const double3x3 &a, const double3x3 &b, double t)
 
template float4x4 interpolate_fast (const float4x4 &a, const float4x4 &b, float t)
 
template double4x4 interpolate_fast (const double4x4 &a, const double4x4 &b, double t)
 

Variables

template<typename T >
constexpr bool is_math_float_type = std::is_floating_point_v<T>
 
template<typename T >
constexpr bool is_math_integral_type = std::is_integral_v<T>
 
static const std::array< locus_entry_t, 31 > planck_locus
 

Typedef Documentation

◆ AngleCartesian

◆ AngleRadian

◆ AxisAngle

◆ AxisAngleCartesian

◆ DualQuaternion

◆ Euler3

Definition at line 436 of file BLI_math_euler_types.hh.

◆ EulerXYZ

◆ Quaternion

Enumeration Type Documentation

◆ eCubicFilter

enum class blender::math::eCubicFilter
strong
Enumerator
BSpline 
Mitchell 

Definition at line 23 of file math_interp.cc.

◆ EulerOrder

Enumerator
XYZ 
XZY 
YXZ 
YZX 
ZXY 
ZYX 

Definition at line 40 of file BLI_math_euler_types.hh.

Function Documentation

◆ abs() [1/3]

template<>
AxisSigned blender::math::abs ( const AxisSigned & axis)
inline

Definition at line 201 of file BLI_math_basis_types.hh.

◆ abs() [2/3]

template<typename T >
T blender::math::abs ( const T & a)
inline

Definition at line 33 of file BLI_math_base.hh.

Referenced by almost_equal_relative(), angle_between(), blender::math::AngleCartesianBase< T >::AngleCartesianBase(), blender::apply_stroke_transform(), blender::ed::sculpt_paint::calc_brush_cube_distances(), blender::ed::sculpt_paint::calc_brush_cube_distances(), blender::ed::sculpt_paint::filter::calc_sphere_translations(), blender::bke::pbvh::pixels::CopyPixelCommand::can_be_extended(), blender::math::CartesianBasis::CartesianBasis(), blender::ed::sculpt_paint::clip_and_lock_translations(), blender::ed::sculpt_paint::clip_and_lock_translations(), blender::nodes::node_composite_defocus_cc::DefocusOperation::compute_maximum_diameter_of_circle_of_confusion(), blender::compositor::compute_motion_rect(), blender::ed::sculpt_paint::greasepencil::EraseOperationExecutor::compute_piecewise_linear_falloff(), blender::realtime_compositor::compute_realized_transformation_domain(), convexhull_2d_angle_iter_init(), blender::draw::create_lines_for_remaining_edges(), cross(), blender::deform_drawing(), blender::deform_drawing_as_envelope(), dominant_axis(), blender::imbuf::transform::edge_aa(), blender::nodes::node_composite_dilate_cc::DilateErodeOperation::execute_step_horizontal_pass(), blender::nodes::node_composite_dilate_cc::DilateErodeOperation::execute_step_vertical_pass(), blender::geometry::extend_curves_curved(), blender::find_envelope(), blender::realtime_compositor::find_scale_factor(), from_orthonormal_axes(), blender::ed::greasepencil::generate_arc_from_point_to_point(), blender::nodes::node_composite_dilate_cc::DilateErodeOperation::get_morphological_distance_threshold_radius(), blender::nodes::node_fn_integer_math_cc::get_multi_function(), blender::realtime_compositor::horizontal_pass(), interpolate_dot_slerp(), is_equal(), is_equal(), is_equal(), blender::compositor::is_inside_motion_line(), is_orthogonal(), is_orthonormal(), is_uniformly_scaled(), is_unit(), is_unit_scale(), is_unit_scale(), is_zero(), length_manhattan(), blender::draw::lines_adjacency_triangle(), mod_periodic(), blender::realtime_compositor::morphological_distance(), blender::ed::sculpt_paint::greasepencil::EraseOperation::on_stroke_done(), blender::math::AngleFraction< T >::operator AngleCartesianBase< T >(), OVERLAY_wireframe_cache_init(), blender::noise::perlin_signed(), blender::noise::perlin_signed(), blender::noise::perlin_signed(), blender::noise::perlin_signed(), blender::ed::sculpt_paint::greasepencil::PaintOperationExecutor::process_extension_sample(), project_point(), blender::seq::query_thumbnail(), blender::math::AngleFraction< T >::radian(), rotation_between(), rotation_between(), blender::nodes::node_fn_integer_math_cc::safe_divide_round_i(), blender::draw::overlay::ShapeCache::ShapeCache(), blender::Bounds< T >::size(), blender::compositor::SMAABlendingWeightCalculationPS(), blender::compositor::SMAADecodeDiagBilinearAccess(), blender::compositor::SMAADecodeDiagBilinearAccess(), blender::compositor::SMAALumaEdgeDetectionPS(), snap_object_context_runtime_init(), blender::eevee::IrradianceBake::surfels_create(), blender::math::QuaternionBase< T >::swing(), blender::math::tests::TEST(), blender::tests::TEST(), to_vector(), blender::compositor::BokehImageOperation::update_memory_buffer_partial(), blender::compositor::VariableSizeBokehBlurOperation::update_memory_buffer_partial(), blender::realtime_compositor::vertical_pass(), and blender::math::AngleFraction< T >::wrapped().

◆ abs() [3/3]

template<typename T , int Size>
VecBase< T, Size > blender::math::abs ( const VecBase< T, Size > & a)
inlinenodiscard

Definition at line 39 of file BLI_math_vector.hh.

References result.

◆ acos()

template<typename T >
T blender::math::acos ( const T & a)
inline

◆ adjoint() [1/7]

template double2x2 blender::math::adjoint ( const double2x2 & mat)

◆ adjoint() [2/7]

template double3x3 blender::math::adjoint ( const double3x3 & mat)

◆ adjoint() [3/7]

template double4x4 blender::math::adjoint ( const double4x4 & mat)

◆ adjoint() [4/7]

template float2x2 blender::math::adjoint ( const float2x2 & mat)

◆ adjoint() [5/7]

template float3x3 blender::math::adjoint ( const float3x3 & mat)

◆ adjoint() [6/7]

template float4x4 blender::math::adjoint ( const float4x4 & mat)

◆ adjoint() [7/7]

template<typename T , int Size>
MatBase< T, Size, Size > blender::math::adjoint ( const MatBase< T, Size, Size > & mat)
nodiscard

Returns the adjoint of the matrix (also known as adjugate matrix).

Definition at line 157 of file math_matrix.cc.

References determinant(), and T.

◆ almost_equal_relative()

template<typename T , int Size>
bool blender::math::almost_equal_relative ( const VecBase< T, Size > & a,
const VecBase< T, Size > & b,
const T & epsilon_factor )
inlinenodiscard

Returns true if the given vectors are equal within the given epsilon. The epsilon is scaled for each component by magnitude of the matching component of a.

Definition at line 26 of file BLI_math_vector.hh.

References abs(), b, and distance().

Referenced by blender::bke::curves::poly::calculate_tangents(), blender::bke::curves::poly::direction_bisect(), and blender::bke::CurvesGeometry::evaluated_tangents().

◆ angle_between() [1/3]

template<typename T >
AngleFraction< T > blender::math::angle_between ( const AxisSigned a,
const AxisSigned b )
nodiscard

◆ angle_between() [2/3]

template<typename T >
AngleRadianBase< T > blender::math::angle_between ( const QuaternionBase< T > & a,
const QuaternionBase< T > & b )
nodiscard

Extract angle between 2 orientations. For Quaternion, the returned angle is in [0..2pi] range. For other types, the returned angle is in [0..pi] range. See angle_of for more detail.

Definition at line 150 of file BLI_math_rotation.hh.

References angle_of(), b, and rotation_between().

Referenced by blender::ed::sculpt_paint::greasepencil::compute_auto_flip(), blender::geometry::extend_curves_curved(), and blender::math::tests::TEST().

◆ angle_between() [3/3]

template<typename T >
AngleRadianBase< T > blender::math::angle_between ( const VecBase< T, 3 > & a,
const VecBase< T, 3 > & b )
nodiscard

Definition at line 156 of file BLI_math_rotation.hh.

References b, BLI_assert, is_unit_scale(), and safe_acos().

◆ angle_between_signed()

template<typename T >
AngleRadianBase< T > blender::math::angle_between_signed ( const QuaternionBase< T > & a,
const QuaternionBase< T > & b )
nodiscard

Extract angle between 2 orientations. Returned angle is in [-pi..pi] range. See angle_of_signed for more detail.

Definition at line 180 of file BLI_math_rotation.hh.

References angle_of_signed(), b, and rotation_between().

Referenced by blender::math::tests::TEST().

◆ angle_of()

template<typename T >
AngleRadianBase< T > blender::math::angle_of ( const QuaternionBase< T > & q)
nodiscard

Extract rotation angle from a unit quaternion. Returned angle is in [0..2pi] range.

Unlike the angle between vectors, this does NOT return the shortest angle. See angle_of_signed below for this.

Definition at line 123 of file BLI_math_rotation.hh.

References BLI_assert, is_unit_scale(), safe_acos(), T, and blender::math::QuaternionBase< T >::w.

Referenced by angle_between(), blender::nodes::node_fn_combine_transform_cc::CombineTransformFunction::call(), blender::math::tests::TEST(), and blender::nodes::node_geo_transform_geometry_cc::use_translate().

◆ angle_of_signed()

template<typename T >
AngleRadianBase< T > blender::math::angle_of_signed ( const QuaternionBase< T > & q)
nodiscard

Extract rotation angle from a unit quaternion. Always return the shortest angle. Returned angle is in [-pi..pi] range.

angle_of with quaternion can exceed PI radians. Having signed versions of these functions allows to use 'abs(angle_of_signed(...))' to get the shortest angle between quaternions with higher precision than subtracting 2pi afterwards.

Definition at line 137 of file BLI_math_rotation.hh.

References BLI_assert, is_unit_scale(), safe_acos(), T, and blender::math::QuaternionBase< T >::w.

Referenced by angle_between_signed(), and blender::math::tests::TEST().

◆ asin()

template<typename T >
T blender::math::asin ( const T & a)
inline

Definition at line 218 of file BLI_math_base.hh.

◆ atan()

template<typename T >
T blender::math::atan ( const T & a)
inline

Definition at line 223 of file BLI_math_base.hh.

Referenced by blender::tests::TEST().

◆ atan2()

◆ average()

◆ bicubic_interpolation()

template<typename T , eCubicFilter filter>
static void blender::math::bicubic_interpolation ( const T * src_buffer,
T * output,
int width,
int height,
int components,
float u,
float v )
static

◆ bilinear_byte_impl()

template<bool border>
BLI_INLINE uchar4 blender::math::bilinear_byte_impl ( const uchar * buffer,
int width,
int height,
float u,
float v )

Definition at line 331 of file math_interp.cc.

References b, BLI_assert, clamp(), floorf, int, and v.

Referenced by interpolate_bilinear_border_byte(), and interpolate_bilinear_byte().

◆ bilinear_fl_impl()

template<bool border>
BLI_INLINE void blender::math::bilinear_fl_impl ( const float * buffer,
float * output,
int width,
int height,
int components,
float u,
float v,
bool wrap_x = false,
bool wrap_y = false )

◆ canonicalize()

template<typename T >
QuaternionBase< T > blender::math::canonicalize ( const QuaternionBase< T > & q)
inlinenodiscard

◆ ceil() [1/2]

template<typename T >
T blender::math::ceil ( const T & a)
inline

Definition at line 120 of file BLI_math_base.hh.

Referenced by blender::bke::compositor::add_passes_used_by_cryptomatte_node(), ceil(), blender::compositor::compute_motion_rect(), blender::compositor::compute_symmetric_separable_blur_weights(), blender::compositor::DefocusNode::convert_to_operations(), blender::deform_drawing(), draw_strip_thumbnails(), blender::nodes::node_composite_defocus_cc::DefocusOperation::execute(), blender::nodes::node_composite_blur_cc::BlurOperation::execute_constant_size(), blender::nodes::node_composite_blur_cc::BlurOperation::execute_variable_size(), blender::geometry::extend_curves(), blender::geometry::extend_curves_curved(), blender::geometry::extend_curves_straight(), blender::nodes::node_composite_bilateralblur_cc::BilateralBlurOperation::get_blur_radius(), blender::nodes::node_composite_directionalblur_cc::DirectionalBlurOperation::get_iterations(), blender::nodes::node_composite_cryptomatte_cc::CryptoMatteOperation::get_layers_from_render(), blender::nodes::node_composite_dilate_cc::DilateErodeOperation::get_morphological_distance_threshold_radius(), blender::draw::image_engine::ScreenTileTextures< Divisions >::gpu_texture_size(), blender::realtime_compositor::horizontal_pass(), blender::TimeMapping::local_frame_after_scene_frame(), blender::draw::mesh_render_data_edge_flag(), blender::draw::mesh_render_data_vert_flag(), blender::eevee::Film::overscan_pixels_get(), blender::TimeMapping::scene_frame_after_local_frame(), blender::compositor::BilateralBlurOperation::set_data(), blender::realtime_compositor::SymmetricBlurWeights::SymmetricBlurWeights(), blender::realtime_compositor::SymmetricSeparableBlurWeights::SymmetricSeparableBlurWeights(), blender::table_sample(), blender::compositor::GaussianBlurReferenceOperation::update_memory_buffer_partial(), blender::compositor::velocity_atomic_max_value(), and blender::realtime_compositor::vertical_pass().

◆ ceil() [2/2]

template<typename T , int Size>
VecBase< T, Size > blender::math::ceil ( const VecBase< T, Size > & a)
inlinenodiscard

Definition at line 262 of file BLI_math_vector.hh.

References BLI_UNROLL_MATH_VEC_OP_VEC, and ceil().

◆ ceil_to_multiple()

template<typename T , int Size>
VecBase< T, Size > blender::math::ceil_to_multiple ( const VecBase< T, Size > & a,
const VecBase< T, Size > & b )
inlinenodiscard

Returns a if it is a multiple of b or the next multiple or b after a . In other words, it is equivalent to divide_ceil(a, b) * b. It is undefined if a is negative or b is not strictly positive.

Definition at line 194 of file BLI_math_vector.hh.

References b, BLI_assert, and result.

Referenced by blender::eevee::DepthOfField::sync(), blender::eevee::HiZBuffer::sync(), and blender::tests::TEST().

◆ chromatic_adaption_matrix()

float3x3 blender::math::chromatic_adaption_matrix ( const float3 & from_XYZ,
const float3 & to_XYZ )

◆ clamp() [1/3]

template<typename T >
T blender::math::clamp ( const T & a,
const T & min,
const T & max )
inline

Definition at line 63 of file BLI_math_base.hh.

References min.

Referenced by blender::ed::sculpt_paint::greasepencil::WeightPaintOperation::apply_weight_to_point(), bilinear_byte_impl(), bilinear_fl_impl(), blender::imbuf::transform::calc_coverage(), blender::calc_min_radius_v3v3(), blender::nodes::node_shader_tex_noise_cc::NoiseFunction::call(), clamp(), clamp(), clamp_rect(), blender::ed::sculpt_paint::color::color_filter_task(), blender::nodes::node_composite_blur_cc::BlurOperation::compute_blur_radius(), blender::nodes::node_composite_bokehblur_cc::BokehBlurOperation::compute_blur_radius(), blender::realtime_compositor::compute_marker_points(), blender::realtime_compositor::compute_realized_transformation_domain(), blender::nodes::node_composite_bokehblur_cc::BokehBlurOperation::compute_variable_size_search_radius(), blender::create_envelope_stroke_for_point(), blender::deform_drawing(), blender::compositor::depth_compare(), blender::ed::sculpt_paint::color::do_paint_brush(), blender::ed::sculpt_paint::color::do_paint_brush_task(), blender::geometry::extend_curves_curved(), fill_rect_alpha_under(), blender::ed::greasepencil::fit_strokes_to_view(), blender::noise::gabor(), blender::noise::gabor(), blender::get_build_factor(), get_default_fac_fade(), blender::compositor::MemoryBuffer::get_elem_clamped(), blender::get_factor_from_draw_speed(), blender::ed::greasepencil::trim::get_intersection_distance_of_segments(), blender::nodes::node_sh_mix_cc::get_multi_function(), initialize_shadow_alpha(), interpolate_nearest_byte(), interpolate_nearest_fl(), blender::compositor::load_mask(), blender::ed::sculpt_paint::node_in_sphere(), blender::ed::greasepencil::normalize_vertex_weights_try(), blender::ed::sculpt_paint::greasepencil::RandomizeOperation::on_stroke_extended(), blender::ed::sculpt_paint::greasepencil::VertexSmearOperation::on_stroke_extended(), paint_sample_color(), blender::imbuf::transform::process_scanlines(), project_face_pixel(), project_paint_PickColor(), blender::ed::greasepencil::retrieve_editable_drawings_from_layer_with_falloff(), blender::ed::greasepencil::retrieve_editable_drawings_with_falloff(), blender::geometry::ReverseUVSampler::sample(), blender::ed::sculpt_paint::greasepencil::EraseOperationExecutor::soft_eraser(), blender::compositor::spread_compare(), blender::tests::TEST(), blender::tests::TEST(), blender::compositor::VariableSizeBokehBlurOperation::update_memory_buffer_partial(), blender::ed::greasepencil::weight_sample_invoke(), whitepoint_from_temp_tint(), blender::io::ply::write_vertices(), and blender::write_weights_for_drawing().

◆ clamp() [2/3]

template<typename T , int Size>
VecBase< T, Size > blender::math::clamp ( const VecBase< T, Size > & a,
const T & min,
const T & max )
inlinenodiscard

Definition at line 82 of file BLI_math_vector.hh.

References clamp(), min, and result.

◆ clamp() [3/3]

template<typename T , int Size>
VecBase< T, Size > blender::math::clamp ( const VecBase< T, Size > & a,
const VecBase< T, Size > & min,
const VecBase< T, Size > & max )
inlinenodiscard

Definition at line 70 of file BLI_math_vector.hh.

References clamp(), min, and result.

◆ conjugate()

template<typename T >
QuaternionBase< T > blender::math::conjugate ( const QuaternionBase< T > & a)
inlinenodiscard

Return the conjugate of the given quaternion. If the quaternion q represent the rotation from A to B, then the conjugate of q represents the rotation from B to A.

Definition at line 221 of file BLI_math_quaternion.hh.

References blender::math::QuaternionBase< T >::w.

Referenced by from_triangle(), invert(), invert_normalized(), blender::math::tests::TEST(), to_quaternion_legacy(), and transform_point().

◆ cos() [1/4]

template<typename T >
T blender::math::cos ( const AngleCartesianBase< T > & a)

Definition at line 697 of file BLI_math_angle_types.hh.

◆ cos() [2/4]

template<typename T >
T blender::math::cos ( const AngleFraction< T > & a)

Definition at line 710 of file BLI_math_angle_types.hh.

References cos().

◆ cos() [3/4]

template<typename T >
T blender::math::cos ( const AngleRadianBase< T > & a)

Definition at line 684 of file BLI_math_angle_types.hh.

References cos().

Referenced by blender::math::AxisAngleBase< T, AngleT >::AxisAngleBase(), blender::noise::compute_2d_gabor_kernel(), blender::noise::compute_3d_gabor_kernel(), blender::noise::compute_3d_orientation(), blender::realtime_compositor::compute_denominator_1(), blender::realtime_compositor::compute_denominator_2(), blender::realtime_compositor::compute_denominator_3(), blender::compositor::compute_fog_glow_kernel_value(), blender::realtime_compositor::compute_fog_glow_kernel_value(), blender::realtime_compositor::compute_numerator_1(), blender::realtime_compositor::compute_numerator_2(), blender::realtime_compositor::compute_numerator_3(), blender::realtime_compositor::compute_realized_transformation_domain(), blender::nodes::node_composite_glare_cc::GlareOperation::compute_streak_direction(), cos(), cos(), blender::nodes::node_composite_directionalblur_cc::DirectionalBlurOperation::execute(), blender::workbench::filter_blackman_harris(), blender::math::detail::from_rotation(), blender::math::detail::from_rotation(), blender::math::detail::from_rotation(), from_triangle(), blender::ed::greasepencil::generate_arc_from_point_to_point(), blender::ed::greasepencil::grease_pencil_primitive_rotate_all_update(), blender::workbench::SceneResources::load_jitter_tx(), blender::math::AngleFraction< T >::operator AngleCartesianBase< T >(), pow(), blender::ed::sculpt_paint::greasepencil::PaintOperationExecutor::process_extension_sample(), blender::draw::overlay::ring_vertices(), rotate(), blender::ed::sculpt_paint::greasepencil::rotate_by_angle(), blender::rotate_by_angle(), blender::draw::statvis_calc_thickness(), blender::math::tests::TEST(), blender::tests::TEST(), to_quaternion(), to_quaternion(), to_quaternion_legacy(), and blender::write_fill_transforms().

◆ cos() [4/4]

template<typename T >
T blender::math::cos ( const T & a)
inline

Definition at line 154 of file BLI_math_base.hh.

◆ cross() [1/2]

AxisSigned blender::math::cross ( const AxisSigned a,
const AxisSigned b )
inlinenodiscard

Returns the cross direction from two basis direction using the right hand rule. This is much faster than true cross product if the vectors are basis vectors. Any ill-formed case will return a orthogonal axis to a but will also trigger an assert. It is better to filter these cases upstream.

Definition at line 217 of file BLI_math_basis_types.hh.

References abs(), b, BLI_assert_msg, blender::math::AxisSigned::X_NEG, blender::math::AxisSigned::X_POS, blender::math::AxisSigned::Y_NEG, blender::math::AxisSigned::Y_POS, blender::math::AxisSigned::Z_NEG, and blender::math::AxisSigned::Z_POS.

Referenced by blender::math::AxisAngleBase< T, AngleT >::AxisAngleBase(), blender::ed::sculpt_paint::boundary::bend_data_init_bmesh(), blender::ed::sculpt_paint::boundary::bend_data_init_grids(), blender::ed::sculpt_paint::boundary::bend_data_init_mesh(), blender::bke::build_point_matrix(), blender::bke::curves::poly::calculate_next_normal(), blender::ed::sculpt_paint::min_distance_edit::calculate_points_per_side(), blender::nodes::node_fn_axes_to_rotation_cc::AxesToRotationFunction::call(), blender::ed::sculpt_paint::cloth::cloth_brush_apply_brush_foces(), blender::bke::mesh::corner_fan_space_define(), blender::nodes::node_geo_curve_primitive_arc_cc::create_arc_curve_from_points(), blender::nodes::node_geo_curve_primitive_circle_cc::create_point_circle_curve(), blender::nodes::node_geo_scale_elements_cc::create_single_axis_transform(), cross_tri(), blender::deform_drawing(), blender::ed::sculpt_paint::do_clay_strips_brush(), blender::ed::sculpt_paint::do_clay_thumb_brush(), blender::ed::sculpt_paint::do_multiplane_scrape_brush(), blender::ed::sculpt_paint::do_nudge_brush(), blender::ed::sculpt_paint::do_pinch_brush(), blender::ed::sculpt_paint::do_thumb_brush(), blender::geometry::extend_curves_curved(), from_orthonormal_axes(), from_orthonormal_axes(), from_vector(), gizmo_ruler_draw(), blender::ed::greasepencil::grease_pencil_texture_gradient_exec(), blender::ed::view3d::geometry_nodes_gizmos::make_matrix_orthonormal_but_keep_z_axis(), blender::ed::sculpt_paint::min_distance_edit::min_distance_edit_draw(), orthogonalize(), rotate_direction_around_axis(), blender::bke::mesh_surface_sample::sample_surface_points_spherical(), blender::draw::overlay::ShapeCache::ShapeCache(), blender::eevee::Light::sync(), and blender::tests::TEST().

◆ cross() [2/2]

template<typename T >
VecBase< T, 3 > blender::math::cross ( const VecBase< T, 3 > & a,
const VecBase< T, 3 > & b )
inlinenodiscard
Returns
cross perpendicular vector to a and b.
Note
Return zero vector if a and b are collinear.
The length of the resulting vector is equal to twice the area of the triangle between a and b ; and it is equal to the sine of the angle between a and b if they are normalized.
Blender 3D space uses right handedness: a = thumb, b = index, return = middle.

Definition at line 450 of file BLI_math_vector.hh.

References b.

◆ cross_high_precision()

VecBase< float, 3 > blender::math::cross_high_precision ( const VecBase< float, 3 > & a,
const VecBase< float, 3 > & b )
inlinenodiscard

Same as cross(a, b) but use double float precision for the computation.

Definition at line 458 of file BLI_math_vector.hh.

References b, and float.

Referenced by blender::nodes::node_fn_align_euler_to_vector_cc::align_rotations_auto_pivot(), and blender::nodes::node_fn_align_rotation_to_vector_cc::align_rotations_auto_pivot().

◆ cross_poly()

template<typename T >
VecBase< T, 3 > blender::math::cross_poly ( Span< VecBase< T, 3 > > poly)
inlinenodiscard
Parameters
polyArray of points around a polygon. They don't have to be co-planar.
Returns
Best fit plane normal for the given polygon loop or zero vector if point array is too short. Not normalized.

Definition at line 471 of file BLI_math_vector.hh.

References int.

◆ cross_tri()

template<typename T >
VecBase< T, 3 > blender::math::cross_tri ( const VecBase< T, 3 > & v1,
const VecBase< T, 3 > & v2,
const VecBase< T, 3 > & v3 )
inlinenodiscard

Return normal vector to a triangle. The result is not normalized and can be degenerate.

Definition at line 499 of file BLI_math_vector.hh.

References cross(), and v2.

Referenced by normal_tri().

◆ cubic_filter_coefficients()

template<enum eCubicFilter filter>
static float4 blender::math::cubic_filter_coefficients ( float f)
static

Definition at line 30 of file math_interp.cc.

References BSpline, and Mitchell.

Referenced by bicubic_interpolation().

◆ determinant() [1/7]

template double blender::math::determinant ( const double2x2 & mat)

◆ determinant() [2/7]

template double blender::math::determinant ( const double3x3 & mat)

◆ determinant() [3/7]

template double blender::math::determinant ( const double4x4 & mat)

◆ determinant() [4/7]

template float blender::math::determinant ( const float2x2 & mat)

◆ determinant() [5/7]

template float blender::math::determinant ( const float3x3 & mat)

◆ determinant() [6/7]

template float blender::math::determinant ( const float4x4 & mat)

◆ determinant() [7/7]

template<typename T , int Size>
T blender::math::determinant ( const MatBase< T, Size, Size > & mat)
nodiscard

◆ distance() [1/2]

template<typename T >
T blender::math::distance ( const T & a,
const T & b )
inline

Definition at line 125 of file BLI_math_base.hh.

References b.

Referenced by blender::length_parameterize::accumulate_lengths(), blender::ed::sculpt_paint::greasepencil::PaintOperationExecutor::active_smoothing(), blender::ed::sculpt_paint::greasepencil::WeightPaintOperation::add_point_under_brush_to_brush_buffer(), almost_equal_relative(), blender::ed::sculpt_paint::greasepencil::brush_point_influence(), blender::ed::sculpt_paint::auto_mask::calc_blurred_cavity_bmesh(), blender::ed::sculpt_paint::auto_mask::calc_blurred_cavity_grids(), blender::ed::sculpt_paint::auto_mask::calc_blurred_cavity_mesh(), blender::ed::sculpt_paint::calc_brush_cube_distances(), blender::ed::sculpt_paint::calc_brush_cube_distances(), blender::ed::sculpt_paint::trim::calc_expand_factor(), blender::bke::curves::bezier::calculate_aligned_handle(), blender::ed::transform::curves::calculate_curve_point_distances_for_proportional_editing(), blender::ed::space_node::calculate_inner_link_bezier_points(), blender::ed::sculpt_paint::greasepencil::closest_distance_to_surface_2d(), blender::ed::sculpt_paint::cloth::cloth_brush_add_length_constraint(), blender::ed::sculpt_paint::cloth::cloth_brush_simulation_falloff_get(), blender::ed::sculpt_paint::mask::color_delta_get(), blender::ed::sculpt_paint::ScaleCurvesEffect::compute_poly_curve_length(), blender::geometry::curve_constraints::compute_segment_lengths(), blender::nodes::node_geo_curve_primitive_arc_cc::create_arc_curve_from_points(), blender::nodes::node_geo_curve_primitive_circle_cc::create_point_circle_curve(), blender::deform_drawing(), blender::ed::greasepencil::dist_to_interpolated(), blender::ed::sculpt_paint::color::do_smear_brush_task(), blender::ed::sculpt_paint::boundary::edit_data_init_bmesh(), blender::ed::sculpt_paint::boundary::edit_data_init_grids(), blender::ed::sculpt_paint::boundary::edit_data_init_mesh(), fill_crossdata_for_intersect(), blender::bke::pbvh::pixels::Rows::filter_pixels_for_closer_examination(), blender::bke::pbvh::pixels::Rows::find_copy_source(), blender::ed::greasepencil::find_curve_intersections(), blender::find_envelope(), blender::bke::pbvh::pixels::Rows::find_second_source(), blender::ed::sculpt_paint::CurvesEffectOperationExecutor::gather_influences_projected(), blender::get_distance_factor(), blender::bke::greasepencil::Layer::get_frame_duration_at(), gizmo_ruler_draw(), blender::ed::sculpt_paint::grease_pencil_fill_event_modal_map(), blender::ed::sculpt_paint::grease_pencil_fill_extension_cut(), blender::ed::sculpt_paint::grease_pencil_fill_modal(), blender::ed::sculpt_paint::pose::ik_chain_origin_heads_init(), blender::ed::sculpt_paint::greasepencil::EraseOperationExecutor::intersections_segment_circle_integers(), blender::geometry::limit_radius(), blender::ed::sculpt_paint::mask::mask_by_color_contiguous_mesh(), blender::ed::sculpt_paint::min_distance_edit::min_distance_edit_draw(), blender::modify_geometry_set(), blender::ed::sculpt_paint::move_last_point_and_resample(), blender::ed::space_node::node_find_indicated_socket(), blender::ed::sculpt_paint::greasepencil::EraseOperation::on_stroke_done(), blender::ed::sculpt_paint::greasepencil::VertexSmearOperation::on_stroke_extended(), blender::geometry::perpendicular_distance(), blender::ed::greasepencil::polyline_fit_curve(), blender::ed::sculpt_paint::greasepencil::PaintOperationExecutor::process_extension_sample(), blender::ed::sculpt_paint::PuffOperationExecutor::puff(), blender::reorder_strokes(), blender::ed::sculpt_paint::sample_curves_3d_brush(), blender::ed::sculpt_paint::dyntopo::sample_detail_voxel(), blender::ed::sculpt_paint::DensityAddOperationExecutor::sample_projected_with_symmetry(), blender::ed::sculpt_paint::DensityAddOperationExecutor::sample_spherical_with_symmetry(), blender::eevee::ShadowModule::screen_pixel_radius(), blender::ed::sculpt_paint::greasepencil::EraseOperationExecutor::segment_intersections_and_points_sides(), blender::ed::greasepencil::select_similar_exec(), blender::ed::sculpt_paint::greasepencil::EraseOperationExecutor::soft_eraser(), blender::length_parameterize::tests::test_uniform_lengths(), blender::ed::sculpt_paint::transform_brush_radius(), transform_mesh_edge_slide_data_create(), transform_mesh_uv_edge_slide_data_create(), blender::compositor::SunBeamsOperation::update_memory_buffer_partial(), blender::ed::sculpt_paint::pose::vert_inside_brush_radius(), blender::noise::voronoi_distance(), blender::noise::voronoi_distance(), blender::noise::voronoi_distance(), blender::noise::voronoi_n_sphere_radius(), blender::noise::voronoi_n_sphere_radius(), and blender::noise::voronoi_n_sphere_radius().

◆ distance() [2/2]

template<typename T , int Size>
T blender::math::distance ( const VecBase< T, Size > & a,
const VecBase< T, Size > & b )
inlinenodiscard

Definition at line 378 of file BLI_math_vector.hh.

References b, and length().

◆ distance_manhattan()

template<typename T , int Size>
T blender::math::distance_manhattan ( const VecBase< T, Size > & a,
const VecBase< T, Size > & b )
inlinenodiscard

Definition at line 366 of file BLI_math_vector.hh.

References b, and length_manhattan().

◆ distance_squared()

template<typename T , int Size>
T blender::math::distance_squared ( const VecBase< T, Size > & a,
const VecBase< T, Size > & b )
inlinenodiscard

Definition at line 372 of file BLI_math_vector.hh.

References b, and length_squared().

Referenced by blender::ed::greasepencil::add_armature_automatic_weights(), blender::ed::sculpt_paint::cloth::add_constraints_for_verts(), blender::ed::spreadsheet::apply_row_filter(), bm_loop_uv_calc_opposite_co(), blender::ed::sculpt_paint::greasepencil::brush_point_influence_mask(), blender::ed::sculpt_paint::calc_brush_distances_squared(), blender::ed::sculpt_paint::calc_brush_distances_squared(), blender::ed::sculpt_paint::pose::calc_pose_origin_and_factor_bmesh(), blender::ed::sculpt_paint::pose::calc_pose_origin_and_factor_grids(), blender::ed::sculpt_paint::pose::calc_pose_origin_and_factor_mesh(), blender::ed::sculpt_paint::greasepencil::compute_auto_flip(), blender::nodes::node_geo_curve_primitive_arc_cc::create_arc_curve_from_points(), blender::ed::sculpt_paint::DeleteOperationExecutor::delete_projected(), blender::ed::sculpt_paint::DeleteOperationExecutor::delete_spherical(), blender::ed::greasepencil::dist_to_interpolated(), blender::ed::sculpt_paint::fake_neighbor_search_bmesh(), blender::ed::sculpt_paint::fake_neighbor_search_grids(), blender::ed::sculpt_paint::fake_neighbor_search_mesh(), fill_crossdata_for_intersect(), find_closest_edge_in_poly(), blender::find_closest_point(), blender::ed::sculpt_paint::SlideOperationExecutor::find_closest_ray_hit(), blender::ed::sculpt_paint::find_curves_brush_position(), blender::ed::sculpt_paint::SlideOperationExecutor::find_curves_to_slide(), blender::ed::sculpt_paint::SmoothOperationExecutor::find_projected_smooth_factors(), blender::ed::sculpt_paint::SmoothOperationExecutor::find_spherical_smooth_factors(), blender::ed::sculpt_paint::CurvesEffectOperationExecutor::gather_influences_spherical(), blender::ed::sculpt_paint::geometry_preview_lines_update(), blender::ed::sculpt_paint::boundary::get_closest_boundary_vert_bmesh(), blender::ed::sculpt_paint::boundary::get_closest_boundary_vert_grids(), blender::ed::sculpt_paint::boundary::get_closest_boundary_vert_mesh(), blender::nodes::node_geo_sample_nearest_cc::get_closest_mesh_corners(), blender::ed::greasepencil::grease_pencil_primitive_event_modal_map(), blender::ed::greasepencil::grease_pencil_primitive_mouse_event(), blender::ed::sculpt_paint::greasepencil::EraseOperationExecutor::intersections_segment_circle_integers(), jump_flooding_pass(), layerEqual_propfloat2(), blender::ed::sculpt_paint::nearest_vert_calc_bmesh(), blender::ed::sculpt_paint::nearest_vert_calc_grids(), blender::ed::sculpt_paint::nearest_vert_calc_mesh(), blender::ed::sculpt_paint::node_in_sphere(), blender::ed::space_node::node_under_mouse_tweak(), blender::ed::sculpt_paint::greasepencil::VertexAverageOperation::on_stroke_extended(), blender::ed::sculpt_paint::greasepencil::VertexBlurOperation::on_stroke_extended(), blender::ed::sculpt_paint::PinchOperationExecutor::pinch_projected(), blender::ed::sculpt_paint::PinchOperationExecutor::pinch_spherical(), blender::ed::greasepencil::primitive_check_ui_hover(), blender::ed::sculpt_paint::SnakeHookOperatorExecutor::projected_snake_hook(), remove_non_constraint_edges_leave_valid_bmesh(), blender::bke::mesh_surface_sample::sample_nearest_weights(), blender::bke::mesh_surface_sample::sample_surface_points_spherical(), blender::ed::curves::select_circle(), blender::ed::curves::select_circle_mask(), uv_remove_doubles_to_selected_shared_vertex(), view3d_ruler_pick(), and blender::math::QuaternionBase< T >::wrapped_around().

◆ divide_ceil()

template<typename T , int Size>
VecBase< T, Size > blender::math::divide_ceil ( const VecBase< T, Size > & a,
const VecBase< T, Size > & b )
inlinenodiscard

Integer division that returns the ceiling, instead of flooring like normal C division. It is undefined if a is negative or b is not strictly positive.

Definition at line 211 of file BLI_math_vector.hh.

References b, BLI_assert, and result.

Referenced by blender::realtime_compositor::compute_complete_blocks(), blender::realtime_compositor::compute_complete_x_prologues(), blender::realtime_compositor::compute_complete_y_prologues(), blender::realtime_compositor::compute_dispatch_threads_at_least(), blender::realtime_compositor::compute_incomplete_prologues(), blender::compositor::compute_max_tile_velocity(), blender::nodes::node_composite_vec_blur_cc::VectorBlurOperation::compute_max_tile_velocity(), blender::eevee::LightModule::end_sync(), blender::eevee::ShadowModule::end_sync(), blender::eevee::VolumeModule::end_sync(), blender::eevee::Film::init(), blender::eevee::VolumeModule::init(), blender::realtime_compositor::parallel_reduction_dispatch(), blender::eevee::Precompute::Precompute(), blender::eevee::DepthOfField::render(), blender::eevee::MotionBlurModule::render(), blender::eevee::RayTraceModule::render(), blender::eevee::SubsurfaceModule::render(), blender::eevee::ShadowModule::set_view(), blender::eevee::VolumeProbeModule::set_view(), blender::eevee::IrradianceBake::surfels_create(), blender::eevee::AmbientOcclusion::sync(), blender::eevee::DepthOfField::sync(), blender::eevee::Film::sync(), blender::eevee::HiZBuffer::sync(), blender::tests::TEST(), and blender::eevee::Film::write_viewport_compositor_passes().

◆ dominant_axis()

template<typename T >
int blender::math::dominant_axis ( const VecBase< T, 3 > & a)
inlinenodiscard

◆ dot() [1/2]

template<typename T >
T blender::math::dot ( const QuaternionBase< T > & a,
const QuaternionBase< T > & b )
inlinenodiscard

Dot product between two quaternions. Equivalent to vector dot product. Equivalent to component wise multiplication followed by summation of the result.

Definition at line 197 of file BLI_math_quaternion.hh.

References b.

Referenced by blender::ed::sculpt_paint::calc_area_normal_and_center_node_bmesh(), blender::ed::sculpt_paint::calc_area_normal_and_center_node_grids(), blender::ed::sculpt_paint::calc_area_normal_and_center_node_mesh(), blender::ed::sculpt_paint::auto_mask::calc_blurred_cavity_bmesh(), blender::ed::sculpt_paint::auto_mask::calc_blurred_cavity_grids(), blender::ed::sculpt_paint::auto_mask::calc_blurred_cavity_mesh(), blender::ed::sculpt_paint::calc_front_face(), blender::ed::sculpt_paint::calc_front_face(), blender::ed::sculpt_paint::calc_front_face(), blender::ed::sculpt_paint::calc_front_face(), blender::ed::sculpt_paint::calc_front_face(), blender::calc_min_radius_v3v3(), blender::ed::sculpt_paint::cloth::calc_perpendicular_pinch_forces(), calcEdgeSlide_mval_range(), blender::ed::greasepencil::calculate_texture_space(), blender::noise::compute_2d_gabor_kernel(), blender::noise::compute_3d_gabor_kernel(), blender::ed::sculpt_paint::greasepencil::compute_auto_flip(), blender::bke::mesh::corner_fan_space_define(), blender::bke::mesh::corner_space_custom_normal_to_data(), blender::nodes::node_geo_curve_primitive_arc_cc::create_arc_curve_from_points(), blender::compositor::dir_compare(), blender::ed::sculpt_paint::do_bmesh_topology_rake_brush(), blender::ed::sculpt_paint::do_multiplane_scrape_brush(), blender::ed::sculpt_paint::color::do_smear_brush_task(), ED_transform_snap_object_project_all_view3d_ex(), ED_transform_snap_object_project_view3d_ex(), blender::draw::edge_factor_calc< float >(), blender::draw::edge_factor_calc< uint8_t >(), blender::nodes::node_composite_levels_cc::LevelsOperation::execute_single_value(), blender::find_envelope(), blender::ed::greasepencil::generate_arc_from_point_to_point(), blender::ed::greasepencil::generate_corner(), blender::nodes::node_fn_compare_cc::get_multi_function(), blender::ed::sculpt_paint::greasepencil::get_screen_projection_fn(), blender::nodes::node_geo_input_mesh_edge_angle_cc::SignedAngleFieldInput::get_varray_for_context(), blender::nodes::node_geo_input_mesh_face_is_planar_cc::PlanarFieldInput::get_varray_for_context(), blender::ed::greasepencil::grease_pencil_texture_gradient_exec(), blender::ed::sculpt_paint::face_set::init_op_exec(), blender::ed::sculpt_paint::greasepencil::EraseOperationExecutor::intersections_segment_circle_integers(), blender::ed::sculpt_paint::gesture::is_affected(), blender::compositor::is_inside_motion_line(), is_orthogonal(), blender::eevee::ForwardPipeline::material_transparent_add(), blender::bke::mesh::mesh_edges_sharp_tag(), blender::ed::sculpt_paint::auto_mask::normal_calc(), blender::ed::sculpt_paint::expand::normals_falloff_create(), blender::geometry::perpendicular_distance(), blender::eevee::ForwardPipeline::prepass_transparent_add(), blender::ed::sculpt_paint::greasepencil::PaintOperationExecutor::process_extension_sample(), blender::ed::sculpt_paint::project_translations(), blender::eevee::PlanarProbe::reflection_clip_plane_get(), blender::io::grease_pencil::GreasePencilExporter::retrieve_objects(), rotate_direction_around_axis(), blender::bke::mesh_surface_sample::sample_surface_points_projected(), blender::ed::mesh::set_sharpness_by_angle_exec(), blender::compositor::SMAALumaEdgeDetectionPS(), blender::compositor::SMAANeighborhoodBlendingPS(), blender::compositor::SMAASearchDiag1(), blender::compositor::SMAASearchDiag2(), blender::geometry::curve_constraints::solve_length_and_collision_constraints(), blender::bke::mesh::split_corner_normal_fan_do(), blender::math::tests::TEST(), transform_mesh_edge_slide_data_create(), transform_mesh_uv_edge_slide_data_create(), VertSlideData::update_active_edges(), blender::compositor::KeyingScreenOperation::update_memory_buffer_partial(), blender::compositor::KuwaharaAnisotropicStructureTensorOperation::update_memory_buffer_partial(), blender::compositor::KuwaharaClassicOperation::update_memory_buffer_partial(), blender::noise::voronoi_distance_to_edge(), blender::noise::voronoi_distance_to_edge(), and blender::noise::voronoi_distance_to_edge().

◆ dot() [2/2]

template<typename T , int Size>
T blender::math::dot ( const VecBase< T, Size > & a,
const VecBase< T, Size > & b )
inlinenodiscard

Dot product between two vectors. Equivalent to component wise multiplication followed by summation of the result. Equivalent to the cosine of the angle between the two vectors if the vectors are normalized.

Note
prefer using length_manhattan(a) than dot(a, vec(1)) to get the sum of all components.

Definition at line 323 of file BLI_math_vector.hh.

References b, and result.

◆ exp() [1/2]

◆ exp() [2/2]

template<typename T , int Size>
VecBase< T, Size > blender::math::exp ( const VecBase< T, Size > & x)
inlinenodiscard

Definition at line 183 of file BLI_math_vector.hh.

References BLI_UNROLL_MATH_VEC_OP_VEC, and exp().

◆ faceforward()

template<typename T , int Size>
VecBase< T, Size > blender::math::faceforward ( const VecBase< T, Size > & vector,
const VecBase< T, Size > & incident,
const VecBase< T, Size > & reference )
inlinenodiscard

Return vector if incident and reference are pointing in the same direction.

Definition at line 545 of file BLI_math_vector.hh.

References vector.

◆ float_to_half()

uint16_t blender::math::float_to_half ( float v)

Float (FP32) <-> Half (FP16) conversion functions.

Behavior matches hardware (x64 F16C, ARM NEON FCVT), including handling of denormals, infinities, NaNs, rounding is to nearest even, etc. When NaNs are produced, the exact bit pattern might not match hardware, but it will still be a NaN.

When compiling for ARM NEON (e.g. Apple Silicon), hardware VCVT instructions are used.

For anything involving more than a handful of numbers, prefer float_to_half_array and half_to_float_array for performance. Converts float (FP32) number to half-precision (FP16).

Definition at line 27 of file math_half.cc.

References sign(), and v.

Referenced by blender::gpu::convert(), and float_to_half_array().

◆ float_to_half_array()

void blender::math::float_to_half_array ( const float * src,
uint16_t * dst,
size_t length )

Definition at line 221 of file math_half.cc.

References float_to_half(), and length().

Referenced by blender::gpu::convert_buffer(), and blender::tests::TEST().

◆ floor() [1/2]

◆ floor() [2/2]

template<typename T , int Size>
VecBase< T, Size > blender::math::floor ( const VecBase< T, Size > & a)
inlinenodiscard

Definition at line 250 of file BLI_math_vector.hh.

References BLI_UNROLL_MATH_VEC_OP_VEC, and floor().

◆ fract() [1/2]

◆ fract() [2/2]

template<typename T , int Size>
VecBase< T, Size > blender::math::fract ( const VecBase< T, Size > & a)
inlinenodiscard

Definition at line 311 of file BLI_math_vector.hh.

References BLI_UNROLL_MATH_VEC_OP_VEC, and fract().

◆ from_loc_rot()

template<typename MatT , typename RotationT >
MatT blender::math::from_loc_rot ( const typename MatT::loc_type & location,
const RotationT & rotation )
nodiscard

Create a transform matrix with translation and rotation applied in this order.

Definition at line 1410 of file BLI_math_matrix.hh.

References from_rotation().

Referenced by blender::math::tests::TEST(), blender::tests::TEST(), and blender::tests::TEST().

◆ from_loc_rot_scale()

template<typename MatT , typename RotationT , int ScaleDim>
MatT blender::math::from_loc_rot_scale ( const typename MatT::loc_type & location,
const RotationT & rotation,
const VecBase< typename MatT::base_type, ScaleDim > & scale )
nodiscard

◆ from_loc_scale()

template<typename MatT , int ScaleDim>
MatT blender::math::from_loc_scale ( const typename MatT::loc_type & location,
const VecBase< typename MatT::base_type, ScaleDim > & scale )
nodiscard

Create a transform matrix with translation and scale applied in this order.

Definition at line 1420 of file BLI_math_matrix.hh.

References from_scale().

Referenced by blender::draw::overlay::Fluids::object_sync(), and OVERLAY_grease_pencil_cache_init().

◆ from_location()

◆ from_origin_transform()

template<typename MatT , typename VectorT >
MatT blender::math::from_origin_transform ( const MatT & transform,
const VectorT origin )
nodiscard

Construct a transformation that is pivoted around the given origin point. So for instance, from_origin_transform<MatT>(from_rotation(numbers::pi * 0.5), float2(0.0f, 2.0f)) will construct a transformation representing a 90 degree rotation around the point (0, 2).

Definition at line 1567 of file BLI_math_matrix.hh.

References from_location().

◆ from_orthonormal_axes() [1/3]

CartesianBasis blender::math::from_orthonormal_axes ( const AxisSigned forward,
const AxisSigned up )
inlinenodiscard

Create an CartesianBasis using two orthogonal axes. The third axis is chosen by right hand rule to follow blender coordinate system. forward is Y axis in blender coordinate system. up is Z axis in blender coordinate system.

Note
forward and up must be different axes.

Definition at line 405 of file BLI_math_basis_types.hh.

References abs(), BLI_assert, and cross().

Referenced by from_orthonormal_axes(), from_tracking(), rotation_between(), blender::math::tests::TEST(), blender::math::tests::TEST(), and blender::math::tests::TEST().

◆ from_orthonormal_axes() [2/3]

template<typename MatT , typename VectorT >
MatT blender::math::from_orthonormal_axes ( const VectorT forward,
const VectorT up )
nodiscard

Create a rotation matrix from 2 basis vectors. The matrix determinant is given to be positive and it can be converted to other rotation types.

Note
forward and up must be normalized.

Definition at line 1429 of file BLI_math_matrix.hh.

References BLI_assert, cross(), and is_unit_scale().

◆ from_orthonormal_axes() [3/3]

template<typename MatT , typename VectorT >
MatT blender::math::from_orthonormal_axes ( const VectorT location,
const VectorT forward,
const VectorT up )
nodiscard

Create a transform matrix with translation and rotation from 2 basis vectors and a translation.

Note
forward and up must be normalized.

Definition at line 1445 of file BLI_math_matrix.hh.

References from_orthonormal_axes().

◆ from_rot_scale()

template<typename MatT , typename RotationT , typename VectorT >
MatT blender::math::from_rot_scale ( const RotationT & rotation,
const VectorT & scale )
nodiscard

Create a transform matrix with rotation and scale applied in this order.

Definition at line 1392 of file BLI_math_matrix.hh.

References from_rotation(), and from_scale().

Referenced by from_loc_rot_scale().

◆ from_rotation()

◆ from_scale()

template<typename MatT , int ScaleDim>
MatT blender::math::from_scale ( const VecBase< typename MatT::base_type, ScaleDim > & scale)
nodiscard

◆ from_tracking()

template<typename T >
QuaternionBase< T > blender::math::from_tracking ( AxisSigned forward_axis,
Axis up_axis )
nodiscard

Returns a quaternion for converting local space to tracking space. This is slightly different than from_axis_conversion for legacy reasons.

Definition at line 351 of file BLI_math_rotation.hh.

References blender::math::AxisSigned::axis(), BLI_assert, from_orthonormal_axes(), rotation_between(), blender::math::AxisSigned::Y_POS, and blender::math::AxisSigned::Z_POS.

◆ from_triangle() [1/2]

template<typename T >
QuaternionBase< T > blender::math::from_triangle ( const VecBase< T, 3 > & v1,
const VecBase< T, 3 > & v2,
const VecBase< T, 3 > & v3 )
nodiscard

Create a orientation from a triangle plane and the axis formed by the segment(v1, v2).

Definition at line 261 of file BLI_math_rotation.hh.

References from_triangle(), normal_tri(), and v2.

◆ from_triangle() [2/2]

template<typename T >
QuaternionBase< T > blender::math::from_triangle ( const VecBase< T, 3 > & v1,
const VecBase< T, 3 > & v2,
const VecBase< T, 3 > & v3,
const VecBase< T, 3 > & normal )
nodiscard

Create a orientation from a triangle plane and the axis formed by the segment(v1, v2). Takes pre-computed normal from the triangle. Used for Ngons when their normal is known.

Definition at line 227 of file BLI_math_rotation.hh.

References atan2(), conjugate(), cos(), is_zero(), nor, normalize(), q1, safe_acos(), sin(), T, transform_point(), UNUSED_VARS, and v2.

Referenced by from_triangle(), and blender::math::tests::TEST().

◆ from_up_axis()

template<typename MatT , typename VectorT >
MatT blender::math::from_up_axis ( const VectorT up)
nodiscard

Create a rotation matrix from only one up axis. The other axes are chosen to always be orthogonal. The resulting matrix is a basis matrix.

Note
up must be normalized.
This can be used to create a tangent basis from a normal vector.
The output of this function is not given to be same across blender version. Prefer using from_orthonormal_axes for more stable output.

Definition at line 1455 of file BLI_math_matrix.hh.

References b, BLI_assert, is_unit_scale(), sign(), square(), T, blender::MatBase< T, NumCol, NumRow, Alignment >::x_axis(), blender::MatBase< T, NumCol, NumRow, Alignment >::y_axis(), and blender::MatBase< T, NumCol, NumRow, Alignment >::z_axis().

Referenced by blender::tests::TEST().

◆ from_vector()

template<typename T >
QuaternionBase< T > blender::math::from_vector ( const VecBase< T, 3 > & vector,
const AxisSigned track_flag,
const Axis up_flag )
nodiscard

◆ half_to_float()

float blender::math::half_to_float ( uint16_t v)

Converts half-precision (FP16) number to float (FP32).

Definition at line 91 of file math_half.cc.

References exp(), magic(), and v.

Referenced by blender::gpu::convert(), half_to_float_array(), ViewportColorSampleSession::sample(), and blender::tests::TEST().

◆ half_to_float_array()

void blender::math::half_to_float_array ( const uint16_t * src,
float * dst,
size_t length )

Definition at line 257 of file math_half.cc.

References half_to_float(), and length().

Referenced by blender::gpu::convert_buffer(), and blender::tests::TEST().

◆ hypot()

template<typename T >
T blender::math::hypot ( const T & y,
const T & x )
inline

◆ interpolate() [1/11]

template<eAlpha Alpha>
ColorSceneLinear4f< Alpha > blender::math::interpolate ( const ColorSceneLinear4f< Alpha > & a,
const ColorSceneLinear4f< Alpha > & b,
const float t )
inline

Definition at line 21 of file BLI_math_color.hh.

References b, and interpolate().

◆ interpolate() [2/11]

template<eAlpha Alpha>
ColorSceneLinearByteEncoded4b< Alpha > blender::math::interpolate ( const ColorSceneLinearByteEncoded4b< Alpha > & a,
const ColorSceneLinearByteEncoded4b< Alpha > & b,
const float t )
inline

Definition at line 32 of file BLI_math_color.hh.

References b, and interpolate().

◆ interpolate() [3/11]

template double3x3 blender::math::interpolate ( const double3x3 & a,
const double3x3 & b,
double t )

◆ interpolate() [4/11]

template double4x4 blender::math::interpolate ( const double4x4 & a,
const double4x4 & b,
double t )

◆ interpolate() [5/11]

template float3x3 blender::math::interpolate ( const float3x3 & a,
const float3x3 & b,
float t )

◆ interpolate() [6/11]

template float4x4 blender::math::interpolate ( const float4x4 & a,
const float4x4 & b,
float t )

◆ interpolate() [7/11]

template<typename T >
MatBase< T, 3, 3 > blender::math::interpolate ( const MatBase< T, 3, 3 > & a,
const MatBase< T, 3, 3 > & b,
T t )
nodiscard

A polar-decomposition-based interpolation between matrix A and matrix B.

Note
This code is about five times slower than the 'naive' interpolation (it typically remains below 2 usec on an average i74700, while naive implementation remains below 0.4 usec). However, it gives expected results even with non-uniformly scaled matrices, see #46418 for an example.

Based on "Matrix Animation and Polar Decomposition", by Ken Shoemake & Tom Duff

Parameters
AInput matrix which is totally effective with t = 0.0.
BInput matrix which is totally effective with t = 1.0.
tInterpolation factor.

Definition at line 328 of file math_matrix.cc.

References B, interpolate(), interpolate_linear(), normalize(), P, polar_decompose(), and to_quaternion().

◆ interpolate() [8/11]

template<typename T >
MatBase< T, 4, 4 > blender::math::interpolate ( const MatBase< T, 4, 4 > & a,
const MatBase< T, 4, 4 > & b,
T t )
nodiscard

Complete transform matrix interpolation, based on polar-decomposition-based interpolation from interpolate<T, 3, 3>.

Parameters
AInput matrix which is totally effective with t = 0.0.
BInput matrix which is totally effective with t = 1.0.
tInterpolation factor.

Definition at line 372 of file math_matrix.cc.

References A, B, and result.

◆ interpolate() [9/11]

template<typename T >
QuaternionBase< T > blender::math::interpolate ( const QuaternionBase< T > & a,
const QuaternionBase< T > & b,
T t )
inlinenodiscard

Use spherical interpolation between two quaternions. Always interpolate along the shortest angle.

Definition at line 301 of file BLI_math_quaternion.hh.

References b, BLI_assert, interpolate_dot_slerp(), is_unit_scale(), and w().

◆ interpolate() [10/11]

template<typename T , typename FactorT >
T blender::math::interpolate ( const T & a,
const T & b,
const FactorT & t )
inline

Definition at line 239 of file BLI_math_base.hh.

References b, and result.

Referenced by blender::ed::greasepencil::add_armature_automatic_weights(), blender::apply_gradient_tint(), blender::apply_uniform_tint(), blender::ed::sculpt_paint::greasepencil::WeightPaintOperation::apply_weight_to_point(), blender::draw::overlay::Grid::begin_sync(), blender::animrig::blend_layer_results(), blender::calc_min_radius_v3v3(), blender::geometry::calc_position_with_interpolation(), blender::geometry::calc_radius_with_interpolation(), blender::ed::space_node::calculate_inner_link_bezier_points(), blender::bke::curves::bezier::calculate_vector_handle(), blender::io::grease_pencil::GreasePencilExporter::compute_average_stroke_color(), blender::nodes::node_composite_tonemap_cc::ToneMapOperation::compute_global_adaptation_level(), blender::ed::sculpt_paint::greasepencil::EraseOperationExecutor::compute_piecewise_linear_falloff(), blender::ed::greasepencil::control_point_colors_and_sizes(), blender::nodes::node_geo_curve_primitive_arc_cc::create_arc_curve_from_points(), blender::geometry::create_nurbs_to_bezier_positions(), blender::nodes::node_geo_curve_primitive_circle_cc::create_point_circle_curve(), blender::nodes::node_geo_curve_primitive_quadratic_bezier_cc::create_quadratic_bezier_curve(), blender::deform_drawing(), blender::deform_drawing(), blender::deform_drawing_as_envelope(), blender::ed::sculpt_paint::do_multiplane_scrape_brush(), DRW_text_edit_mesh_measure_stats(), blender::nodes::node_composite_zcombine_cc::ZCombineOperation::execute_single_value(), blender::geometry::extend_curves_straight(), blender::ed::space_node::find_bounds_by_zone_recursive(), blender::ed::sculpt_paint::find_curves_brush_position(), blender::find_envelope(), blender::find_plane_intersection(), blender::ed::sculpt_paint::CurvesEffectOperationExecutor::gather_influences_projected(), blender::nodes::node_sh_mix_cc::get_multi_function(), get_next_crossing_from_edge(), blender::nodes::node_composite_keyingscreen_cc::KeyingScreenOperation::get_smoothness(), gizmo_ruler_invoke(), blender::ed::sculpt_paint::grease_pencil_fill_extension_cut(), blender::ed::greasepencil::grease_pencil_vertex_paint_set_exec(), blender::bke::curves::bezier::insert(), interpolate(), interpolate(), interpolate(), interpolate_linear(), blender::length_parameterize::interpolate_to_masked(), layerCopyValue_propfloat2(), blender::bke::subdiv::mesh_interpolate_position_on_edge(), blender::bke::mesh_normals_varray(), blender::bke::attribute_math::mix2(), blender::bke::attribute_math::mix2(), blender::bke::attribute_math::mix2(), blender::bke::attribute_math::mix2(), blender::bke::attribute_math::mix2(), blender::bke::attribute_math::mix2(), blender::bke::attribute_math::mix2(), blender::geometry::mix_arrays(), blender::ed::sculpt_paint::greasepencil::EraseOperation::on_stroke_done(), blender::ed::sculpt_paint::greasepencil::VertexAverageOperation::on_stroke_extended(), blender::ed::sculpt_paint::greasepencil::VertexBlurOperation::on_stroke_extended(), blender::ed::sculpt_paint::greasepencil::VertexPaintOperation::on_stroke_extended(), blender::ed::sculpt_paint::greasepencil::VertexSmearOperation::on_stroke_extended(), OVERLAY_wireframe_cache_init(), blender::geometry::perpendicular_distance(), blender::ed::sculpt_paint::PinchOperationExecutor::pinch_projected(), blender::ed::sculpt_paint::PinchOperationExecutor::pinch_spherical(), blender::ed::greasepencil::primitive_calulate_curve_positions(), blender::ed::sculpt_paint::greasepencil::PaintOperationExecutor::process_extension_sample(), blender::ed::sculpt_paint::PuffOperationExecutor::puff(), blender::ed::sculpt_paint::greasepencil::PaintOperationExecutor::randomize_color(), blender::ed::sculpt_paint::greasepencil::PaintOperationExecutor::randomize_opacity(), blender::ed::sculpt_paint::greasepencil::PaintOperationExecutor::randomize_radius(), blender::ed::sculpt_paint::greasepencil::PaintOperationExecutor::randomize_rotation(), blender::ed::sculpt_paint::color::sculpt_color_presmooth_init(), blender::compositor::KeyingScreenOperation::set_smoothness(), blender::compositor::SMAAMovc(), blender::compositor::SMAAMovc(), blender::ed::sculpt_paint::SmoothOperationExecutor::smooth(), blender::ed::sculpt_paint::greasepencil::EraseOperationExecutor::soft_eraser(), blender::meshintersect::CDTArrangement< T >::split_edge(), blender::table_sample(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), tonemap_rd_photoreceptor(), tonemap_simple(), whitepoint_from_temp_tint(), whitepoint_to_temp_tint(), and WM_gesture_lasso_modal().

◆ interpolate() [11/11]

template<typename T , typename FactorT , int Size>
VecBase< T, Size > blender::math::interpolate ( const VecBase< T, Size > & a,
const VecBase< T, Size > & b,
const FactorT & t )
inlinenodiscard

Per component linear interpolation.

Parameters
tinterpolation factor. Return a if equal 0. Return b if equal 1. Outside of [0..1] range, use linear extrapolation.

Definition at line 524 of file BLI_math_vector.hh.

References b.

◆ interpolate_bilinear_border_byte()

uchar4 blender::math::interpolate_bilinear_border_byte ( const uchar * buffer,
int width,
int height,
float u,
float v )
nodiscard

Bilinear sampling (with black border).

Takes four image samples at floor(u,v) and floor(u,v)+1, and blends them based on fractional parts of u,v. Samples outside the image are turned into transparent black.

Note that you probably want to subtract 0.5 from u,v before this function, to get proper filtering.

Definition at line 474 of file math_interp.cc.

References bilinear_byte_impl(), and v.

Referenced by blender::imbuf::interpolate_bilinear_border_byte(), blender::imbuf::interpolate_bilinear_border_byte(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().

◆ interpolate_bilinear_border_fl() [1/2]

void blender::math::interpolate_bilinear_border_fl ( const float * buffer,
float * output,
int width,
int height,
int components,
float u,
float v )

Definition at line 492 of file math_interp.cc.

References bilinear_fl_impl(), and v.

◆ interpolate_bilinear_border_fl() [2/2]

float4 blender::math::interpolate_bilinear_border_fl ( const float * buffer,
int width,
int height,
float u,
float v )
nodiscard

◆ interpolate_bilinear_byte()

uchar4 blender::math::interpolate_bilinear_byte ( const uchar * buffer,
int width,
int height,
float u,
float v )
nodiscard

Bilinear sampling.

Takes four image samples at floor(u,v) and floor(u,v)+1, and blends them based on fractional parts of u,v. Samples outside the image are clamped to texels at image edge.

Note that you probably want to subtract 0.5 from u,v before this function, to get proper filtering.

Definition at line 480 of file math_interp.cc.

References bilinear_byte_impl(), and v.

Referenced by blender::imbuf::interpolate_bilinear_byte(), blender::imbuf::interpolate_bilinear_byte(), and TEST().

◆ interpolate_bilinear_fl() [1/2]

void blender::math::interpolate_bilinear_fl ( const float * buffer,
float * output,
int width,
int height,
int components,
float u,
float v )

Definition at line 505 of file math_interp.cc.

References bilinear_fl_impl(), and v.

◆ interpolate_bilinear_fl() [2/2]

◆ interpolate_bilinear_wrap_byte()

uchar4 blender::math::interpolate_bilinear_wrap_byte ( const uchar * buffer,
int width,
int height,
float u,
float v )
nodiscard

Wrapped bilinear sampling. (u,v) is repeated to be inside the image size, including properly wrapping samples that are right on the edges.

Definition at line 524 of file math_interp.cc.

References b, BLI_assert, floored_fmod(), floorf, int, and v.

Referenced by blender::imbuf::interpolate_bilinear_wrap_byte(), and TEST().

◆ interpolate_bilinear_wrap_fl() [1/2]

void blender::math::interpolate_bilinear_wrap_fl ( const float * buffer,
float * output,
int width,
int height,
int components,
float u,
float v,
bool wrap_x,
bool wrap_y )

Definition at line 511 of file math_interp.cc.

References bilinear_fl_impl(), and v.

◆ interpolate_bilinear_wrap_fl() [2/2]

float4 blender::math::interpolate_bilinear_wrap_fl ( const float * buffer,
int width,
int height,
float u,
float v )
nodiscard

◆ interpolate_cubic_bspline_byte()

uchar4 blender::math::interpolate_cubic_bspline_byte ( const uchar * buffer,
int width,
int height,
float u,
float v )
nodiscard

Cubic B-Spline sampling.

Takes 4x4 image samples at floor(u,v)-1 .. floor(u,v)+2, and blends them based on fractional parts of u,v. Uses B-Spline variant Mitchell-Netravali filter (B=1, C=0), which has no ringing but introduces quite a lot of blur. Samples outside the image are clamped to texels at image edge.

Note that you probably want to subtract 0.5 from u,v before this function, to get proper filtering.

Definition at line 573 of file math_interp.cc.

References bicubic_interpolation(), and v.

Referenced by blender::imbuf::interpolate_cubic_bspline_byte(), blender::imbuf::interpolate_cubic_bspline_byte(), TEST(), TEST(), TEST(), and TEST().

◆ interpolate_cubic_bspline_fl() [1/2]

void blender::math::interpolate_cubic_bspline_fl ( const float * buffer,
float * output,
int width,
int height,
int components,
float u,
float v )

Definition at line 587 of file math_interp.cc.

References bicubic_interpolation(), and v.

◆ interpolate_cubic_bspline_fl() [2/2]

◆ interpolate_cubic_mitchell_byte()

uchar4 blender::math::interpolate_cubic_mitchell_byte ( const uchar * buffer,
int width,
int height,
float u,
float v )
nodiscard

Cubic Mitchell sampling.

Takes 4x4 image samples at floor(u,v)-1 .. floor(u,v)+2, and blends them based on fractional parts of u,v. Uses Mitchell-Netravali filter (B=C=1/3), which has a good compromise between blur and ringing. Samples outside the image are clamped to texels at image edge.

Note that you probably want to subtract 0.5 from u,v before this function, to get proper filtering.

Definition at line 594 of file math_interp.cc.

References bicubic_interpolation(), and v.

Referenced by blender::imbuf::interpolate_cubic_mitchell_byte(), blender::imbuf::interpolate_cubic_mitchell_byte(), TEST(), TEST(), and TEST().

◆ interpolate_cubic_mitchell_fl() [1/2]

void blender::math::interpolate_cubic_mitchell_fl ( const float * buffer,
float * output,
int width,
int height,
int components,
float u,
float v )

Definition at line 609 of file math_interp.cc.

References bicubic_interpolation(), and v.

◆ interpolate_cubic_mitchell_fl() [2/2]

float4 blender::math::interpolate_cubic_mitchell_fl ( const float * buffer,
int width,
int height,
float u,
float v )
nodiscard

Definition at line 602 of file math_interp.cc.

References bicubic_interpolation(), and v.

Referenced by blender::imbuf::transform::sample_image(), TEST(), and TEST().

◆ interpolate_dot_slerp()

template<typename T >
VecBase< T, 2 > blender::math::interpolate_dot_slerp ( const T t,
const T cosom )
inlinenodiscard

Generic function for implementing slerp (quaternions and spherical vector coords).

Parameters
tfactor in [0..1]
cosomdot product from normalized quaternions.
Returns
calculated weights.

Definition at line 271 of file BLI_math_quaternion.hh.

References abs(), acos(), BLI_assert, e, eps, IN_RANGE_INCL, LIKELY, sin(), T, and w().

Referenced by interpolate().

◆ interpolate_fast() [1/6]

template double3x3 blender::math::interpolate_fast ( const double3x3 & a,
const double3x3 & b,
double t )

References interpolate_fast().

◆ interpolate_fast() [2/6]

template double4x4 blender::math::interpolate_fast ( const double4x4 & a,
const double4x4 & b,
double t )

References interpolate_fast().

◆ interpolate_fast() [3/6]

template float3x3 blender::math::interpolate_fast ( const float3x3 & a,
const float3x3 & b,
float t )

References interpolate_fast().

◆ interpolate_fast() [4/6]

template float4x4 blender::math::interpolate_fast ( const float4x4 & a,
const float4x4 & b,
float t )

References interpolate_fast().

◆ interpolate_fast() [5/6]

template<typename T >
MatBase< T, 3, 3 > blender::math::interpolate_fast ( const MatBase< T, 3, 3 > & a,
const MatBase< T, 3, 3 > & b,
T t )
nodiscard

Naive interpolation implementation, faster than polar decomposition

Note
This code is about five times faster than the polar decomposition. However, it gives un-expected results even with non-uniformly scaled matrices, see #46418 for an example.
Parameters
AInput matrix which is totally effective with t = 0.0.
BInput matrix which is totally effective with t = 1.0.
tInterpolation factor.

Definition at line 389 of file math_matrix.cc.

References b, and interpolate_fast().

Referenced by interpolate_fast(), interpolate_fast(), interpolate_fast(), interpolate_fast(), interpolate_fast(), interpolate_fast(), blender::tests::TEST(), and blender::tests::TEST().

◆ interpolate_fast() [6/6]

template<typename T >
MatBase< T, 4, 4 > blender::math::interpolate_fast ( const MatBase< T, 4, 4 > & a,
const MatBase< T, 4, 4 > & b,
T t )
nodiscard

Naive transform matrix interpolation, based on naive-decomposition-based interpolation from interpolate_fast<T, 3, 3>.

Note
This code is about five times faster than the polar decomposition. However, it gives un-expected results even with non-uniformly scaled matrices, see #46418 for an example.
Parameters
AInput matrix which is totally effective with t = 0.0.
BInput matrix which is totally effective with t = 1.0.
tInterpolation factor.

Definition at line 408 of file math_matrix.cc.

References b, and interpolate_fast().

◆ interpolate_linear()

template<typename T , int NumCol, int NumRow>
MatBase< T, NumCol, NumRow > blender::math::interpolate_linear ( const MatBase< T, NumCol, NumRow > & a,
const MatBase< T, NumCol, NumRow > & b,
T t )
nodiscard

Interpolate each component linearly.

Definition at line 696 of file BLI_math_matrix.hh.

References b, interpolate(), result, and blender::unroll().

Referenced by interpolate().

◆ interpolate_nearest_border_byte() [1/2]

uchar4 blender::math::interpolate_nearest_border_byte ( const uchar * buffer,
int width,
int height,
float u,
float v )
inlinenodiscard

Definition at line 56 of file BLI_math_interp.hh.

References interpolate_nearest_border_byte(), and v.

◆ interpolate_nearest_border_byte() [2/2]

void blender::math::interpolate_nearest_border_byte ( const uchar * buffer,
uchar * output,
int width,
int height,
float u,
float v )
inline

Nearest (point) sampling (with black border).

Returns texel at floor(u,v) integer index. Samples outside the image are turned into transparent black.

Note that it is not "nearest to u,v coordinate", but rather with fractional part truncated (it would be "nearest" if subtracting 0.5 from input u,v).

Definition at line 36 of file BLI_math_interp.hh.

References BLI_assert, int, v, x, and y.

Referenced by blender::imbuf::interpolate_nearest_border_byte(), blender::imbuf::interpolate_nearest_border_byte(), interpolate_nearest_border_byte(), TEST(), and TEST().

◆ interpolate_nearest_border_fl() [1/2]

void blender::math::interpolate_nearest_border_fl ( const float * buffer,
float * output,
int width,
int height,
int components,
float u,
float v )
inline

◆ interpolate_nearest_border_fl() [2/2]

float4 blender::math::interpolate_nearest_border_fl ( const float * buffer,
int width,
int height,
float u,
float v )
inlinenodiscard

Definition at line 85 of file BLI_math_interp.hh.

References interpolate_nearest_border_fl(), and v.

◆ interpolate_nearest_byte() [1/2]

uchar4 blender::math::interpolate_nearest_byte ( const uchar * buffer,
int width,
int height,
float u,
float v )
inlinenodiscard

Definition at line 117 of file BLI_math_interp.hh.

References interpolate_nearest_byte(), and v.

◆ interpolate_nearest_byte() [2/2]

void blender::math::interpolate_nearest_byte ( const uchar * buffer,
uchar * output,
int width,
int height,
float u,
float v )
inline

Nearest (point) sampling.

Returns texel at floor(u,v) integer index. Samples outside the image are clamped to texels at image edge.

Note that it is not "nearest to u,v coordinate", but rather with fractional part truncated (it would be "nearest" if subtracting 0.5 from input u,v).

Definition at line 103 of file BLI_math_interp.hh.

References BLI_assert, clamp(), v, and x.

Referenced by interpolate_nearest_byte().

◆ interpolate_nearest_fl() [1/2]

void blender::math::interpolate_nearest_fl ( const float * buffer,
float * output,
int width,
int height,
int components,
float u,
float v )
inline

◆ interpolate_nearest_fl() [2/2]

float4 blender::math::interpolate_nearest_fl ( const float * buffer,
int width,
int height,
float u,
float v )
inlinenodiscard

Definition at line 138 of file BLI_math_interp.hh.

References interpolate_nearest_fl(), and v.

◆ interpolate_nearest_wrap_byte() [1/2]

uchar4 blender::math::interpolate_nearest_wrap_byte ( const uchar * buffer,
int width,
int height,
float u,
float v )
inlinenodiscard

Definition at line 167 of file BLI_math_interp.hh.

References interpolate_nearest_wrap_byte(), and v.

◆ interpolate_nearest_wrap_byte() [2/2]

void blender::math::interpolate_nearest_wrap_byte ( const uchar * buffer,
uchar * output,
int width,
int height,
float u,
float v )
inline

Wrapped nearest sampling. (u,v) is repeated to be inside the image size.

Definition at line 150 of file BLI_math_interp.hh.

References BLI_assert, floored_fmod(), int, v, and x.

Referenced by blender::imbuf::interpolate_nearest_wrap_byte(), and interpolate_nearest_wrap_byte().

◆ interpolate_nearest_wrap_fl() [1/2]

void blender::math::interpolate_nearest_wrap_fl ( const float * buffer,
float * output,
int width,
int height,
int components,
float u,
float v )
inline

◆ interpolate_nearest_wrap_fl() [2/2]

float4 blender::math::interpolate_nearest_wrap_fl ( const float * buffer,
int width,
int height,
float u,
float v )
inlinenodiscard

Definition at line 191 of file BLI_math_interp.hh.

References interpolate_nearest_wrap_fl(), and v.

◆ invert() [1/10]

CartesianBasis blender::math::invert ( const CartesianBasis & basis)
inlinenodiscard

Return the inverse transformation represented by the given basis. This is conceptually the equivalent to a rotation matrix transpose, but much faster.

Definition at line 460 of file BLI_math_basis_types.hh.

References blender::math::AxisSigned::axis(), blender::math::AxisSigned::is_negative(), result, blender::math::Axis::X, blender::math::CartesianBasis::x(), blender::math::AxisSigned::X_NEG, blender::math::AxisSigned::X_POS, blender::math::Axis::Y, blender::math::CartesianBasis::y(), blender::math::AxisSigned::Y_NEG, blender::math::AxisSigned::Y_POS, blender::math::Axis::Z, blender::math::CartesianBasis::z(), blender::math::AxisSigned::Z_NEG, and blender::math::AxisSigned::Z_POS.

Referenced by blender::ed::object::apply_objects_internal(), blender::ed::greasepencil::bake_grease_pencil_animation_exec(), BKE_grease_pencil_point_coords_apply(), BKE_grease_pencil_point_coords_apply_with_mat4(), blender::nodes::node_fn_invert_matrix_cc::InvertMatrixFunction::call(), chromatic_adaption_matrix(), blender::ed::sculpt_paint::CombOperationExecutor::comb_projected(), blender::draw::View::compute_visibility(), blender::geometry::copy_transformed_normals(), blender::bke::CurvesSurfaceTransforms::CurvesSurfaceTransforms(), blender::eevee::ShadowTileMap::debug_draw(), blender::nodes::node_geo_deform_curves_on_surface_cc::deform_curves(), blender::ed::sculpt_paint::DeleteOperationExecutor::delete_projected(), blender::ed::sculpt_paint::do_clay_strips_brush(), blender::ed::sculpt_paint::do_multiplane_scrape_brush(), blender::eevee::VolumeModule::draw_prepass(), blender::ed::greasepencil::DrawingPlacement::DrawingPlacement(), blender::ed::greasepencil::DrawingPlacement::DrawingPlacement(), DRW_debug_m4_as_bbox(), blender::draw::overlay::Particles::dupli_matrix_get(), blender::nodes::node_composite_stabilize2d_cc::Stabilize2DOperation::execute(), blender::ed::sculpt_paint::PuffOperationExecutor::find_curve_weights_projected(), blender::ed::sculpt_paint::SmoothOperationExecutor::find_projected_smooth_factors(), blender::ed::sculpt_paint::CurvesEffectOperationExecutor::gather_influences_projected(), blender::get_mirror_matrix(), blender::ed::sculpt_paint::greasepencil::get_screen_projection_fn(), blender::draw::grease_pencil_geom_batch_ensure(), blender::ed::greasepencil::grease_pencil_paste_strokes_exec(), blender::ed::greasepencil::grease_pencil_snap_to_cursor_exec(), blender::ed::greasepencil::grease_pencil_snap_to_grid_exec(), invert(), blender::ed::greasepencil::join_object_with_active(), blender::ed::greasepencil::merge_layers(), blender::geometry::merge_layers(), blender::geometry::boolean::mesh_bm_concat(), blender::ed::sculpt_paint::multiplane_scrape_preview_draw(), nearest_world_tree(), blender::nodes::node_fn_invert_rotation_cc::node_build_multi_function(), blender::nodes::node_fn_matrix_multiply_cc::node_eval_inverse(), blender::ed::object::object_origin_set_exec(), blender::ed::sculpt_paint::greasepencil::CloneOperation::on_stroke_begin(), blender::ed::sculpt_paint::SelectionPaintOperationExecutor::paint_curve_selection_projected(), blender::ed::sculpt_paint::SelectionPaintOperationExecutor::paint_point_selection_projected(), blender::ed::curves::convert_from_particle_system::particles_to_curves(), blender::io::grease_pencil::persmat_from_camera_object(), blender::ed::sculpt_paint::PinchOperationExecutor::pinch_projected(), blender::ed::sculpt_paint::greasepencil::process_stroke_weights(), blender::ed::sculpt_paint::SnakeHookOperatorExecutor::projected_snake_hook(), raycastMesh(), blender::realtime_compositor::realize_on_domain(), rotation_between(), blender::ed::sculpt_paint::sample_curves_3d_brush(), blender::ed::sculpt_paint::DensityAddOperationExecutor::sample_projected_with_symmetry(), blender::ed::sculpt_paint::sculpt_init_mirror_clipping(), sculpt_update_object(), blender::eevee::VolumeProbeModule::set_view(), blender::ed::sculpt_paint::SlideOperationExecutor::slide(), snapCamera(), blender::draw::View::sync(), blender::eevee::Camera::sync(), blender::eevee::ShadowTileMap::sync_cubeface(), blender::math::tests::TEST(), blender::math::tests::TEST(), blender::tests::TEST(), to_dual_quaternion(), blender::bke::transform_normals(), blender::bke::crazyspace::GeometryDeformation::translation_from_deformed_to_original(), blender::ed::curves::convert_to_particle_system::try_convert_single_object(), blender::draw::image_engine::OneTexture::update_bounds(), blender::draw::image_engine::ScreenTileTextures< Divisions >::update_bounds(), blender::ed::view3d::geometry_nodes_gizmos::TransformGizmos::update_rotate_transform_and_target_property(), blender::ed::view3d::geometry_nodes_gizmos::TransformGizmos::update_scale_transform_and_target_property(), blender::ed::view3d::geometry_nodes_gizmos::TransformGizmos::update_translate_transform_and_target_property(), view3d_ruler_item_mousemove(), blender::draw::volume_grid_cache_get(), and workbench_render_to_image().

◆ invert() [2/10]

template double2x2 blender::math::invert ( const double2x2 & mat,
bool & r_success )

◆ invert() [3/10]

template double3x3 blender::math::invert ( const double3x3 & mat,
bool & r_success )

◆ invert() [4/10]

template double4x4 blender::math::invert ( const double4x4 & mat,
bool & r_success )

◆ invert() [5/10]

template float2x2 blender::math::invert ( const float2x2 & mat,
bool & r_success )

◆ invert() [6/10]

template float3x3 blender::math::invert ( const float3x3 & mat,
bool & r_success )

◆ invert() [7/10]

template float4x4 blender::math::invert ( const float4x4 & mat,
bool & r_success )

◆ invert() [8/10]

template<typename T , int Size>
MatBase< T, Size, Size > blender::math::invert ( const MatBase< T, Size, Size > & mat)
nodiscard

Definition at line 609 of file BLI_math_matrix.hh.

References invert().

◆ invert() [9/10]

template<typename T , int Size>
MatBase< T, Size, Size > blender::math::invert ( const MatBase< T, Size, Size > & mat,
bool & r_success )
nodiscard

Returns the inverse of a square matrix or zero matrix on failure. r_success is optional and set to true if the matrix was inverted successfully.

Definition at line 195 of file math_matrix.cc.

References blender::MatBase< T, NumCol, NumRow, Alignment >::base_ptr(), M, R, and result.

◆ invert() [10/10]

template<typename T >
QuaternionBase< T > blender::math::invert ( const QuaternionBase< T > & q)
inlinenodiscard

Return invert of q or identity if q is ill-formed. The invert allows quaternion division.

Note
The inverse of q isn't the opposite rotation. This would be the conjugate.

Definition at line 232 of file BLI_math_quaternion.hh.

References conjugate(), blender::math::QuaternionBase< T >::identity(), length_squared(), and T.

◆ invert_normalized()

template<typename T >
QuaternionBase< T > blender::math::invert_normalized ( const QuaternionBase< T > & q)
inlinenodiscard

Return invert of q assuming it is a unit quaternion. In this case, the inverse is just the conjugate. conjugate(q) could be use directly, but this function shows the intent better, and asserts if q ever becomes non-unit-length.

Definition at line 242 of file BLI_math_quaternion.hh.

References BLI_assert, conjugate(), and is_unit_scale().

Referenced by blender::math::QuaternionBase< T >::swing(), blender::math::tests::TEST(), and blender::math::QuaternionBase< T >::wrapped_around().

◆ is_any_zero() [1/2]

template<typename T >
bool blender::math::is_any_zero ( const T & a)
inline

Definition at line 28 of file BLI_math_base.hh.

References is_zero().

◆ is_any_zero() [2/2]

template<typename T , int Size>
bool blender::math::is_any_zero ( const VecBase< T, Size > & a)
inlinenodiscard

Returns true if at least one component is exactly equal to 0.

Definition at line 685 of file BLI_math_vector.hh.

References T.

◆ is_equal() [1/3]

template<typename T , int NumCol, int NumRow>
bool blender::math::is_equal ( const MatBase< T, NumCol, NumRow > & a,
const MatBase< T, NumCol, NumRow > & b,
const T epsilon = T(0) )
inlinenodiscard

◆ is_equal() [2/3]

template<typename T >
bool blender::math::is_equal ( const QuaternionBase< T > & a,
const QuaternionBase< T > & b,
const T epsilon = T(0) )
inlinenodiscard

Returns true if the quaternions are equal within the given epsilon. Return false otherwise.

Definition at line 115 of file BLI_math_quaternion.hh.

References abs(), and b.

◆ is_equal() [3/3]

template<typename T , int Size>
bool blender::math::is_equal ( const VecBase< T, Size > & a,
const VecBase< T, Size > & b,
const T epsilon = T(0) )
inlinenodiscard

Returns true if vectors are equal within the given epsilon.

Definition at line 653 of file BLI_math_vector.hh.

References abs(), and b.

◆ is_negative() [1/4]

template bool blender::math::is_negative ( const double4x4 & mat)

◆ is_negative() [2/4]

template bool blender::math::is_negative ( const float4x4 & mat)

◆ is_negative() [3/4]

template<typename T >
bool blender::math::is_negative ( const MatBase< T, 4, 4 > & mat)
nodiscard

◆ is_negative() [4/4]

template<typename T , int Size>
bool blender::math::is_negative ( const MatBase< T, Size, Size > & mat)
nodiscard

Returns true if matrix has inverted handedness.

Note
It doesn't use determinant(mat4x4) as only the 3x3 components are needed when the matrix is used as a transformation to represent location/scale/rotation.

Definition at line 476 of file BLI_math_matrix.hh.

References determinant(), and T.

Referenced by blender::geometry::boolean::mesh_bm_concat(), blender::math::detail::normalized_to_quat_fast(), blender::math::AngleFraction< T >::operator AngleCartesianBase< T >(), blender::math::AngleFraction< T >::radian(), blender::tests::TEST(), to_dual_quaternion(), to_rot_scale(), to_rot_scale(), to_scale(), and to_scale().

◆ is_normalized()

template<typename T >
bool blender::math::is_normalized ( const DualQuaternionBase< T > & dq)
inlinenodiscard

Returns true if the DualQuaternion has not been mixed with other DualQuaternion and needs no normalization.

Definition at line 286 of file BLI_math_quaternion_types.hh.

References blender::math::DualQuaternionBase< T >::quat_weight, and T.

Referenced by blender::draw::evaluate_vertex_weight(), blender::math::detail::from_rotation(), and transform_point().

◆ is_orthogonal()

template<typename MatT >
bool blender::math::is_orthogonal ( const MatT & mat)
inlinenodiscard

Test if the X, Y and Z axes are perpendicular with each other.

Definition at line 503 of file BLI_math_matrix.hh.

References abs(), and dot().

Referenced by is_orthonormal(), is_uniformly_scaled(), and blender::tests::TEST().

◆ is_orthonormal()

template<typename MatT >
bool blender::math::is_orthonormal ( const MatT & mat)
inlinenodiscard

◆ is_uniformly_scaled()

template<typename MatT >
bool blender::math::is_uniformly_scaled ( const MatT & mat)
inlinenodiscard

Test if the X, Y and Z axes are perpendicular with each other and the same length.

Definition at line 540 of file BLI_math_matrix.hh.

References abs(), e, eps, is_orthogonal(), length_squared(), and z().

Referenced by blender::tests::TEST().

◆ is_unit()

template<typename T , int Size>
bool blender::math::is_unit ( const VecBase< T, Size > & a,
const T epsilon = T(10) * std::numeric_limits<T>::epsilon() )
inlinenodiscard

Return true if the squared length of the vector is (almost) equal to 1 (with a 10 * std::numeric_limits<T>::epsilon() epsilon error by default).

Definition at line 700 of file BLI_math_vector.hh.

References abs(), length_squared(), and T.

Referenced by rotate_direction_around_axis().

◆ is_unit_scale() [1/3]

◆ is_unit_scale() [2/3]

template<typename T >
bool blender::math::is_unit_scale ( const QuaternionBase< T > & q)
inlinenodiscard

◆ is_unit_scale() [3/3]

template<typename T , int Size>
bool blender::math::is_unit_scale ( const VecBase< T, Size > & v)
inlinenodiscard

Return true if each individual column is unit scaled. Mainly for assert usage.

Definition at line 355 of file BLI_math_vector.hh.

References abs(), length_squared(), T, and v.

◆ is_zero() [1/4]

template<typename T , int NumCol, int NumRow>
bool blender::math::is_zero ( const MatBase< T, NumCol, NumRow > & mat)
inline

Definition at line 554 of file BLI_math_matrix.hh.

References is_zero().

◆ is_zero() [2/4]

template<typename T >
bool blender::math::is_zero ( const QuaternionBase< T > & q)
inlinenodiscard

◆ is_zero() [3/4]

template<typename T >
bool blender::math::is_zero ( const T & a)
inline

Definition at line 23 of file BLI_math_base.hh.

References T.

Referenced by blender::nodes::node_fn_align_euler_to_vector_cc::align_rotations_auto_pivot(), blender::nodes::node_fn_align_rotation_to_vector_cc::align_rotations_auto_pivot(), blender::nodes::node_fn_align_euler_to_vector_cc::align_rotations_fixed_pivot(), blender::nodes::node_fn_align_rotation_to_vector_cc::align_rotations_fixed_pivot(), blender::ed::sculpt_paint::cloth::apply_filter_forces_bmesh(), blender::ed::sculpt_paint::cloth::apply_filter_forces_grids(), blender::ed::sculpt_paint::cloth::apply_filter_forces_mesh(), blender::apply_stroke_transform(), BKE_mesh_translate(), blender::ed::sculpt_paint::cloth::calc_forces_bmesh(), blender::ed::sculpt_paint::cloth::calc_forces_grids(), blender::ed::sculpt_paint::cloth::calc_forces_mesh(), blender::calc_radius_limit(), blender::ed::sculpt_paint::smooth::calc_relaxed_translations_bmesh(), blender::ed::sculpt_paint::smooth::calc_relaxed_translations_faces(), blender::ed::sculpt_paint::smooth::calc_relaxed_translations_grids(), blender::bke::curves::poly::calculate_next_normal(), blender::bke::curves::poly::calculate_normals_minimum(), blender::ed::sculpt_paint::min_distance_edit::calculate_points_per_side(), blender::bke::curves::poly::calculate_tangents(), blender::nodes::node_fn_axes_to_rotation_cc::AxesToRotationFunction::call(), blender::nodes::node_fn_combine_transform_cc::CombineTransformFunction::call(), blender::ed::sculpt_paint::cloth::cloth_brush_apply_brush_foces(), blender::nodes::node_geo_scale_elements_cc::create_single_axis_transform(), blender::ed::sculpt_paint::do_bmesh_topology_rake_brush(), blender::ed::sculpt_paint::do_clay_strips_brush(), blender::ed::sculpt_paint::do_clay_thumb_brush(), blender::ed::sculpt_paint::do_pinch_brush(), drawEdgeSlide(), edge_slide_snap_apply(), blender::geometry::extend_curves_straight(), blender::bke::mesh::face_normal_calc(), blender::find_envelope(), blender::bke::float2_to_bool(), blender::bke::float3_to_bool(), from_triangle(), blender::ed::greasepencil::generate_arc_from_point_to_point(), blender::nodes::node_fn_axes_to_rotation_cc::get_orthogonal_of_non_zero_vector(), blender::bke::int2_to_bool(), is_any_zero(), blender::nodes::node_composite_displace_cc::DisplaceOperation::is_identity(), is_zero(), blender::ed::sculpt_paint::min_distance_edit::min_distance_edit_draw(), blender::nodes::node_fn_axis_angle_to_rotation_cc::node_build_multi_function(), blender::nodes::node_fn_rotation_to_axis_angle_cc::node_eval_inverse(), blender::ed::transform::node_snap_grid_apply(), blender::geometry::perpendicular_distance(), project(), rotate_direction_around_axis(), blender::bke::rotate_directions_around_axes(), blender::tests::TEST(), blender::bke::CurvesGeometry::translate(), blender::geometry::translate_pointcloud(), blender::bke::greasepencil::update_curve_plane_normal_cache(), blender::ed::view3d::geometry_nodes_gizmos::DialGizmo::update_transform(), blender::ed::view3d::geometry_nodes_gizmos::LinearGizmo::update_transform(), and vpaint_proj_dm_map_cosnos_init__map_cb().

◆ is_zero() [4/4]

template<typename T , int Size>
bool blender::math::is_zero ( const VecBase< T, Size > & a,
const T epsilon = T(0) )
inlinenodiscard

Return true if the absolute values of all components are smaller than given epsilon (0 by default).

Note
Does not compute the actual length of the vector, for performance.

Definition at line 672 of file BLI_math_vector.hh.

References abs().

◆ isect_seg_seg() [1/3]

template<>
isect_result< double2 > blender::math::isect_seg_seg ( const double2 & v1,
const double2 & v2,
const double2 & v3,
const double2 & v4 )

◆ isect_seg_seg() [2/3]

template<>
isect_result< float2 > blender::math::isect_seg_seg ( const float2 & v1,
const float2 & v2,
const float2 & v3,
const float2 & v4 )

◆ isect_seg_seg() [3/3]

template<typename T , int Size>
isect_result< VecBase< T, Size > > blender::math::isect_seg_seg ( const VecBase< T, Size > & v1,
const VecBase< T, Size > & v2,
const VecBase< T, Size > & v3,
const VecBase< T, Size > & v4 )
nodiscard

◆ length()

template<typename T , int Size>
T blender::math::length ( const VecBase< T, Size > & a)
inlinenodiscard

Definition at line 349 of file BLI_math_vector.hh.

References length_squared(), and sqrt().

Referenced by blender::apply_gradient_tint(), blender::ed::sculpt_paint::calc_distances(), blender::bke::curves::bezier::calculate_point_handles(), blender::ed::sculpt_paint::min_distance_edit::calculate_points_per_side(), blender::nodes::node_shader_tex_gradient_cc::GradientFunction::call(), blender::ed::sculpt_paint::cloth::cloth_brush_satisfy_constraints(), blender::noise::compute_3d_orientation(), blender::compositor::compute_motion_line(), createEdgeSlideVerts(), blender::ed::sculpt_paint::do_elastic_deform_brush(), blender::ed::sculpt_paint::color::do_smear_brush_task(), blender::nodes::node_composite_sunbeams_cc::SunBeamsOperation::execute(), blender::geometry::extend_curves_straight(), blender::find_envelope(), blender::draw::View::frustum_culling_planes_calc(), blender::noise::gabor(), blender::noise::gabor(), blender::compositor::gather_blur(), blender::ed::sculpt_paint::CurvesEffectOperationExecutor::gather_influences_spherical(), blender::compositor::gather_sample(), blender::ed::greasepencil::generate_corner(), blender::generate_curves(), blender::ed::greasepencil::trim::get_intersection_distance_of_segments(), blender::nodes::node_composite_directionalblur_cc::DirectionalBlurOperation::get_iterations(), blender::nodes::node_fn_compare_cc::get_multi_function(), blender::nodes::node_composite_directionalblur_cc::DirectionalBlurOperation::get_translation(), blender::ed::greasepencil::grease_pencil_primitive_scale_all_update(), blender::ed::sculpt_paint::filter::mesh_filter_sharpen_init(), blender::modify_drawing(), blender::nodes::node_geo_mesh_primitive_line_cc::node_geo_exec(), blender::ed::greasepencil::pixel_radius_to_world_space_radius(), blender::imbuf::transform::process_scanlines(), blender::compositor::SMAANeighborhoodBlendingPS(), blender::realtime_compositor::SymmetricBlurWeights::SymmetricBlurWeights(), to_axis_angle(), blender::math::projection::translate(), blender::compositor::SunBeamsOperation::update_memory_buffer_partial(), blender::ed::view3d::geometry_nodes_gizmos::LinearGizmo::update_transform(), blender::ed::view3d::geometry_nodes_gizmos::TransformGizmos::update_translate_transform_and_target_property(), and blender::compositor::velocity_atomic_max_value().

◆ length_manhattan()

template<typename T , int Size>
T blender::math::length_manhattan ( const VecBase< T, Size > & a)
inlinenodiscard

Returns summation of all components.

Definition at line 335 of file BLI_math_vector.hh.

References abs(), and result.

Referenced by distance_manhattan(), to_euler(), to_euler(), to_nearest_euler(), and to_nearest_euler().

◆ length_squared()

◆ max() [1/2]

template<typename T >
T blender::math::max ( const T & a,
const T & b )
inline

Definition at line 48 of file BLI_math_base.hh.

References b.

Referenced by blender::eevee::RenderBuffers::acquire(), bicubic_interpolation(), blender::gpu::render_graph::VKUpdateMipmapsNode::build_commands(), blender::nodes::node_shader_tex_noise_cc::NoiseFunction::call(), blender::nodes::node_composite_bokehblur_cc::BokehBlurOperation::compute_blur_radius(), blender::nodes::node_composite_tonemap_cc::ToneMapOperation::compute_log_maximum_luminance(), blender::nodes::node_composite_tonemap_cc::ToneMapOperation::compute_log_minimum_luminance(), blender::compositor::compute_motion_rect(), blender::realtime_compositor::compute_sigma_from_radius(), blender::create_array_copies(), blender::bke::create_attribute_providers_for_mesh(), blender::deform_drawing(), blender::deform_drawing(), draw_strip_thumbnails(), blender::imbuf::transform::edge_aa(), blender::eevee::LightModule::end_sync(), blender::eevee::VolumeModule::end_sync(), evaluate_film_like(), blender::nodes::node_composite_zcombine_cc::ZCombineOperation::execute_single_value(), blender::geometry::extend_curves_curved(), fcurve_to_keylist(), blender::ed::greasepencil::fill_strokes(), blender::ed::greasepencil::fit_strokes_to_view(), blender::noise::gabor(), blender::noise::gabor(), gaussian_blur_x(), gaussian_blur_y(), blender::compositor::SMAAOperation::get_area_of_interest(), blender::realtime_compositor::Context::get_compositing_region_size(), blender::get_distance_factor(), blender::compositor::KuwaharaAnisotropicOperation::get_eccentricity(), blender::nodes::node_composite_kuwahara_cc::ConvertKuwaharaOperation::get_eccentricity(), blender::nodes::node_composite_defocus_cc::DefocusOperation::get_f_stop(), blender::get_factor_from_draw_speed(), blender::nodes::node_composite_defocus_cc::DefocusOperation::get_focal_length(), blender::ed::greasepencil::trim::get_intersections_of_curve_with_curves(), blender::ed::greasepencil::get_minmax_selected_frame_numbers(), blender::nodes::node_fn_integer_math_cc::get_multi_function(), blender::nodes::node_composite_scale_cc::ScaleOperation::get_scale_render_size_crop(), glow_blur_bitmap(), blender::draw::grease_pencil_geom_batch_ensure(), blender::ed::greasepencil::grease_pencil_stroke_simplify_exec(), blender::ed::greasepencil::grease_pencil_vertex_paint_brightness_contrast_exec(), blender::eevee::Sampling::init(), blender::bounds::intersect(), blender::Bounds< blender::VecBase >::is_empty(), blender::compositor::jump_flooding(), blender::realtime_compositor::jump_flooding(), max(), max_inplace(), min_max(), min_max(), blender::modify_drawing(), blender::ed::space_node::node_frame_rect_inside(), blender::ed::space_node::node_get_resize_direction(), blender::draw::overlay::Bounds::object_sync(), blender::ed::sculpt_paint::greasepencil::RandomizeOperation::on_stroke_extended(), blender::ed::sculpt_paint::greasepencil::VertexPaintOperation::on_stroke_extended(), ScaleUpX::op(), ScaleUpY::op(), blender::point_counts_to_keep_concurrent(), blender::ed::sculpt_paint::greasepencil::PaintOperationExecutor::process_extension_sample(), blender::seq::query_thumbnail(), blender::eevee::IrradianceBake::raylists_build(), blender::reorder_strokes(), blender::ed::greasepencil::retrieve_editable_drawings_grouped_per_frame(), blender::compositor::SMAALumaEdgeDetectionPS(), blender::compositor::SMAANeighborhoodBlendingPS(), blender::ed::space_node::socket_link_connection_location(), blender::ed::sculpt_paint::greasepencil::EraseOperationExecutor::soft_eraser(), blender::eevee::HiZBuffer::sync(), blender::eevee::SyncModule::sync_mesh(), blender::eevee::SyncModule::sync_sculpt(), text_gaussian_blur_x(), text_gaussian_blur_y(), tonemap_calc_chunk_luminance(), tonemap_simple(), blender::geometry::tri_to_cell_bounds(), blender::compositor::GlareThresholdOperation::update_memory_buffer_partial(), blender::compositor::KuwaharaAnisotropicStructureTensorOperation::update_memory_buffer_partial(), blender::compositor::KuwaharaClassicOperation::update_memory_buffer_partial(), blender::compositor::SunBeamsOperation::update_memory_buffer_partial(), blender::compositor::VariableSizeBokehBlurOperation::update_memory_buffer_partial(), and blender::ed::greasepencil::vertex_group_normalize_exec().

◆ max() [2/2]

template<typename T , int Size>
VecBase< T, Size > blender::math::max ( const VecBase< T, Size > & a,
const VecBase< T, Size > & b )
inlinenodiscard

Definition at line 64 of file BLI_math_vector.hh.

References b, BLI_UNROLL_MATH_VEC_FUNC_VEC_VEC, and max().

◆ max_inplace()

◆ midpoint() [1/2]

template<typename T >
T blender::math::midpoint ( const T & a,
const T & b )
inline

See std::midpoint from C++20.

Definition at line 248 of file BLI_math_base.hh.

References b, sign(), and T.

Referenced by BKE_gpencil_centroid_3d(), blender::bke::pbvh::build_nodes_recursive_grids(), blender::bke::pbvh::build_nodes_recursive_mesh(), blender::bke::calc_edge_centers(), blender::ed::sculpt_paint::filter::calc_sphere_translations(), blender::Bounds< T >::center(), blender::nodes::node_geo_curve_primitive_arc_cc::create_arc_curve_from_points(), blender::ed::sculpt_paint::do_multiplane_scrape_brush(), edbm_rip_edge_side_measure(), blender::ed::sculpt_paint::ensure_valid_pivot(), find_closest_edge_in_poly(), gpencil_depth_plane(), gpencil_object_cache_add(), blender::ed::greasepencil::grease_pencil_snap_cursor_to_sel_exec(), blender::bke::int2_to_int(), blender::ed::seq::make_vectorscope_view_from_ibuf(), blender::ed::space_node::node_group_make_insert_selected(), blender::ed::object::object_origin_set_exec(), blender::draw::overlay::Bounds::object_sync(), blender::workbench::Instance::object_sync(), OVERLAY_bounds(), paint_init_pivot_curves(), paint_init_pivot_grease_pencil(), paint_init_pivot_mesh(), blender::bke::pbvh::pbvh_bmesh_node_limit_ensure_fast(), blender::bke::pbvh::pbvh_bmesh_node_split(), blender::draw::Manager::resource_handle_for_sculpt(), blender::ed::sculpt_paint::dyntopo::sculpt_detail_flood_fill_exec(), blender::ed::sculpt_paint::SmoothOperationExecutor::smooth(), blender::eevee::IrradianceBake::surfel_raster_views_sync(), blender::eevee::SyncModule::sync_sculpt(), blender::tests::TEST(), transform_mesh_edge_slide_data_create(), transform_mesh_uv_edge_slide_data_create(), view3d_ob_drop_matrix_from_snap(), and view3d_orbit_calc_center().

◆ midpoint() [2/2]

template<typename T , int Size>
VecBase< T, Size > blender::math::midpoint ( const VecBase< T, Size > & a,
const VecBase< T, Size > & b )
inlinenodiscard
Returns
Point halfway between a and b.

Definition at line 535 of file BLI_math_vector.hh.

References b.

◆ min() [1/2]

template<typename T >
T blender::math::min ( const T & a,
const T & b )
inline

Definition at line 43 of file BLI_math_base.hh.

References b.

Referenced by bicubic_interpolation(), blur_isolate_highlights(), blender::ed::space_node::calculate_inner_link_bezier_points(), blender::ed::sculpt_paint::greasepencil::closest_distance_to_surface_2d(), blender::nodes::node_composite_defocus_cc::DefocusOperation::compute_maximum_defocus_radius(), blender::compositor::compute_motion_rect(), blender::eevee::VolumeModule::draw_prepass(), blender::eevee::VolumeModule::end_sync(), evaluate_film_like(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_bloom(), blender::geometry::extend_curves_curved(), fcurve_to_keylist(), find_first_points(), blender::ed::greasepencil::fit_strokes_to_view(), blender::index_mask::IndexMask::foreach_segment_zipped(), blender::noise::fractal_voronoi_distance_to_edge(), gaussian_blur_x(), gaussian_blur_y(), blender::compositor::GlareBloomOperation::generate_glare(), blender::get_factor_from_draw_speed(), blender::ed::greasepencil::trim::get_intersections_of_curve_with_curves(), blender::nodes::node_composite_directionalblur_cc::DirectionalBlurOperation::get_iterations(), blender::ed::greasepencil::get_minmax_selected_frame_numbers(), blender::nodes::node_fn_integer_math_cc::get_multi_function(), blender::nodes::node_composite_scale_cc::ScaleOperation::get_scale_render_size_fit(), glow_blur_bitmap(), blender::bounds::intersect(), blender::Bounds< blender::VecBase >::is_empty(), min(), min_inplace(), min_max(), min_max(), blender::modify_geometry_set(), blender::ed::space_node::node_add_file_modal(), blender::ed::space_node::node_insert_offset_modal(), blender::ed::greasepencil::retrieve_editable_drawings_grouped_per_frame(), blender::ed::sculpt_paint::greasepencil::EraseOperationExecutor::soft_eraser(), blender::compositor::summed_area_table_sum(), blender::tests::TEST(), TEST(), text_gaussian_blur_x(), text_gaussian_blur_y(), tonemap_calc_chunk_luminance(), blender::geometry::tri_to_cell_bounds(), blender::compositor::ConvertDepthToRadiusOperation::update_memory_buffer_partial(), blender::compositor::KuwaharaAnisotropicStructureTensorOperation::update_memory_buffer_partial(), blender::compositor::KuwaharaClassicOperation::update_memory_buffer_partial(), blender::compositor::SunBeamsOperation::update_memory_buffer_partial(), blender::compositor::VariableSizeBokehBlurOperation::update_memory_buffer_partial(), blender::compositor::velocity_atomic_max_value(), blender::noise::voronoi_distance_to_edge(), blender::noise::voronoi_distance_to_edge(), blender::noise::voronoi_distance_to_edge(), and blender::noise::voronoi_distance_to_edge().

◆ min() [2/2]

template<typename T , int Size>
VecBase< T, Size > blender::math::min ( const VecBase< T, Size > & a,
const VecBase< T, Size > & b )
inlinenodiscard

Definition at line 58 of file BLI_math_vector.hh.

References b, BLI_UNROLL_MATH_VEC_FUNC_VEC_VEC, and min().

◆ min_inplace()

template<typename T >
void blender::math::min_inplace ( T & a,
const T & b )
inline

Definition at line 58 of file BLI_math_base.hh.

References b, and min().

Referenced by blender::io::obj::Geometry::track_vertex_index().

◆ min_max() [1/2]

◆ min_max() [2/2]

template<typename T , int Size>
void blender::math::min_max ( const VecBase< T, Size > & vector,
VecBase< T, Size > & min,
VecBase< T, Size > & max )
inline

Definition at line 224 of file BLI_math_vector.hh.

References max(), min(), and min.

◆ mod() [1/3]

◆ mod() [2/3]

template<typename T , int Size>
VecBase< T, Size > blender::math::mod ( const VecBase< T, Size > & a,
const T & b )
inlinenodiscard

Definition at line 115 of file BLI_math_vector.hh.

References b, BLI_assert, mod(), and result.

◆ mod() [3/3]

template<typename T , int Size>
VecBase< T, Size > blender::math::mod ( const VecBase< T, Size > & a,
const VecBase< T, Size > & b )
inlinenodiscard

Definition at line 109 of file BLI_math_vector.hh.

References b, BLI_UNROLL_MATH_VEC_FUNC_VEC_VEC, and mod().

◆ mod_periodic()

template<typename T >
T blender::math::mod_periodic ( const T & a,
const T & b )
inline

Repeats the saw-tooth pattern even on negative numbers. ex: mod_periodic(-3, 4) = 1, mod(-3, 4)= -3. This will cause undefined behavior for negative b.

Definition at line 109 of file BLI_math_base.hh.

References abs(), b, BLI_assert, and floor().

Referenced by blender::nodes::node_fn_integer_math_cc::get_multi_function(), blender::tests::TEST(), blender::math::AngleFraction< T >::wrapped(), and blender::math::AngleRadianBase< T >::wrapped().

◆ normal_tri()

template<typename T >
VecBase< T, 3 > blender::math::normal_tri ( const VecBase< T, 3 > & v1,
const VecBase< T, 3 > & v2,
const VecBase< T, 3 > & v3 )
inlinenodiscard

Return normal vector to a triangle. The result is normalized but can still be degenerate.

Definition at line 511 of file BLI_math_vector.hh.

References cross_tri(), normalize(), and v2.

Referenced by blender::ed::sculpt_paint::calc_area_normal_and_center_node_bmesh(), blender::io::stl::export_frame(), blender::bke::mesh::face_normal_calc(), and from_triangle().

◆ normalize() [1/5]

template<typename T >
DualQuaternionBase< T > blender::math::normalize ( const DualQuaternionBase< T > & dual_quat)
nodiscard

Apply all accumulated weights to the dual-quaternions. Also make sure the rotation quaternions is normalized.

Note
The C version of this function does not normalize the quaternion. This makes other operations like transform and matrix conversion more complex.
Returns identity DualQuaternion if degenerate.

Definition at line 445 of file BLI_math_quaternion.hh.

References blender::math::DualQuaternionBase< T >::identity(), blender::math::DualQuaternionBase< T >::quat, blender::math::DualQuaternionBase< T >::quat_weight, blender::math::DualQuaternionBase< T >::scale, blender::math::DualQuaternionBase< T >::scale_weight, sqrt(), T, and blender::math::DualQuaternionBase< T >::trans.

◆ normalize() [2/5]

template<typename T , int NumCol, int NumRow>
MatBase< T, NumCol, NumRow > blender::math::normalize ( const MatBase< T, NumCol, NumRow > & a)
nodiscard

Normalize each column of the matrix individually.

Definition at line 744 of file BLI_math_matrix.hh.

References normalize(), result, and blender::unroll().

Referenced by blender::ed::sculpt_paint::greasepencil::PaintOperationExecutor::active_jitter(), blender::ed::sculpt_paint::pose::align_pivot_local_space(), blender::nodes::node_fn_align_euler_to_vector_cc::align_rotations_auto_pivot(), blender::nodes::node_fn_align_rotation_to_vector_cc::align_rotations_auto_pivot(), blender::nodes::node_fn_align_rotation_to_vector_cc::align_rotations_fixed_pivot(), blender::draw::overlay::Meshes::begin_sync(), blender::draw::overlay::Paints::begin_sync(), blender::ed::sculpt_paint::boundary::bend_data_init_bmesh(), blender::ed::sculpt_paint::boundary::bend_data_init_grids(), blender::ed::sculpt_paint::boundary::bend_data_init_mesh(), blender::bke::build_point_matrix(), blender::ed::sculpt_paint::auto_mask::calc_blurred_cavity_bmesh(), blender::ed::sculpt_paint::auto_mask::calc_blurred_cavity_grids(), blender::ed::sculpt_paint::auto_mask::calc_blurred_cavity_mesh(), blender::ed::sculpt_paint::smooth::calc_boundary_normal_corner(), blender::ed::sculpt_paint::smooth::calc_boundary_normal_corner(), blender::ed::sculpt_paint::smooth::calc_boundary_normal_corner(), blender::ed::sculpt_paint::cloth::calc_forces_bmesh(), blender::ed::sculpt_paint::cloth::calc_forces_grids(), blender::ed::sculpt_paint::cloth::calc_forces_mesh(), blender::ed::sculpt_paint::cloth::calc_perpendicular_pinch_forces(), blender::ed::sculpt_paint::cloth::calc_pinch_forces(), blender::ed::sculpt_paint::cloth::calc_plane_pinch_forces(), blender::ed::sculpt_paint::pose::calc_pose_data(), blender::geometry::calc_position_with_interpolation(), blender::geometry::calc_position_without_interpolation(), blender::ed::sculpt_paint::pose::calc_scale_from_grab_delta(), blender::ed::sculpt_paint::filter::calc_sphere_translations(), blender::bke::curves::bezier::calculate_aligned_handle(), blender::geometry::calculate_directions(), blender::bke::curves::poly::calculate_next_normal(), blender::bke::curves::poly::calculate_normals_minimum(), blender::bke::curves::poly::calculate_normals_z_up(), blender::calculate_plane(), blender::ed::sculpt_paint::min_distance_edit::calculate_points_per_side(), blender::bke::curves::poly::calculate_tangents(), blender::ed::greasepencil::calculate_texture_space(), blender::nodes::node_fn_axes_to_rotation_cc::AxesToRotationFunction::call(), blender::nodes::node_fn_separate_transform_cc::SeparateTransformFunction::call(), blender::ed::sculpt_paint::cloth::cloth_brush_apply_brush_foces(), blender::nodes::node_geo_curve_primitive_arc_cc::colinear_f3_f3_f3(), blender::nodes::node_geo_curve_primitive_circle_cc::colinear_f3_f3_f3(), blender::ed::sculpt_paint::greasepencil::compute_auto_flip(), blender::geometry::compute_surface_point_normal(), blender::bke::mesh::corner_fan_space_define(), blender::bke::mesh::corner_space_custom_normal_to_data(), blender::nodes::node_geo_curve_primitive_arc_cc::create_arc_curve_from_points(), blender::nodes::node_geo_curve_primitive_line_cc::create_direction_line_curve(), blender::nodes::node_geo_curve_primitive_circle_cc::create_point_circle_curve(), blender::nodes::node_geo_scale_elements_cc::create_single_axis_transform(), blender::deform_drawing(), blender::bke::curves::poly::direction_bisect(), blender::ed::sculpt_paint::boundary::displacement_from_grab_delta_get(), blender::ed::sculpt_paint::do_bmesh_topology_rake_brush(), blender::ed::sculpt_paint::do_clay_strips_brush(), blender::ed::sculpt_paint::do_multiplane_scrape_brush(), blender::ed::sculpt_paint::do_pinch_brush(), blender::ed::sculpt_paint::color::do_smear_brush_task(), DRW_text_edit_mesh_measure_stats(), blender::geometry::extend_curves_curved(), blender::ed::sculpt_paint::SlideOperationExecutor::find_curves_to_slide(), blender::find_envelope(), blender::bke::float4x4_to_quaternion(), blender::noise::gabor(), blender::ed::greasepencil::generate_cap(), blender::ed::greasepencil::generate_corner(), blender::ed::greasepencil::generate_stroke_perimeter(), blender::ed::sculpt_paint::trim::gesture_to_screen_points(), blender::ed::view3d::geometry_nodes_gizmos::TransformGizmos::get_axis_gizmo_matrix_basis(), blender::ed::greasepencil::trim::get_intersections_of_curve_with_curves(), blender::nodes::node_geo_input_mesh_edge_angle_cc::SignedAngleFieldInput::get_varray_for_context(), gizmo_ruler_draw(), blender::ed::sculpt_paint::grease_pencil_fill_get_extension_data(), imapaint_pick_face(), blender::bke::mesh::lnor_space_for_single_fan(), blender::ed::view3d::geometry_nodes_gizmos::make_matrix_orthonormal_but_keep_z_axis(), blender::bke::mesh_normals_varray(), blender::ed::sculpt_paint::min_distance_edit::min_distance_edit_draw(), blender::ed::sculpt_paint::min_distance_edit::min_distance_edit_invoke(), blender::bke::attribute_math::mix3(), blender::nodes::node_fn_axis_angle_to_rotation_cc::node_build_multi_function(), blender::nodes::node_fn_quaternion_to_rotation_cc::node_build_multi_function(), blender::nodes::node_fn_rotation_to_axis_angle_cc::node_eval_inverse(), blender::nodes::node_geo_interpolate_curves_cc::node_geo_exec(), blender::nodes::node_geo_mesh_primitive_line_cc::node_geo_exec(), blender::nodes::node_geo_raycast_cc::node_geo_exec(), blender::nodes::node_geo_distribute_points_on_faces_cc::normal_to_rotation(), normalize(), normalize(), blender::bke::normalize_span(), blender::geometry::normalize_span(), blender::bke::pbvh::normals_calc_verts_simple(), blender::draw::overlay::LightProbes::object_sync(), blender::ed::sculpt_paint::greasepencil::RandomizeOperation::on_stroke_extended(), blender::ed::sculpt_paint::boundary::populate_twist_data(), blender::ed::curves::primitive_random_sphere(), blender::ed::sculpt_paint::greasepencil::PaintOperationExecutor::process_extension_sample(), blender::ed::sculpt_paint::PuffOperationExecutor::puff(), SnapData::register_result(), SnapData::register_result_raycast(), blender::ed::greasepencil::DrawingPlacement::reproject(), blender::bke::mesh_surface_sample::sample_corner_normals(), blender::ed::sculpt_paint::sample_curves_3d_brush(), blender::ed::sculpt_paint::sample_curves_surface_3d_brush(), blender::ed::sculpt_paint::AddOperationExecutor::sample_in_center(), blender::bke::mesh_surface_sample::sample_point_normals(), blender::ed::sculpt_paint::AddOperationExecutor::sample_spherical_with_symmetry(), blender::bke::mesh_surface_sample::sample_surface_points_projected(), blender::bke::mesh_surface_sample::sample_surface_points_spherical(), blender::ed::sculpt_paint::boundary::slide_data_init_bmesh(), blender::ed::sculpt_paint::boundary::slide_data_init_grids(), blender::ed::sculpt_paint::boundary::slide_data_init_mesh(), blender::ed::sculpt_paint::pose::solve_ik_chain(), blender::geometry::curve_constraints::solve_length_and_collision_constraints(), blender::geometry::curve_constraints::solve_length_constraints(), blender::ed::sculpt_paint::pose::solve_roll_chain(), blender::bke::mesh::split_corner_normal_fan_do(), blender::io::obj::OBJMesh::store_normal_coords_and_indices(), transform_mesh_edge_slide_data_create(), transform_mesh_uv_edge_slide_data_create(), blender::geometry::transform_volume(), VertSlideData::update_active_edges(), blender::bke::greasepencil::update_curve_plane_normal_cache(), blender::ed::view3d::geometry_nodes_gizmos::TransformGizmos::update_rotate_transform_and_target_property(), blender::ed::view3d::geometry_nodes_gizmos::TransformGizmos::update_scale_transform_and_target_property(), blender::ed::view3d::geometry_nodes_gizmos::DialGizmo::update_transform(), blender::ed::view3d::geometry_nodes_gizmos::LinearGizmo::update_transform(), blender::noise::voronoi_distance_to_edge(), blender::noise::voronoi_distance_to_edge(), and blender::noise::voronoi_distance_to_edge().

◆ normalize() [3/5]

template<typename T , int NumCol, int NumRow, int SrcNumCol, int SrcNumRow, int SrcStartCol, int SrcStartRow, int SrcAlignment>
MatBase< T, NumCol, NumRow > blender::math::normalize ( const MatView< T, NumCol, NumRow, SrcNumCol, SrcNumRow, SrcStartCol, SrcStartRow, SrcAlignment > & a)
nodiscard

Definition at line 713 of file BLI_math_matrix.hh.

References normalize(), result, and blender::unroll().

◆ normalize() [4/5]

template<typename T >
QuaternionBase< T > blender::math::normalize ( const QuaternionBase< T > & q)
inlinenodiscard

Return a unit quaternion representing the same rotation as q or the identity quaternion if q is ill-formed.

Definition at line 256 of file BLI_math_quaternion.hh.

References len, and normalize_and_get_length().

◆ normalize() [5/5]

template<typename T , int Size>
VecBase< T, Size > blender::math::normalize ( const VecBase< T, Size > & v)
inlinenodiscard

Definition at line 435 of file BLI_math_vector.hh.

References len, normalize_and_get_length(), and v.

◆ normalize_and_get_length() [1/2]

◆ normalize_and_get_length() [2/2]

template<typename T , int Size>
VecBase< T, Size > blender::math::normalize_and_get_length ( const VecBase< T, Size > & v,
T & out_length )
inlinenodiscard

Definition at line 419 of file BLI_math_vector.hh.

References length_squared(), sqrt(), and v.

◆ normalize_and_get_size() [1/2]

template<typename T , int NumCol, int NumRow, typename VectorT >
MatBase< T, NumCol, NumRow > blender::math::normalize_and_get_size ( const MatBase< T, NumCol, NumRow > & a,
VectorT & r_size )
nodiscard

Normalize each column of the matrix individually. Return the length of each column vector.

Definition at line 752 of file BLI_math_matrix.hh.

References BLI_STATIC_ASSERT, normalize_and_get_length(), result, and blender::unroll().

Referenced by blender::nodes::node_fn_separate_transform_cc::SeparateTransformFunction::call(), blender::eevee::Light::sync(), blender::tests::TEST(), to_rot_scale(), and to_rot_scale().

◆ normalize_and_get_size() [2/2]

template<typename T , int NumCol, int NumRow, int SrcNumCol, int SrcNumRow, int SrcStartCol, int SrcStartRow, int SrcAlignment, typename VectorT >
MatBase< T, NumCol, NumRow > blender::math::normalize_and_get_size ( const MatView< T, NumCol, NumRow, SrcNumCol, SrcNumRow, SrcStartCol, SrcStartRow, SrcAlignment > & a,
VectorT & r_size )
nodiscard

◆ normalized_to_quaternion_safe()

template<typename T >
QuaternionBase< T > blender::math::normalized_to_quaternion_safe ( const MatBase< T, 3, 3 > & mat)
inlinenodiscard

This is "safe" in the sense that the input matrix may not actually encode a rotation but can also contain shearing etc.

Definition at line 1236 of file BLI_math_matrix.hh.

References to_euler(), and to_quaternion().

Referenced by blender::nodes::node_fn_separate_transform_cc::SeparateTransformFunction::call(), blender::bke::float4x4_to_quaternion(), blender::bke::attribute_math::mix3(), and blender::tests::TEST().

◆ operator<<() [1/4]

std::ostream & blender::math::operator<< ( std::ostream & stream,
const Axis axis )

Definition at line 11 of file math_basis_types.cc.

◆ operator<<() [2/4]

std::ostream & blender::math::operator<< ( std::ostream & stream,
const AxisSigned axis )

Definition at line 25 of file math_basis_types.cc.

◆ operator<<() [3/4]

std::ostream & blender::math::operator<< ( std::ostream & stream,
const CartesianBasis & rot )

Definition at line 40 of file math_basis_types.cc.

◆ operator<<() [4/4]

std::ostream & blender::math::operator<< ( std::ostream & stream,
EulerOrder order )

Definition at line 142 of file math_rotation.cc.

References XYZ, XZY, YXZ, YZX, ZXY, and ZYX.

◆ operator<=() [1/2]

bool blender::math::operator<= ( const Axis::Value a,
const Axis::Value b )
constexpr

Definition at line 185 of file BLI_math_basis_types.hh.

References b, and int.

◆ operator<=() [2/2]

bool blender::math::operator<= ( const AxisSigned::Value a,
const AxisSigned::Value b )
constexpr

Definition at line 190 of file BLI_math_basis_types.hh.

References b, and int.

◆ orthogonal() [1/2]

template<typename T >
VecBase< T, 2 > blender::math::orthogonal ( const VecBase< T, 2 > & v)
inlinenodiscard

Calculates a perpendicular vector to v.

Note
Returned vector can be in any perpendicular direction.

Definition at line 644 of file BLI_math_vector.hh.

References v.

◆ orthogonal() [2/2]

template<typename T >
VecBase< T, 3 > blender::math::orthogonal ( const VecBase< T, 3 > & v)
inlinenodiscard

Calculates a perpendicular vector to v.

Note
Returned vector can be in any perpendicular direction.
Returned vector might not the same length as v.

Definition at line 626 of file BLI_math_vector.hh.

References dominant_axis(), and v.

Referenced by blender::math::AxisAngleBase< T, AngleT >::AxisAngleBase(), and isect_face_dst().

◆ orthogonalize()

template<typename MatT >
MatT blender::math::orthogonalize ( const MatT & mat,
const Axis axis )
nodiscard

This returns a version of mat with orthonormal basis axes. This leaves the given axis untouched.

In other words this removes the shear of the matrix. However this doesn't properly account for volume preservation, and so, the axes keep their respective length.

Note
Prefer using from_up_axis to create a orthogonal basis around a vector.

The secondary axis is chosen as follow (X->Y, Y->X, Z->X). If this axis is co-planar try the third axis. If also co-planar, make up an axis by shuffling the primary axis coordinates (XYZ > YZX).

The secondary axis is chosen as follow (X->Y, Y->X, Z->X). If this axis is co-planar try the third axis. If also co-planar, make up an axis by shuffling the primary axis coordinates (XYZ > YZX).

Definition at line 1472 of file BLI_math_matrix.hh.

References BLI_assert_unreachable, cross(), normalize(), normalize_and_get_length(), R, result, scale(), blender::math::Axis::X, blender::math::Axis::Y, and blender::math::Axis::Z.

Referenced by to_dual_quaternion().

◆ polar_decompose()

template<typename T >
static void blender::math::polar_decompose ( const MatBase< T, 3, 3 > & mat3,
MatBase< T, 3, 3 > & r_U,
MatBase< T, 3, 3 > & r_P )
static

Right polar decomposition: M = UP

U is the 'rotation'-like component, the closest orthogonal matrix to M. P is the 'scaling'-like component, defined in U space.

See https://en.wikipedia.org/wiki/Polar_decomposition for more.

WORKAROUND: (ComputeThinU | ComputeThinV) must be set as runtime parameters in Eigen < 3.4.0. But this requires the matrix type to be dynamic to avoid an assert.

Definition at line 284 of file math_matrix.cc.

References blender::MatBase< T, NumCol, NumRow, Alignment >::base_ptr(), Map, polar_decompose(), transpose(), V, and W.

Referenced by interpolate(), and polar_decompose().

◆ pow() [1/4]

template<typename T >
QuaternionBase< T > blender::math::pow ( const QuaternionBase< T > & q,
const T & y )
nodiscard

Raise a unit Quaternion q to the real y exponent.

Note
This only works on unit quaternions and y != 0.
This is not a per component power.

Definition at line 202 of file BLI_math_quaternion.hh.

References BLI_assert, cos(), blender::math::QuaternionBase< T >::imaginary_part(), is_unit_scale(), normalize(), safe_acos(), sin(), and blender::math::QuaternionBase< T >::w.

◆ pow() [2/4]

◆ pow() [3/4]

template<typename T , int Size>
VecBase< T, Size > blender::math::pow ( const VecBase< T, Size > & x,
const T & y )
inlinenodiscard

Return the value of x raised to the y power. The result is undefined if x < 0 or if x = 0 and y <= 0.

Definition at line 156 of file BLI_math_vector.hh.

References pow(), and result.

◆ pow() [4/4]

template<typename T , int Size>
VecBase< T, Size > blender::math::pow ( const VecBase< T, Size > & x,
const VecBase< T, Size > & y )
inlinenodiscard

Return the value of x raised to the y power. The result is undefined if x < 0 or if x = 0 and y <= 0.

Definition at line 170 of file BLI_math_vector.hh.

References BLI_UNROLL_MATH_VEC_FUNC_VEC_VEC, and pow().

◆ project()

template<typename T , int Size>
VecBase< T, Size > blender::math::project ( const VecBase< T, Size > & p,
const VecBase< T, Size > & v_proj )
inlinenodiscard

Project p onto v_proj . Returns zero vector if v_proj is degenerate (zero length).

Definition at line 409 of file BLI_math_vector.hh.

References is_zero(), and UNLIKELY.

◆ project_point() [1/4]

template float2 blender::math::project_point ( const float3x3 & mat,
const float2 & point )
extern

◆ project_point() [2/4]

template float3 blender::math::project_point ( const float4x4 & mat,
const float3 & point )
extern

◆ project_point() [3/4]

template<typename T , int N, int NumRow>
VecBase< T, N > blender::math::project_point ( const MatBase< T, N+1, NumRow > & mat,
const VecBase< T, N > & point )

Definition at line 1597 of file BLI_math_matrix.hh.

References abs(), N, and T.

◆ project_point() [4/4]

template<typename MatT , typename VectorT >
VectorT blender::math::project_point ( const MatT & mat,
const VectorT & point )
nodiscard

◆ pseudo_invert() [1/7]

template double2x2 blender::math::pseudo_invert ( const double2x2 & mat,
double epsilon )

References pseudo_invert().

◆ pseudo_invert() [2/7]

template double3x3 blender::math::pseudo_invert ( const double3x3 & mat,
double epsilon )

References pseudo_invert().

◆ pseudo_invert() [3/7]

template double4x4 blender::math::pseudo_invert ( const double4x4 & mat,
double epsilon )

References pseudo_invert().

◆ pseudo_invert() [4/7]

template float2x2 blender::math::pseudo_invert ( const float2x2 & mat,
float epsilon )

References pseudo_invert().

◆ pseudo_invert() [5/7]

template float3x3 blender::math::pseudo_invert ( const float3x3 & mat,
float epsilon )

References pseudo_invert().

◆ pseudo_invert() [6/7]

template float4x4 blender::math::pseudo_invert ( const float4x4 & mat,
float epsilon )

References pseudo_invert().

◆ pseudo_invert() [7/7]

template<typename T , int Size>
MatBase< T, Size, Size > blender::math::pseudo_invert ( const MatBase< T, Size, Size > & mat,
T epsilon = 1e-8 )
nodiscard

Compute Moore-Penrose pseudo inverse of matrix. Singular values below epsilon are ignored for stability (truncated SVD). Gives a good enough approximation of the regular inverse matrix if the given matrix is non-invertible (ex: degenerate transform). The returned pseudo inverse matrix A+ of input matrix A will not satisfy A+ * A = Identity but will satisfy A * A+ * A = A. For more detail, see https://en.wikipedia.org/wiki/Moore%E2%80%93Penrose_inverse.

Compute the Single Value Decomposition of an arbitrary matrix A That is compute the 3 matrices U,W,V with U column orthogonal (m,n) ,W a diagonal matrix and V an orthogonal square matrix s.t.A = U.W.Vt. From this decomposition it is trivial to compute the (pseudo-inverse) of A as Ainv = V.Winv.transpose(U).

WORKAROUND: (ComputeThinU | ComputeThinV) must be set as runtime parameters in Eigen < 3.4.0. But this requires the matrix type to be dynamic to avoid an assert.

Compute the Single Value Decomposition of an arbitrary matrix A That is compute the 3 matrices U,W,V with U column orthogonal (m,n) ,W a diagonal matrix and V an orthogonal square matrix s.t.A = U.W.Vt. From this decomposition it is trivial to compute the (pseudo-inverse) of A as Ainv = V.Winv.transpose(U).

WORKAROUND: (ComputeThinU | ComputeThinV) must be set as runtime parameters in Eigen < 3.4.0. But this requires the matrix type to be dynamic to avoid an assert.

Definition at line 215 of file math_matrix.cc.

References blender::MatBase< T, NumCol, NumRow, Alignment >::base_ptr(), invert(), pseudo_invert(), T, transpose(), U, V, and W.

Referenced by pseudo_invert(), pseudo_invert(), pseudo_invert(), pseudo_invert(), pseudo_invert(), pseudo_invert(), pseudo_invert(), and blender::tests::TEST().

◆ rcp() [1/2]

◆ rcp() [2/2]

template<typename T , int Size>
VecBase< T, Size > blender::math::rcp ( const VecBase< T, Size > & a)
inlinenodiscard

Per-element inverse. Zero elements are evaluated to NaN.

Definition at line 295 of file BLI_math_vector.hh.

References BLI_UNROLL_MATH_VEC_OP_VEC, and rcp().

◆ reduce_add()

◆ reduce_max()

◆ reduce_min()

template<typename T , int Size>
T blender::math::reduce_min ( const VecBase< T, Size > & a)
inlinenodiscard
Returns
the minimum component of a vector.

Definition at line 578 of file BLI_math_vector.hh.

References result.

Referenced by evaluate_film_like(), and blender::eevee::IrradianceBake::surfels_create().

◆ reduce_mul()

template<typename T , int Size>
T blender::math::reduce_mul ( const VecBase< T, Size > & a)
inlinenodiscard
Returns
the product of the components of a vector.

Definition at line 604 of file BLI_math_vector.hh.

References result.

Referenced by blender::eevee::VolumeProbeModule::init(), and blender::draw::overlay::Fluids::object_sync().

◆ reflect()

template<typename T , int Size>
VecBase< T, Size > blender::math::reflect ( const VecBase< T, Size > & incident,
const VecBase< T, Size > & normal )
inlinenodiscard

Definition at line 384 of file BLI_math_vector.hh.

References BLI_assert, and is_unit_scale().

◆ refract()

template<typename T , int Size>
VecBase< T, Size > blender::math::refract ( const VecBase< T, Size > & incident,
const VecBase< T, Size > & normal,
const T & eta )
inlinenodiscard

Definition at line 392 of file BLI_math_vector.hh.

References sqrt().

◆ rotate() [1/6]

template<typename T , typename RotT , typename AngleT >
AxisAngleBase< T, AngleT > blender::math::rotate ( const AxisAngleBase< T, AngleT > & a,
const RotT & b )
nodiscard

Rotate a by b. In other word, insert the b rotation before a.

Note
Since a is an AxisAngle it will cast both a and b to Quaternion. This might introduce some precision loss and have performance implication.

Definition at line 199 of file BLI_math_rotation.hh.

References b.

◆ rotate() [2/6]

template<typename T , typename RotT >
Euler3Base< T > blender::math::rotate ( const Euler3Base< T > & a,
const RotT & b )
nodiscard

Rotate a by b. In other word, insert the b rotation before a.

Note
Since a is an Euler3 it will cast both a and b to #MatBase<T, 3, 3>. This might introduce some precision loss and have performance implication.

Definition at line 212 of file BLI_math_rotation.hh.

References b, from_rotation(), and to_euler().

◆ rotate() [3/6]

template<typename T , typename RotT >
EulerXYZBase< T > blender::math::rotate ( const EulerXYZBase< T > & a,
const RotT & b )
nodiscard

Rotate a by b. In other word, insert the b rotation before a.

Note
Since a is an EulerXYZ it will cast both a and b to #MatBase<T, 3, 3>. This might introduce some precision loss and have performance implication.

Definition at line 205 of file BLI_math_rotation.hh.

References b, from_rotation(), and to_euler().

◆ rotate() [4/6]

template<typename T , int NumCol, int NumRow, typename AngleT >
MatBase< T, NumCol, NumRow > blender::math::rotate ( const MatBase< T, NumCol, NumRow > & mat,
const AxisAngleBase< T, AngleT > & rotation )
nodiscard

Definition at line 648 of file BLI_math_matrix.hh.

References cos(), from_rotation(), result, sin(), and blender::unroll().

◆ rotate() [5/6]

template<typename T , int NumCol, int NumRow, typename RotationT >
MatBase< T, NumCol, NumRow > blender::math::rotate ( const MatBase< T, NumCol, NumRow > & mat,
const RotationT & rotation )
nodiscard

Equivalent to mat * from_rotation(rotation) but with fewer operation. Optimized for AxisAngle rotation on basis vector (i.e: AxisAngle({1, 0, 0}, 0.2)).

Referenced by blender::tests::TEST().

◆ rotate() [6/6]

template<typename T , typename RotT >
QuaternionBase< T > blender::math::rotate ( const QuaternionBase< T > & a,
const RotT & b )
nodiscard

Rotate a by b. In other word, insert the b rotation before a.

Note
Since a is a Quaternion it will cast b to a Quaternion. This might introduce some precision loss and have performance implication.

Definition at line 193 of file BLI_math_rotation.hh.

References b.

◆ rotate_around_axis()

float3 blender::math::rotate_around_axis ( const float3 & vector,
const float3 & center,
const float3 & axis,
float angle )

Rotate any arbitrary vector around the center position, with a unit-length axis and the specified angle.

Definition at line 129 of file math_rotation.cc.

References axis_angle_normalized_to_mat3(), and mul_m3_v3().

Referenced by blender::ed::sculpt_paint::boundary::calc_twist_position().

◆ rotate_direction_around_axis()

float3 blender::math::rotate_direction_around_axis ( const float3 & direction,
const float3 & axis,
float angle )

◆ rotation_between() [1/3]

CartesianBasis blender::math::rotation_between ( const AxisSigned a_forward,
const AxisSigned b_forward )
inlinenodiscard

Create an CartesianBasis for converting from an a orientation defined only by its forward vector to a b orientation defined only by its forward vector. Rotation is given to be non flipped and deterministic.

Definition at line 430 of file BLI_math_basis_types.hh.

References abs(), from_orthonormal_axes(), blender::math::AxisSigned::next_after(), rotation_between(), and sign().

◆ rotation_between() [2/3]

CartesianBasis blender::math::rotation_between ( const CartesianBasis & a,
const CartesianBasis & b )
inlinenodiscard

◆ rotation_between() [3/3]

template<typename T >
QuaternionBase< T > blender::math::rotation_between ( const QuaternionBase< T > & a,
const QuaternionBase< T > & b )
nodiscard

Return rotation from orientation a to orientation b into another quaternion.

Definition at line 220 of file BLI_math_rotation.hh.

References b, and invert().

◆ round() [1/2]

◆ round() [2/2]

template<typename T , int Size>
VecBase< T, Size > blender::math::round ( const VecBase< T, Size > & a)
inlinenodiscard

Definition at line 256 of file BLI_math_vector.hh.

References BLI_UNROLL_MATH_VEC_OP_VEC, and round().

◆ safe_acos()

template<typename T >
T blender::math::safe_acos ( const T & a)
inline

◆ safe_acos_approx()

◆ safe_divide() [1/3]

template<typename T >
T blender::math::safe_divide ( const T & a,
const T & b )
inline

Definition at line 89 of file BLI_math_base.hh.

References b, and T.

Referenced by blender::apply_gradient_tint(), blender::ed::sculpt_paint::average_mask_border_position(), blender::ed::sculpt_paint::average_unmasked_position(), blender::nodes::node_shader_map_range_cc::build_vector_linear(), blender::nodes::node_shader_map_range_cc::build_vector_stepped(), blender::ed::space_node::calculate_inner_link_bezier_points(), blender::draw::curves_sub_pass_setup_implementation(), blender::deform_drawing(), blender::draw::DRW_shgroup_curves_create_sub(), blender::ed::sculpt_paint::ScaleCurvesEffect::execute(), blender::ed::greasepencil::fill_strokes(), blender::ed::greasepencil::fit_strokes_to_view(), blender::nodes::node_fn_integer_math_cc::get_multi_function(), blender::compositor::karis_brightness_weighted_sum(), blender::geometry::limit_radius(), blender::ed::sculpt_paint::move_last_point_and_resample(), blender::nodes::node_fn_integer_math_cc::node_eval_inverse(), blender::nodes::node_shader_math_cc::node_eval_inverse(), blender::nodes::node_shader_vector_math_cc::node_eval_inverse(), blender::ed::sculpt_paint::PinchOperationExecutor::pinch_projected(), blender::ed::sculpt_paint::PinchOperationExecutor::pinch_spherical(), blender::ed::greasepencil::pixel_radius_to_world_space_radius(), safe_divide(), blender::nodes::node_fn_integer_math_cc::safe_divide_round_i(), blender::length_parameterize::sample_at_length(), SCULPT_calc_vertex_displacement(), blender::nodes::node_shader_map_range_cc::sh_node_map_range_build_multi_function(), blender::realtime_compositor::SymmetricBlurWeights::SymmetricBlurWeights(), blender::compositor::BokehBlurOperation::update_memory_buffer_partial(), blender::compositor::GaussianBlurReferenceOperation::update_memory_buffer_partial(), and blender::compositor::VariableSizeBokehBlurOperation::update_memory_buffer_partial().

◆ safe_divide() [2/3]

template<typename T , int Size>
VecBase< T, Size > blender::math::safe_divide ( const VecBase< T, Size > & a,
const T & b )
inlinenodiscard

Returns 0 if denominator is exactly equal to 0.

Definition at line 244 of file BLI_math_vector.hh.

References b.

◆ safe_divide() [3/3]

template<typename T , int Size>
VecBase< T, Size > blender::math::safe_divide ( const VecBase< T, Size > & a,
const VecBase< T, Size > & b )
inlinenodiscard

Returns 0 if denominator is exactly equal to 0.

Definition at line 234 of file BLI_math_vector.hh.

References b, BLI_UNROLL_MATH_VEC_FUNC_VEC_VEC, and safe_divide().

◆ safe_mod() [1/3]

template<typename T >
T blender::math::safe_mod ( const T & a,
const T & b )
inline

Definition at line 78 of file BLI_math_base.hh.

References b.

Referenced by safe_mod().

◆ safe_mod() [2/3]

template<typename T , int Size>
VecBase< T, Size > blender::math::safe_mod ( const VecBase< T, Size > & a,
const T & b )
inlinenodiscard

Safe version of mod(a, b) that returns 0 if b is equal to 0.

Definition at line 139 of file BLI_math_vector.hh.

References b, mod(), and result.

◆ safe_mod() [3/3]

template<typename T , int Size>
VecBase< T, Size > blender::math::safe_mod ( const VecBase< T, Size > & a,
const VecBase< T, Size > & b )
inlinenodiscard

Safe version of mod(a, b) that returns 0 if b is equal to 0.

Definition at line 129 of file BLI_math_vector.hh.

References b, BLI_UNROLL_MATH_VEC_FUNC_VEC_VEC, and safe_mod().

◆ safe_rcp() [1/2]

◆ safe_rcp() [2/2]

template<typename T , int Size>
VecBase< T, Size > blender::math::safe_rcp ( const VecBase< T, Size > & a)
inlinenodiscard

Per-element inverse. Zero elements are evaluated to zero.

Definition at line 305 of file BLI_math_vector.hh.

References BLI_UNROLL_MATH_VEC_OP_VEC, and safe_rcp().

◆ safe_sqrt()

template<typename T , int Size>
VecBase< T, Size > blender::math::safe_sqrt ( const VecBase< T, Size > & a)
inlinenodiscard

Per-element square root. Negative elements are evaluated to zero.

Definition at line 282 of file BLI_math_vector.hh.

References result, and T.

Referenced by blender::tests::TEST().

◆ scale()

template<typename T , int NumCol, int NumRow, typename VectorT >
MatBase< T, NumCol, NumRow > blender::math::scale ( const MatBase< T, NumCol, NumRow > & mat,
const VectorT & scale )
nodiscard

◆ sign() [1/3]

int blender::math::sign ( const AxisSigned & axis)
inlinenodiscard

Definition at line 206 of file BLI_math_basis_types.hh.

◆ sign() [2/3]

◆ sign() [3/3]

template<typename T , int Size>
VecBase< T, Size > blender::math::sign ( const VecBase< T, Size > & a)
inlinenodiscard

Returns -1 if a is less than 0, 0 if a is equal to 0, and +1 if a is greater than 0.

Definition at line 52 of file BLI_math_vector.hh.

References BLI_UNROLL_MATH_VEC_OP_VEC, and sign().

◆ sin() [1/4]

template<typename T >
T blender::math::sin ( const AngleCartesianBase< T > & a)

Definition at line 701 of file BLI_math_angle_types.hh.

◆ sin() [2/4]

template<typename T >
T blender::math::sin ( const AngleFraction< T > & a)

Definition at line 714 of file BLI_math_angle_types.hh.

References sin().

◆ sin() [3/4]

template<typename T >
T blender::math::sin ( const AngleRadianBase< T > & a)

Definition at line 688 of file BLI_math_angle_types.hh.

References sin().

Referenced by blender::math::AxisAngleBase< T, AngleT >::AxisAngleBase(), blender::noise::compute_2d_gabor_kernel(), blender::noise::compute_3d_gabor_kernel(), blender::noise::compute_3d_orientation(), blender::realtime_compositor::compute_numerator_1(), blender::realtime_compositor::compute_numerator_2(), blender::realtime_compositor::compute_numerator_3(), blender::realtime_compositor::compute_realized_transformation_domain(), blender::nodes::node_composite_glare_cc::GlareOperation::compute_streak_direction(), blender::nodes::node_composite_directionalblur_cc::DirectionalBlurOperation::execute(), blender::math::detail::from_rotation(), blender::math::detail::from_rotation(), blender::math::detail::from_rotation(), from_triangle(), blender::ed::greasepencil::generate_arc_from_point_to_point(), blender::get_rand_matrix(), blender::ed::greasepencil::grease_pencil_primitive_rotate_all_update(), interpolate_dot_slerp(), blender::workbench::SceneResources::load_jitter_tx(), blender::math::AngleFraction< T >::operator AngleCartesianBase< T >(), pow(), blender::ed::sculpt_paint::greasepencil::PaintOperationExecutor::process_extension_sample(), blender::draw::overlay::ring_vertices(), rotate(), blender::ed::sculpt_paint::greasepencil::rotate_by_angle(), blender::rotate_by_angle(), sin(), sin(), blender::math::tests::TEST(), blender::tests::TEST(), to_quaternion(), to_quaternion(), to_quaternion_legacy(), blender::write_fill_transforms(), and blender::write_weights_for_drawing().

◆ sin() [4/4]

template<typename T >
T blender::math::sin ( const T & a)
inline

Definition at line 159 of file BLI_math_base.hh.

◆ sqrt() [1/2]

◆ sqrt() [2/2]

template<typename T , int Size>
VecBase< T, Size > blender::math::sqrt ( const VecBase< T, Size > & a)
inlinenodiscard

Per-element square root. Negative elements are evaluated to NaN.

Definition at line 272 of file BLI_math_vector.hh.

References BLI_UNROLL_MATH_VEC_OP_VEC, and sqrt().

◆ square() [1/2]

◆ square() [2/2]

template<typename T , int Size>
VecBase< T, Size > blender::math::square ( const VecBase< T, Size > & a)
inlinenodiscard

Per-element square.

Definition at line 177 of file BLI_math_vector.hh.

References BLI_UNROLL_MATH_VEC_OP_VEC, and square().

◆ step() [1/3]

◆ step() [2/3]

template<typename T , int Size>
VecBase< T, Size > blender::math::step ( const T & edge,
const VecBase< T, Size > & value )
inlinenodiscard

Definition at line 99 of file BLI_math_vector.hh.

References result, and step().

◆ step() [3/3]

template<typename T , int Size>
VecBase< T, Size > blender::math::step ( const VecBase< T, Size > & edge,
const VecBase< T, Size > & value )
inlinenodiscard

Definition at line 92 of file BLI_math_vector.hh.

References BLI_UNROLL_MATH_VEC_FUNC_VEC_VEC, and step().

◆ tan() [1/4]

template<typename T >
T blender::math::tan ( const AngleCartesianBase< T > & a)

Definition at line 705 of file BLI_math_angle_types.hh.

◆ tan() [2/4]

template<typename T >
T blender::math::tan ( const AngleFraction< T > & a)

Definition at line 718 of file BLI_math_angle_types.hh.

References tan().

◆ tan() [3/4]

template<typename T >
T blender::math::tan ( const AngleRadianBase< T > & a)

◆ tan() [4/4]

template<typename T >
T blender::math::tan ( const T & a)
inline

Definition at line 164 of file BLI_math_base.hh.

◆ to_angle()

template<typename T >
AngleRadianBase< T > blender::math::to_angle ( const MatBase< T, 2, 2 > & mat)
inlinenodiscard

Extract euler rotation from transform matrix.

Returns
the rotation with the smallest values from the potential candidates.

Definition at line 1135 of file BLI_math_matrix.hh.

References blender::math::detail::normalized_to_angle().

Referenced by blender::math::detail::to_rotation().

◆ to_axis_angle() [1/6]

template AxisAngle blender::math::to_axis_angle ( const Euler3 & )
extern

◆ to_axis_angle() [2/6]

template<typename T , typename AngleT = AngleRadian>
AxisAngleBase< T, AngleT > blender::math::to_axis_angle ( const Euler3Base< T > & euler)

Definition at line 106 of file BLI_math_euler.hh.

References to_axis_angle(), and to_quaternion().

◆ to_axis_angle() [3/6]

template AxisAngle blender::math::to_axis_angle ( const EulerXYZ & )
extern

◆ to_axis_angle() [4/6]

◆ to_axis_angle() [5/6]

template AxisAngle blender::math::to_axis_angle ( const Quaternion & )
extern

◆ to_axis_angle() [6/6]

◆ to_dual_quaternion()

template<typename T >
DualQuaternionBase< T > blender::math::to_dual_quaternion ( const MatBase< T, 4, 4 > & mat,
const MatBase< T, 4, 4 > & basemat )
nodiscard

Convert transformation mat with parent transform basemat into a dual-quaternion representation.

This allows volume preserving deformation for skinning.

Conversion routines between (regular quaternion, translation) and dual quaternion.

Version 1.0.0, February 7th, 2007

SPDX-License-Identifier: Zlib Copyright 2006-2007 University of Dublin, Trinity College, All Rights Reserved.

Changes for Blender:

  • renaming, style changes and optimizations
  • added support for scaling

Definition at line 548 of file BLI_math_quaternion.hh.

References from_rotation(), invert(), is_negative(), is_orthonormal(), length_squared(), normalize(), orthogonalize(), R, scale(), square(), T, to_quaternion(), to_scale(), blender::math::QuaternionBase< T >::w, blender::math::QuaternionBase< T >::x, blender::math::Axis::Y, blender::math::QuaternionBase< T >::y, and blender::math::QuaternionBase< T >::z.

Referenced by blender::math::tests::TEST().

◆ to_euler() [1/14]

template EulerXYZ blender::math::to_euler ( const AxisAngle & )
extern

◆ to_euler() [2/14]

template Euler3 blender::math::to_euler ( const AxisAngle & ,
EulerOrder  )
extern

◆ to_euler() [3/14]

template<typename T , typename AngleT >
EulerXYZBase< T > blender::math::to_euler ( const AxisAngleBase< T, AngleT > & axis_angle)

◆ to_euler() [4/14]

◆ to_euler() [5/14]

template EulerXYZ blender::math::to_euler ( const AxisAngleCartesian & )
extern

◆ to_euler() [6/14]

template Euler3 blender::math::to_euler ( const AxisAngleCartesian & ,
EulerOrder  )
extern

◆ to_euler() [7/14]

template<typename T >
EulerXYZBase< T > blender::math::to_euler ( const MatBase< T, 3, 3 > & mat)
inlinenodiscard

◆ to_euler() [8/14]

template<typename T >
Euler3Base< T > blender::math::to_euler ( const MatBase< T, 3, 3 > & mat,
EulerOrder order )
inlinenodiscard

◆ to_euler() [9/14]

template<typename T >
EulerXYZBase< T > blender::math::to_euler ( const MatBase< T, 4, 4 > & mat)
inlinenodiscard

Definition at line 1166 of file BLI_math_matrix.hh.

References to_euler().

◆ to_euler() [10/14]

template<typename T >
Euler3Base< T > blender::math::to_euler ( const MatBase< T, 4, 4 > & mat,
EulerOrder order )
inlinenodiscard

Definition at line 1160 of file BLI_math_matrix.hh.

References to_euler().

◆ to_euler() [11/14]

template EulerXYZ blender::math::to_euler ( const Quaternion & )
extern

◆ to_euler() [12/14]

template Euler3 blender::math::to_euler ( const Quaternion & ,
EulerOrder  )
extern

◆ to_euler() [13/14]

template<typename T >
EulerXYZBase< T > blender::math::to_euler ( const QuaternionBase< T > & quat)

Definition at line 654 of file BLI_math_quaternion.hh.

References BLI_assert, is_unit_scale(), and to_euler().

◆ to_euler() [14/14]

template<typename T >
Euler3Base< T > blender::math::to_euler ( const QuaternionBase< T > & quat,
EulerOrder order )

Definition at line 662 of file BLI_math_quaternion.hh.

References BLI_assert, is_unit_scale(), and to_euler().

◆ to_gimbal_axis()

template<typename T >
MatBase< T, 3, 3 > blender::math::to_gimbal_axis ( const Euler3Base< T > & rotation)
nodiscard

Convert euler rotation to gimbal rotation matrix.

Definition at line 361 of file BLI_math_rotation.hh.

References from_rotation(), blender::math::Euler3Base< T >::i(), result, and T.

Referenced by blender::math::tests::TEST().

◆ to_loc_rot_scale() [1/2]

template<bool AllowNegativeScale = false, typename T >
void blender::math::to_loc_rot_scale ( const MatBase< T, 3, 3 > & mat,
VecBase< T, 2 > & r_location,
AngleRadianBase< T > & r_rotation,
VecBase< T, 2 > & r_scale )
inline

◆ to_loc_rot_scale() [2/2]

template<bool AllowNegativeScale = false, typename T , typename RotationT >
void blender::math::to_loc_rot_scale ( const MatBase< T, 4, 4 > & mat,
VecBase< T, 3 > & r_location,
RotationT & r_rotation,
VecBase< T, 3 > & r_scale )
inline

◆ to_loc_rot_scale_safe()

template<bool AllowNegativeScale, typename T , typename RotationT >
void blender::math::to_loc_rot_scale_safe ( const MatBase< T, 4, 4 > & mat,
VecBase< T, 3 > & r_location,
RotationT & r_rotation,
VecBase< T, 3 > & r_scale )
inline

Same as to_loc_rot_scale but is handles matrices that are not only location, rotation and scale more gracefully, e.g. when the matrix has skew.

Definition at line 1352 of file BLI_math_matrix.hh.

References to_loc_rot_scale(), and to_quaternion().

Referenced by blender::nodes::node_fn_combine_transform_cc::node_eval_inverse(), blender::nodes::node_geo_object_info_cc::node_geo_exec(), and blender::bke::greasepencil::Layer::set_local_transform().

◆ to_nearest_euler() [1/4]

template<typename T >
Euler3Base< T > blender::math::to_nearest_euler ( const MatBase< T, 3, 3 > & mat,
const Euler3Base< T > & reference )
inlinenodiscard

◆ to_nearest_euler() [2/4]

template<typename T >
EulerXYZBase< T > blender::math::to_nearest_euler ( const MatBase< T, 3, 3 > & mat,
const EulerXYZBase< T > & reference )
inlinenodiscard

Extract euler rotation from transform matrix. The returned euler triple is given to be the closest from the reference. It avoids axis flipping for animated f-curves for eg.

Returns
the rotation with the smallest values from the potential candidates.
Note
this correspond to the C API "to_compatible" functions.

Definition at line 1188 of file BLI_math_matrix.hh.

References length_manhattan(), blender::math::detail::normalized_to_eul2(), and blender::math::EulerXYZBase< T >::wrapped_around().

Referenced by blender::tests::TEST().

◆ to_nearest_euler() [3/4]

template<typename T >
Euler3Base< T > blender::math::to_nearest_euler ( const MatBase< T, 4, 4 > & mat,
const Euler3Base< T > & reference )
inlinenodiscard

Definition at line 1203 of file BLI_math_matrix.hh.

References to_euler().

◆ to_nearest_euler() [4/4]

template<typename T >
EulerXYZBase< T > blender::math::to_nearest_euler ( const MatBase< T, 4, 4 > & mat,
const EulerXYZBase< T > & reference )
inlinenodiscard

Definition at line 1211 of file BLI_math_matrix.hh.

References to_euler().

◆ to_quaternion() [1/10]

template Quaternion blender::math::to_quaternion ( const AxisAngle & )
extern

◆ to_quaternion() [2/10]

template<typename T , typename AngleT >
QuaternionBase< T > blender::math::to_quaternion ( const AxisAngleBase< T, AngleT > & axis_angle)

Definition at line 71 of file BLI_math_axis_angle.hh.

References blender::math::AxisAngleBase< T, AngleT >::angle(), blender::math::AxisAngleBase< T, AngleT >::axis(), BLI_assert, cos(), is_unit_scale(), and sin().

Referenced by blender::nodes::node_fn_align_rotation_to_vector_cc::align_rotations_auto_pivot(), blender::nodes::node_fn_align_rotation_to_vector_cc::align_rotations_fixed_pivot(), blender::ed::sculpt_paint::brush_delta_update(), blender::nodes::node_fn_axes_to_rotation_cc::AxesToRotationFunction::call(), blender::nodes::node_geo_mesh_primitive_cube_cc::create_cube_mesh(), blender::math::QuaternionBase< T >::expmap(), blender::geometry::extend_curves_curved(), blender::bke::float3_to_quaternion(), blender::bke::float_to_quaternion(), from_vector(), blender::nodes::init_socket_cpp_value_from_property(), interpolate(), make_socket_type_rotation(), blender::bke::attribute_math::mix4(), blender::bke::attribute_math::float4x4Mixer::mix_in(), blender::nodes::node_fn_axis_angle_to_rotation_cc::node_build_multi_function(), blender::nodes::node_fn_euler_to_rotation_cc::node_build_multi_function(), blender::nodes::node_fn_input_rotation_cc::node_build_multi_function(), blender::nodes::node_fn_rotation_to_axis_angle_cc::node_eval_inverse(), blender::nodes::node_fn_rotation_to_euler_cc::node_eval_inverse(), blender::nodes::node_geo_tool_3d_cursor_cc::node_geo_exec(), normalized_to_quaternion_safe(), blender::math::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), to_axis_angle(), to_axis_angle(), to_dual_quaternion(), to_euler(), to_euler(), to_loc_rot_scale_safe(), to_quaternion(), to_quaternion(), and blender::math::detail::to_rotation().

◆ to_quaternion() [3/10]

template Quaternion blender::math::to_quaternion ( const AxisAngleCartesian & )
extern

◆ to_quaternion() [4/10]

template<typename T >
QuaternionBase< T > blender::math::to_quaternion ( const CartesianBasis & rotation)

Creates a quaternion from an axis triple. This is faster and more precise than converting from another representation.

There are only 6 * 4 = 24 possible valid orthonormal orientations. We precompute them and store them inside this switch using a key. Generated using generate_axes_to_quaternion_switch_cases().

Definition at line 393 of file BLI_math_rotation.hh.

References blender::math::QuaternionBase< T >::identity(), rcp(), blender::math::numbers::sqrt2, T, x, blender::math::AxisSigned::X_NEG, blender::math::AxisSigned::X_POS, y, blender::math::AxisSigned::Y_NEG, blender::math::AxisSigned::Y_POS, z(), blender::math::AxisSigned::Z_NEG, and blender::math::AxisSigned::Z_POS.

◆ to_quaternion() [5/10]

template Quaternion blender::math::to_quaternion ( const Euler3 & )
extern

◆ to_quaternion() [6/10]

◆ to_quaternion() [7/10]

template Quaternion blender::math::to_quaternion ( const EulerXYZ & )
extern

◆ to_quaternion() [8/10]

◆ to_quaternion() [9/10]

template<typename T >
QuaternionBase< T > blender::math::to_quaternion ( const MatBase< T, 3, 3 > & mat)
inlinenodiscard

Extract quaternion rotation from transform matrix.

Definition at line 1219 of file BLI_math_matrix.hh.

References blender::math::detail::normalized_to_quat_with_checks().

◆ to_quaternion() [10/10]

template<typename T >
QuaternionBase< T > blender::math::to_quaternion ( const MatBase< T, 4, 4 > & mat)
inlinenodiscard

Definition at line 1225 of file BLI_math_matrix.hh.

References to_quaternion().

◆ to_quaternion_legacy()

Quaternion blender::math::to_quaternion_legacy ( const float3x3 & mat)
nodiscard

Extract quaternion rotation from transform matrix. Legacy version of to_quaternion which has slightly different behavior. Keep for particle-system & boids since replacing this will make subtle changes that impact hair in existing files. See: D15772.

Definition at line 434 of file math_matrix.cc.

References atan2(), conjugate(), cos(), nor, normalize(), q1, safe_acos(), sin(), to_quaternion_legacy(), transform_point(), blender::MatBase< T, NumCol, NumRow, Alignment >::x_axis(), and blender::MatBase< T, NumCol, NumRow, Alignment >::z_axis().

Referenced by blender::tests::TEST(), and to_quaternion_legacy().

◆ to_rot_scale() [1/2]

template<bool AllowNegativeScale = false, typename T >
void blender::math::to_rot_scale ( const MatBase< T, 2, 2 > & mat,
AngleRadianBase< T > & r_rotation,
VecBase< T, 2 > & r_scale )
inline

Decompose a matrix into location, rotation, and scale components.

Template Parameters
AllowNegativeScaleif true, will compute determinant to know if matrix is negative. Rotation and scale values will be flipped if it is negative. This is a costly operation so it is disabled by default.

Definition at line 1298 of file BLI_math_matrix.hh.

References is_negative(), normalize_and_get_size(), blender::math::detail::to_rotation(), and UNLIKELY.

Referenced by blender::tests::TEST(), to_loc_rot_scale(), and to_loc_rot_scale().

◆ to_rot_scale() [2/2]

template<bool AllowNegativeScale = false, typename T , typename RotationT >
void blender::math::to_rot_scale ( const MatBase< T, 3, 3 > & mat,
RotationT & r_rotation,
VecBase< T, 3 > & r_scale )
inline

◆ to_scale() [1/2]

template<bool AllowNegativeScale = false, typename T >
VecBase< T, 2 > blender::math::to_scale ( const MatBase< T, 2, 2 > & mat)
inlinenodiscard

Definition at line 1257 of file BLI_math_matrix.hh.

References is_negative(), length(), result, and UNLIKELY.

◆ to_scale() [2/2]

template<bool AllowNegativeScale = false, typename T , int NumCol, int NumRow>
VecBase< T, 3 > blender::math::to_scale ( const MatBase< T, NumCol, NumRow > & mat)
inlinenodiscard

◆ to_vector() [1/2]

◆ to_vector() [2/2]

template<typename T >
T blender::math::to_vector ( const AxisSigned axis)

Create signed basis vector.

Definition at line 331 of file BLI_math_basis_types.hh.

References abs(), BLI_assert, and blender::math::AxisSigned::from_int().

◆ transform_direction() [1/4]

template float3 blender::math::transform_direction ( const float3x3 & mat,
const float3 & direction )
extern

◆ transform_direction() [2/4]

template float3 blender::math::transform_direction ( const float4x4 & mat,
const float3 & direction )
extern

◆ transform_direction() [3/4]

template<typename T >
VecBase< T, 3 > blender::math::transform_direction ( const MatBase< T, 3, 3 > & mat,
const VecBase< T, 3 > & direction )
nodiscard

Transform a 3d direction vector using a 3x3 matrix (rotation & scale).

Definition at line 1585 of file BLI_math_matrix.hh.

Referenced by blender::geometry::calc_position_with_interpolation(), blender::geometry::calc_position_without_interpolation(), blender::ed::greasepencil::DrawingPlacement::DrawingPlacement(), blender::ed::greasepencil::DrawingPlacement::DrawingPlacement(), blender::ed::view3d::geometry_nodes_gizmos::TransformGizmos::get_axis_gizmo_matrix_basis(), blender::workbench::get_light_data_from_studio_solidlight(), blender::ed::sculpt_paint::greasepencil::get_screen_projection_fn(), blender::ed::greasepencil::grease_pencil_texture_gradient_exec(), blender::workbench::ShadowPass::init(), blender::geometry::boolean::mesh_bm_concat(), blender::ed::sculpt_paint::min_distance_edit::min_distance_edit_invoke(), blender::modify_drawing(), nearest_world_tree(), blender::nodes::node_fn_transform_direction_cc::node_build_multi_function(), blender::ed::object::object_origin_set_exec(), blender::ed::greasepencil::pixel_radius_to_world_space_radius(), blender::ed::sculpt_paint::PuffOperationExecutor::puff(), raycastMesh(), SnapData::register_result(), SnapData::register_result_raycast(), blender::geometry::curve_constraints::solve_length_and_collision_constraints(), blender::tests::TEST(), transdata_elem_translate(), blender::ed::view3d::geometry_nodes_gizmos::TransformGizmos::update_rotate_transform_and_target_property(), blender::ed::view3d::geometry_nodes_gizmos::TransformGizmos::update_scale_transform_and_target_property(), and blender::ed::view3d::geometry_nodes_gizmos::TransformGizmos::update_translate_transform_and_target_property().

◆ transform_direction() [4/4]

template<typename T >
VecBase< T, 3 > blender::math::transform_direction ( const MatBase< T, 4, 4 > & mat,
const VecBase< T, 3 > & direction )
nodiscard

Transform a 3d direction vector using a 4x4 matrix (rotation & scale).

Definition at line 1591 of file BLI_math_matrix.hh.

References view.

◆ transform_point() [1/7]

template<typename T >
VecBase< T, 3 > blender::math::transform_point ( const CartesianBasis & basis,
const VecBase< T, 3 > & v )
inlinenodiscard

Definition at line 446 of file BLI_math_basis_types.hh.

References blender::math::Axis::as_int(), blender::math::AxisSigned::axis(), blender::math::AxisSigned::is_negative(), result, v, blender::math::CartesianBasis::x(), blender::math::CartesianBasis::y(), and blender::math::CartesianBasis::z().

Referenced by blender::geometry::add_curves_on_mesh(), blender::nodes::node_fn_align_rotation_to_vector_cc::align_rotations_auto_pivot(), blender::nodes::node_fn_align_rotation_to_vector_cc::align_rotations_fixed_pivot(), blender::ed::sculpt_paint::apply_crazyspace_to_translations(), blender::apply_gradient_tint(), blender::apply_stroke_transform(), applyTranslationValue(), BKE_armature_min_max(), BKE_grease_pencil_point_coords_apply(), BKE_grease_pencil_point_coords_apply_with_mat4(), BKE_grease_pencil_point_coords_get(), BKE_object_minmax(), BoneInstanceData::BoneInstanceData(), bounds_min_max_with_transform(), blender::ed::sculpt_paint::calc_brush_cube_distances(), blender::ed::sculpt_paint::calc_brush_cube_distances(), blender::ed::sculpt_paint::pose::calc_segment_translations(), blender::ed::sculpt_paint::calc_symm_area_transform_translations(), blender::ed::sculpt_paint::calc_transform_translations(), blender::ed::sculpt_paint::trim::calculate_depth(), blender::ed::sculpt_paint::greasepencil::calculate_view_positions(), blender::ed::sculpt_paint::greasepencil::calculate_view_radii(), blender::ed::sculpt_paint::clip_and_lock_translations(), blender::ed::sculpt_paint::clip_and_lock_translations(), blender::ed::sculpt_paint::cloth::cloth_brush_solve_collision(), blender::ed::sculpt_paint::CombOperationExecutor::comb_projected(), blender::ed::sculpt_paint::CombOperationExecutor::comb_spherical_with_symmetry(), blender::io::grease_pencil::compute_drawing_bounds(), blender::draw::copy_transformed_positions(), blender::deform_drawing(), blender::ed::sculpt_paint::DeleteOperationExecutor::delete_projected(), blender::ed::sculpt_paint::DeleteOperationExecutor::delete_spherical_with_symmetry(), blender::ed::greasepencil::image_render::draw_circles(), blender::ed::greasepencil::draw_control_points(), blender::ed::greasepencil::image_render::draw_dot(), blender::ed::greasepencil::image_render::draw_dots(), blender::ed::greasepencil::image_render::draw_grease_pencil_stroke(), blender::ed::greasepencil::image_render::draw_lines(), blender::draw::DebugDraw::draw_polygon(), blender::ed::greasepencil::image_render::draw_polyline(), drw_shgroup_bone_relationship_lines_ex(), drw_shgroup_bone_stick(), DRW_text_edit_mesh_measure_stats(), blender::ed::sculpt_paint::ensure_valid_pivot(), blender::ed::sculpt_paint::DensityAddOperationExecutor::execute(), blender::geometry::extend_curves_curved(), blender::bke::fill_mesh_positions(), blender::ed::sculpt_paint::filter_region_clip_factors(), blender::ed::sculpt_paint::filter_region_clip_factors(), blender::ed::sculpt_paint::PuffOperationExecutor::find_curve_weights_projected(), blender::ed::sculpt_paint::SlideOperationExecutor::find_curves_to_slide(), blender::ed::sculpt_paint::SlideOperationExecutor::find_curves_to_slide_with_symmetry(), blender::ed::sculpt_paint::PuffOperationExecutor::find_curves_weights_spherical_with_symmetry(), blender::ed::sculpt_paint::SmoothOperationExecutor::find_projected_smooth_factors(), blender::ed::sculpt_paint::SmoothOperationExecutor::find_spherical_smooth_factors_with_symmetry(), from_triangle(), from_vector(), blender::draw::View::frustum_boundbox_calc(), blender::ed::sculpt_paint::CurvesEffectOperationExecutor::gather_influences_projected(), blender::ed::sculpt_paint::CurvesEffectOperationExecutor::gather_influences_spherical(), blender::ed::greasepencil::get_boundary_bounds(), blender::get_distance_factor(), blender::ed::sculpt_paint::greasepencil::get_screen_projection_fn(), blender::ed::sculpt_paint::grease_pencil_fill_extension_cut(), blender::ed::sculpt_paint::grease_pencil_fill_extension_lines_from_circles(), blender::ed::sculpt_paint::grease_pencil_fill_get_extension_data(), blender::draw::grease_pencil_geom_batch_ensure(), blender::ed::greasepencil::grease_pencil_snap_compute_centroid(), blender::ed::greasepencil::grease_pencil_snap_to_cursor_exec(), blender::ed::greasepencil::grease_pencil_snap_to_grid_exec(), blender::ed::greasepencil::grease_pencil_texture_gradient_exec(), imapaint_pick_face(), ViewOpsData::init_navigation(), blender::geometry::boolean::mesh_bm_concat(), blender::ed::sculpt_paint::min_distance_edit::min_distance_edit_draw(), blender::ed::sculpt_paint::min_distance_edit::min_distance_edit_invoke(), MOD_lineart_gpencil_generate_v3(), motion_path_cache(), motionpaths_calc_bake_targets(), nearest_world_tree(), blender::nodes::node_fn_rotate_vector_cc::node_build_multi_function(), blender::nodes::node_fn_transform_point_cc::node_build_multi_function(), blender::nodes::node_geo_tool_3d_cursor_cc::node_geo_exec(), blender::ed::object::object_convert_exec(), blender::ed::object::object_origin_set_exec(), blender::draw::overlay::Relations::object_sync(), blender::ed::sculpt_paint::greasepencil::TintOperation::on_stroke_begin(), overlay_grease_pencil_draw_stroke_color_name(), blender::ed::sculpt_paint::SelectionPaintOperationExecutor::paint_curve_selection_spherical_with_symmetry(), blender::ed::sculpt_paint::SelectionPaintOperationExecutor::paint_point_selection_spherical_with_symmetry(), blender::ed::sculpt_paint::PinchOperationExecutor::pinch_projected(), blender::ed::sculpt_paint::PinchOperationExecutor::pinch_spherical_with_symmetry(), blender::ed::greasepencil::pixel_radius_to_world_space_radius(), blender::ed::greasepencil::primitive_local_to_screen(), blender::ed::sculpt_paint::greasepencil::PaintOperationExecutor::process_extension_sample(), blender::ed::greasepencil::DrawingPlacement::project(), blender::io::grease_pencil::GreasePencilExporter::project_to_screen(), blender::ed::sculpt_paint::SnakeHookOperatorExecutor::projected_snake_hook(), blender::ed::sculpt_paint::PuffOperationExecutor::puff(), raycastMesh(), blender::ed::sculpt_paint::DensitySubtractOperationExecutor::reduce_density_spherical_with_symmetry(), SnapData::register_result(), SnapData::register_result_raycast(), blender::ed::greasepencil::DrawingPlacement::reproject(), blender::ed::sculpt_paint::sample_curves_3d_brush(), blender::ed::sculpt_paint::sample_curves_surface_3d_brush(), blender::ed::sculpt_paint::AddOperationExecutor::sample_in_center_with_symmetry(), blender::ed::sculpt_paint::AddOperationExecutor::sample_projected(), blender::ed::sculpt_paint::DensityAddOperationExecutor::sample_projected_with_symmetry(), blender::ed::sculpt_paint::AddOperationExecutor::sample_spherical_with_symmetry(), blender::ed::sculpt_paint::DensityAddOperationExecutor::sample_spherical_with_symmetry(), blender::io::grease_pencil::shape_attributes_to_curves(), snapCamera(), blender::geometry::curve_constraints::solve_length_and_collision_constraints(), blender::ed::sculpt_paint::SnakeHookOperatorExecutor::spherical_snake_hook_with_symmetry(), blender::eevee::ShadowTileMap::sync_cubeface(), blender::math::tests::TEST(), blender::math::tests::TEST(), blender::math::tests::TEST(), blender::tests::TEST(), blender::ed::sculpt_paint::transform_brush_radius(), transform_point(), blender::ed::sculpt_paint::transform_positions(), blender::ed::sculpt_paint::transform_positions(), blender::bke::crazyspace::GeometryDeformation::translation_from_deformed_to_original(), blender::ed::curves::convert_to_particle_system::try_convert_single_object(), blender::draw::image_engine::OneTexture::update_bounds(), blender::draw::image_engine::ScreenTileTextures< Divisions >::update_bounds(), view3d_orbit_calc_center(), blender::eevee::VolumeObjectBounds::VolumeObjectBounds(), blender::io::obj::OBJWriter::write_vertex_coords(), and blender::write_weights_for_drawing().

◆ transform_point() [2/7]

template<typename T >
VecBase< T, 3 > blender::math::transform_point ( const DualQuaternionBase< T > & dq,
const VecBase< T, 3 > & point,
MatBase< T, 3, 3 > * r_crazy_space_mat = nullptr )
nodiscard

Transform point using the dual-quaternion dq . Applying the DualQuaternion transform can only happen if the DualQuaternion was normalized first. Optionally outputs crazy space matrix.

From: "Skinning with Dual Quaternions" Ladislav Kavan, Steven Collins, Jiri Zara, Carol O'Sullivan Trinity College Dublin, Czech Technical University in Prague

Definition at line 486 of file BLI_math_quaternion.hh.

References BLI_assert, is_normalized(), is_unit_scale(), M, point, blender::math::DualQuaternionBase< T >::quat, result, blender::math::DualQuaternionBase< T >::scale, blender::math::DualQuaternionBase< T >::scale_weight, T, blender::math::DualQuaternionBase< T >::trans, transform_point(), and view.

◆ transform_point() [3/7]

template float3 blender::math::transform_point ( const float3x3 & mat,
const float3 & point )
extern

◆ transform_point() [4/7]

template float3 blender::math::transform_point ( const float4x4 & mat,
const float3 & point )
extern

◆ transform_point() [5/7]

template<typename T >
VecBase< T, 3 > blender::math::transform_point ( const MatBase< T, 3, 3 > & mat,
const VecBase< T, 3 > & point )
nodiscard

Transform a 3d point using a 3x3 matrix (rotation & scale).

Definition at line 1573 of file BLI_math_matrix.hh.

References point.

◆ transform_point() [6/7]

template<typename T >
VecBase< T, 3 > blender::math::transform_point ( const MatBase< T, 4, 4 > & mat,
const VecBase< T, 3 > & point )
nodiscard

Transform a 3d point using a 4x4 matrix (location & rotation & scale).

Definition at line 1579 of file BLI_math_matrix.hh.

References blender::MatBase< T, NumCol, NumRow, Alignment >::location(), and view.

◆ transform_point() [7/7]

template<typename T >
VecBase< T, 3 > blender::math::transform_point ( const QuaternionBase< T > & q,
const VecBase< T, 3 > & v )
inlinenodiscard

◆ translate()

template<typename T , int NumCol, int NumRow, typename VectorT >
MatBase< T, NumCol, NumRow > blender::math::translate ( const MatBase< T, NumCol, NumRow > & mat,
const VectorT & translation )
nodiscard

◆ transpose()

◆ vector_hash()

template<typename T >
uint64_t blender::math::vector_hash ( const T & vec)

Definition at line 48 of file BLI_math_vector_types.hh.

References BLI_STATIC_ASSERT, and result.

◆ whitepoint_from_temp_tint()

◆ whitepoint_to_temp_tint()

bool blender::math::whitepoint_to_temp_tint ( const float3 & white,
float & temperature,
float & tint )

Variable Documentation

◆ is_math_float_type

template<typename T >
bool blender::math::is_math_float_type = std::is_floating_point_v<T>
inlineconstexpr

Definition at line 20 of file BLI_math_base.hh.

◆ is_math_integral_type

template<typename T >
bool blender::math::is_math_integral_type = std::is_integral_v<T>
inlineconstexpr

Definition at line 21 of file BLI_math_base.hh.

◆ planck_locus

const std::array<locus_entry_t, 31> blender::math::planck_locus
static
Initial value:
{{
{0.0f, {0.18006f, 0.26352f}, -0.24341f}, {10.0f, {0.18066f, 0.26589f}, -0.25479f},
{20.0f, {0.18133f, 0.26846f}, -0.26876f}, {30.0f, {0.18208f, 0.27119f}, -0.28539f},
{40.0f, {0.18293f, 0.27407f}, -0.30470f}, {50.0f, {0.18388f, 0.27709f}, -0.32675f},
{60.0f, {0.18494f, 0.28021f}, -0.35156f}, {70.0f, {0.18611f, 0.28342f}, -0.37915f},
{80.0f, {0.18740f, 0.28668f}, -0.40955f}, {90.0f, {0.18880f, 0.28997f}, -0.44278f},
{100.0f, {0.19032f, 0.29326f}, -0.47888f}, {125.0f, {0.19462f, 0.30141f}, -0.58204f},
{150.0f, {0.19962f, 0.30921f}, -0.70471f}, {175.0f, {0.20525f, 0.31647f}, -0.84901f},
{200.0f, {0.21142f, 0.32312f}, -1.0182f}, {225.0f, {0.21807f, 0.32909f}, -1.2168f},
{250.0f, {0.22511f, 0.33439f}, -1.4512f}, {275.0f, {0.23247f, 0.33904f}, -1.7298f},
{300.0f, {0.24010f, 0.34308f}, -2.0637f}, {325.0f, {0.24792f, 0.34655f}, -2.4681f},
{350.0f, {0.25591f, 0.34951f}, -2.9641f}, {375.0f, {0.26400f, 0.35200f}, -3.5814f},
{400.0f, {0.27218f, 0.35407f}, -4.3633f}, {425.0f, {0.28039f, 0.35577f}, -5.3762f},
{450.0f, {0.28863f, 0.35714f}, -6.7262f}, {475.0f, {0.29685f, 0.35823f}, -8.5955f},
{500.0f, {0.30505f, 0.35907f}, -11.324f}, {525.0f, {0.31320f, 0.35968f}, -15.628f},
{550.0f, {0.32129f, 0.36011f}, -23.325f}, {575.0f, {0.32931f, 0.36038f}, -40.770f},
{600.0f, {0.33724f, 0.36051f}, -116.45f},
}}

Definition at line 883 of file math_color.cc.

Referenced by whitepoint_from_temp_tint(), and whitepoint_to_temp_tint().