I'm pretty poor at maths but managed to get someone who is decent at it to come up with a linear algebraic formula for the control over the distribution of points along a straight line.

The formula is:

$$f(x) = \left(\frac xL\right)^{\frac 1c}L$$

Would anyone be kind enough and help me translate that into a function I can write within Blender python?

Thanks in advance.


2 Answers 2


With numpy

An ideal candidate for using numpy For example, can define a sequence

>>> x = np.arange(5)
>>> x
array([0, 1, 2, 3, 4])

and run a function quickly over all items, simple example squaring them.

>>> np.power(x, 2)
array([ 0,  1,  4,  9, 16])

Halving and squaring

>>> np.power(x / 2, 2)
array([0.  , 0.25, 1.  , 2.25, 4.  ])

The question equation.

Test script, defines a function of $x$ with scalars (assume they're scalars) $L$ and $c$

import bpy
import numpy as np

def distribute(x, L, c):
    return L * np.power(x / L, 1 / c)

# test run

x = np.arange(20)
for d in distribute(x, 10, 2):
    bpy.ops.object.empty_add(location=(d, 0, 0))

enter image description here

Empties placed as result of test run.


Create curve from Numpy Array using Python

  • 1
    $\begingroup$ What an excellently described answer. Thanks for this. Numpy really is a great extension to the core functionality. $\endgroup$ Apr 12, 2021 at 19:14

The python expression is:

y = (x / L) ** ( 1 / c) * L

  • $\begingroup$ Although I'm going with the answer above, this is still really useful to know what the literal translation looks like. So thanks for your input. $\endgroup$ Apr 12, 2021 at 19:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .