bezier curve problem

Blitz3D Forums/Blitz3D Programming/bezier curve problem

Chevron(Posted 2005) [#1]
Why do my aliens always seem to swoop off to the left with the following code. i.e the bezier curve generated always seems to loop off to the left and not random left/right as I want (Hope you get that).

bezier co-ords generated here:


If swoop_num<max_swoop

If inv1\swoop=False
swoop_on=Rnd(0,swoop_freq)
If swoop_on=0
swoop_num=swoop_num+1
inv1\swoop=True
inv1\x1=inv1\x
inv1\y1=inv1\y
inv1\cmx1=inv1\x1+Rnd(-400,400)

inv1\cmy1=inv1\y1+Rnd(-100,100)

inv1\x2=Rnd(100,700)
inv1\y2=600
inv1\cmx2=Rnd(-500,500)
inv1\cmy2=Rnd(-400,400)
EndIf
EndIf

EndIf

here the beizer code:


If inv1\swoop=True

inv1\t#=inv1\t#+0.004

inv1\x= inv1\x1*(1-inv1\t)^3 + 3*inv1\cmx1*(1-inv1\t)^2*inv1\t + 3*inv1\cmx2*(1-inv1\t)*inv1\t^2 + inv1\x2*inv1\t^3
inv1\y= inv1\Y1*(1-inv1\t)^3 + 3*inv1\cmy1*(1-inv1\t)^2*inv1\t + 3*inv1\cmy2*(1-inv1\t)*inv1\t^2 + inv1\y2*inv1\t^3

If inv1\y=>600;inv1\t#>=1
inv1\t#=0
swoop_num=swoop_num-1
;inv1\swoop=False
Delete inv1

EndIf
EndIf


jfk EO-11110(Posted 2006) [#2]
It's only a guess, but maybe it has something to do with the following paradoxon:

print -10^2
print  10^2


will give you 100 both times.


Chevron(Posted 2006) [#3]
Yeah,thanks for that jfk, I think that this could be it, but I need to put a little more thought into this.
Thanks for the pointer.


VP(Posted 2006) [#4]
Just randomly negate the x coord (once per 'swoop' of course).

x^n will always yield positive, unless you're really into complex numbers ;)


Chevron(Posted 2006) [#5]
Hi VP,

At the moment the line -

inv1\x1=inv1\x

sets the start point of the curve to the x position of the alien.

inv1\cmx1=inv1\x1+Rnd(-400,400)

sets the curve modifier for the curve.

So I would have assumed that this would provide me with the offset that I require.