Gradient vector field Custom tool
Tool script
f(x, y) = x^2 - y^2
#------------------------------------
# Some interesting examples:
#------------------------------------
# -(sqrt(x² + y²) + 1 / sqrt(x² + y²)) cos(atan2(y,x))
# ln(sqrt((x + 1)² + y²)) - ln(sqrt((x - 1)² + y²))
# 1/sqrt(x^2+y^2)
# sqrt(x^2+y^2)
# arctan2(y,x)
fx(x, y) = Derivative(f, x)
fy(x, y) = Derivative(f, y)
scale = 0.15
density = 10
xstep = (x(Corner(3)) - x(Corner(1))) / (density + 1)
ystep = (y(Corner(3)) - y(Corner(1))) / (density + 1)
Lx = Sequence(k, k, x(Corner(1)), x(Corner(3)), xstep)
Ly = Sequence(k, k, y(Corner(1)), y(Corner(3)), ystep)
vectorField = Zip(Zip(Vector((j, k), (j + scale fx(j, k), k + scale fy(j, k))), j, Lx), k, Ly)