All pastes #22101 Raw Edit

Something

public text v1 · immutable
#22101 ·published 2005-09-04 14:42 UTC
rendered paste body
def floor(val, flr):
	if val < flr:
		return flr
	return val

def roof(val, rf):
	if val > rf:
		return rf
	return val

def clamp(val, min, max):
	if val > max:
		return max
	if val < min:
		return min
	return val

def step(val, thrs):
	if val > thrs:
		return 1
	return 0

def smooth_step(x, a, b):
	if x < a:
		return 0
	if x > b:
		return 1
	z = (x - a) / (b - a)
	return z**2*(3-2*z)

def pulse(a, b):
	if a < x < b:
		return 1
	return 0

def smooth_pulse(x, a, b):
	z = (x - a) / (b - a)
	return smooth_step(x, a - z, a) - smooth_step(x, b - z, b)
 
def repeat(x, a):
	return x % a

def magnitude(coords):
	return ([coords[i]**2 for i in range(len(coords))].sum())**2

def distance(coords1, coords2):
	return magnitude([coords1[i]-coords2[i] for i in range(len(coords1))])

def turbulence(freq,coords):
	turb = 0
	f = 0
	while(f < freq):
		turb += abs(Blender.Noise(coords)) / f
	return turb
	
def noise( ):
	return Blender.Mathutils.Rand()