Calculator Community > Axe

Curve-fitting

(1/1)

squidgetx:
~~~~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

Quigibo:
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.

squidgetx:
hmmm sounds like that could work. thanks.

squidgetx:
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: ---: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
--- End code ---

And then I changed it to match Axe syntax:

--- Code: ---:.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
--- End code ---

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

Navigation

[0] Message Index

Go to full version