Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: squidgetx on May 30, 2010, 01:57:08 pm

Title: Curve-fitting
Post by: squidgetx on May 30, 2010, 01:57:08 pm
~~~~axe is smexy~~~

anyway, i'm working on a version of tanks (scorched earth) and I'm wondering if anyone has any ideas on a routine for map-drawing. Smooth, random curves with varying amplitudes and periods: I was using the sin( function, but its epically confusing, what with the period being 255, etc
Title: Re: Curve-fitting
Post by: Quigibo on May 30, 2010, 07:01:16 pm
You can get a nice parabolic smoothing by having a "height map" particle move across the screen with applied random gravity.  If the velocity gets too positive, make the gravity negative and if the velocity is too negative, make gravity positive.  Also, have the gravity flip at random intervals.  That gives a very smooth curve that resembles random wave motion in a cool way.
Title: Re: Curve-fitting
Post by: squidgetx on May 30, 2010, 08:24:03 pm
hmmm sounds like that could work. thanks.
Title: Re: Curve-fitting
Post by: squidgetx on May 31, 2010, 05:40:43 pm
Ok...  because of my unfamiliarity with Axe's system of numbers I decided to try in BASIC first; I managed to make it work but not in axe: it produces a bunch of random vertical lines

BASIC version
Code: [Select]
:ClrDraw
:0->Xmin
:0->Ymin
:94->Xmax
:62-.Ymax
:8->V
:5->G
:0->A
:40->L2(1
:For(X,1,94
:L2(x)-2GA/V^2->L2(x+1)
:A+1->A
:If 2<abs(-2GA/V^2
:Then
:-G+randInt(-2,2->G
:-9->A
;End
:End
;For(A,1,94
:Line(A,L2(A),A+1,L2(A+1)
:End

And then I changed it to match Axe syntax:
Code: [Select]
:.AMAP
:ClrDraw
:8->V
:5->G
:0->A
:deltaList(40)->GDB1
:For(X,1,94
:-2*G*A//V//V+{X+GDB1}->{GDB1+X+1
:A+1->A
:If 2<abs(-2*G*A//V//V
:-G->G
:-9->A
;End
:End
:For(A,0,94
:Line(A,{GDB1+A},A+1,{GDB1+A+1
:End
;DispGraph
;Repeat getKey
:End

The basic idea is to just change the Y value by the derivative of the equ gx^2/v^2 + y where g= grav. constant, v=intitial velocity, and y= initial height and flip the gravity when f'x>2