Blender  V3.3
bl_math_py_api.c File Reference
#include <Python.h>
#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "py_capi_utils.h"
#include "bl_math_py_api.h"

Go to the source code of this file.

Functions

Module Doc String
 PyDoc_STRVAR (M_bl_math_doc, "Miscellaneous math utilities module")
 
Python Functions
 PyDoc_STRVAR (py_bl_math_clamp_doc, ".. function:: clamp(value, min=0, max=1)\n" "\n" " Clamps the float value between minimum and maximum. To avoid\n" " confusion, any call must use either one or all three arguments.\n" "\n" " :arg value: The value to clamp.\n" " :type value: float\n" " :arg min: The minimum value, defaults to 0.\n" " :type min: float\n" " :arg max: The maximum value, defaults to 1.\n" " :type max: float\n" " :return: The clamped value.\n" " :rtype: float\n")
 
static PyObject * py_bl_math_clamp (PyObject *UNUSED(self), PyObject *args)
 
 PyDoc_STRVAR (py_bl_math_lerp_doc, ".. function:: lerp(from_value, to_value, factor)\n" "\n" " Linearly interpolate between two float values based on factor.\n" "\n" " :arg from_value: The value to return when factor is 0.\n" " :type from_value: float\n" " :arg to_value: The value to return when factor is 1.\n" " :type to_value: float\n" " :arg factor: The interpolation value, normally in [0.0, 1.0].\n" " :type factor: float\n" " :return: The interpolated value.\n" " :rtype: float\n")
 
static PyObject * py_bl_math_lerp (PyObject *UNUSED(self), PyObject *args)
 
 PyDoc_STRVAR (py_bl_math_smoothstep_doc, ".. function:: smoothstep(from_value, to_value, value)\n" "\n" " Performs smooth interpolation between 0 and 1 as value changes between from and " "to values.\n" " Outside the range the function returns the same value as the nearest edge.\n" "\n" " :arg from_value: The edge value where the result is 0.\n" " :type from_value: float\n" " :arg to_value: The edge value where the result is 1.\n" " :type to_value: float\n" " :arg factor: The interpolation value.\n" " :type factor: float\n" " :return: The interpolated value in [0.0, 1.0].\n" " :rtype: float\n")
 
static PyObject * py_bl_math_smoothstep (PyObject *UNUSED(self), PyObject *args)
 

Module Definition

static PyMethodDef M_bl_math_methods []
 
static struct PyModuleDef M_bl_math_module_def
 
PyMODINIT_FUNC BPyInit_bl_math (void)
 

Detailed Description

This file defines the 'bl_math' module, a module for math utilities.

Definition in file bl_math_py_api.c.

Function Documentation

◆ BPyInit_bl_math()

PyMODINIT_FUNC BPyInit_bl_math ( void  )

Definition at line 142 of file bl_math_py_api.c.

References M_bl_math_module_def.

◆ py_bl_math_clamp()

static PyObject* py_bl_math_clamp ( PyObject *  UNUSEDself,
PyObject *  args 
)
static

Definition at line 45 of file bl_math_py_api.c.

References CLAMP, NULL, and x.

◆ py_bl_math_lerp()

static PyObject* py_bl_math_lerp ( PyObject *  UNUSEDself,
PyObject *  args 
)
static

Definition at line 78 of file bl_math_py_api.c.

References Freestyle::a, usdtokens::b(), NULL, and x.

◆ py_bl_math_smoothstep()

static PyObject* py_bl_math_smoothstep ( PyObject *  UNUSEDself,
PyObject *  args 
)
static

Definition at line 103 of file bl_math_py_api.c.

References Freestyle::a, usdtokens::b(), CLAMP, NULL, t, and x.

◆ PyDoc_STRVAR() [1/4]

PyDoc_STRVAR ( M_bl_math_doc  ,
"Miscellaneous math utilities module  
)

◆ PyDoc_STRVAR() [2/4]

PyDoc_STRVAR ( py_bl_math_clamp_doc  ,
".. function:: clamp(value, min=0, max=1)\n" "\n" " Clamps the float value between minimum and maximum. To avoid\n" "  confusion,
any call must use either one or all three arguments.\n" "\n" " :arg value:The value to clamp.\n" " :type value:float\n" " :arg min:The minimum  value,
defaults to 0.\n" " :type min:float\n" " :arg max:The maximum  value,
defaults to 1.\n" " :type max:float\n" " :return:The clamped value.\n" " :rtype:float\n"   
)

◆ PyDoc_STRVAR() [3/4]

PyDoc_STRVAR ( py_bl_math_lerp_doc  ,
".. function:: lerp(from_value, to_value, factor)\n" "\n" " Linearly interpolate between two float values based on factor.\n" "\n" " :arg from_value: The value to return when factor is 0.\n" " :type from_value: float\n" " :arg to_value: The value to return when factor is 1.\n" " :type to_value: float\n" " :arg factor: The interpolation  value,
normally in .\n" " :type factor:float\n" " :return:The interpolated value.\n" " :rtype:float\n"  [0.0, 1.0] 
)

◆ PyDoc_STRVAR() [4/4]

PyDoc_STRVAR ( py_bl_math_smoothstep_doc  ,
".. function:: smoothstep(from_value, to_value, value)\n" "\n" " Performs smooth interpolation between 0 and 1 as value changes between from and " "to values.\n" " Outside the range the function returns the same value as the nearest edge.\n" "\n" " :arg from_value: The edge value where the result is 0.\n" " :type from_value: float\n" " :arg to_value: The edge value where the result is 1.\n" " :type to_value: float\n" " :arg factor: The interpolation value.\n" " :type factor: float\n" " :return: The interpolated value in .\n" " :rtype: float\n"  [0.0, 1.0] 
)

Variable Documentation

◆ M_bl_math_methods

PyMethodDef M_bl_math_methods[]
static
Initial value:
= {
{"clamp", (PyCFunction)py_bl_math_clamp, METH_VARARGS, py_bl_math_clamp_doc},
{"lerp", (PyCFunction)py_bl_math_lerp, METH_VARARGS, py_bl_math_lerp_doc},
{"smoothstep", (PyCFunction)py_bl_math_smoothstep, METH_VARARGS, py_bl_math_smoothstep_doc},
{NULL, NULL, 0, NULL},
}
static PyObject * py_bl_math_smoothstep(PyObject *UNUSED(self), PyObject *args)
static PyObject * py_bl_math_clamp(PyObject *UNUSED(self), PyObject *args)
static PyObject * py_bl_math_lerp(PyObject *UNUSED(self), PyObject *args)

Definition at line 123 of file bl_math_py_api.c.

◆ M_bl_math_module_def

struct PyModuleDef M_bl_math_module_def
static
Initial value:
= {
PyModuleDef_HEAD_INIT,
"bl_math",
M_bl_math_doc,
0,
NULL,
NULL,
NULL,
NULL,
}
static PyMethodDef M_bl_math_methods[]

Definition at line 123 of file bl_math_py_api.c.

Referenced by BPyInit_bl_math().