Hello
I got this function from the internet(at least the maths for it), and it just wont work! It`s supposed to make a dint in a matrix, as if you bounce a ball onto a piece of cloth.
Here are some screenies:
This is what it should look like, only a little rounder at the top:
If I change the "spread" value from one(above) to 2, I get these stupid flat spaces:
And if I change "spread" to a higher number, like 5, I get even bigger flat spaces:
I need these flat spaces to smooth out!
here`s the code:
function gaussian_function(x,y,centerx,centery,spread,intensity)
xterm=((x-centerx)/spread)^2
yterm=((y-centery)/spread)^2
height#=intensity*2.718281828^(0-(xterm+yterm))
endfunction height#
and this is how I use the function:
rem setup screen
sync on
sync rate 30
backdrop on
color backdrop 0
hide mouse
rem make a matrix
make matrix 1,1000,1000,50,50
rem set variables
centerx=25:`where the hill should be on the x axis
centery=25:`where the hill should be on the y axis
spread=1:`how big should the hill be
intensity:`how high should the hill be
rem make the gaussian hill
for x=0 to 50:`maximum matrix width
for y=0 to 50:`maximum matrix height
height#=gaussian_function(x,y,centerx,centery,spread,intensity)
set matrix height 1,x,y,height#
next y
next x
update matrix 1
Any help will be greatly appreciated
TheComet