How Maple helps

Sometimes it’s good to test some math model before coding it into ActionScript or any other language, draw some cool graphs and play with parameters. Of course you could write a simple flash application to draw graphs for you but why waste time if there are a lot of math software around? In school we used Maple, so from time to time I use it to check stuff before actually coding it. I have to say that I’m not good at it but my knowledge is enough for my own tasks.

Well, right now I need to code a pseudo random movement. I need some kind of a periodic pattern with bursts and decaying.

So, I opened Maple and set several constants I had in mind.

mpl1

minAmp — minimal value of global amplitude,
maxAmp — maximum value,
minLen — minimal wave length,
deltaLen — minLen + deltaLen = maxLen — maximum wave length,
speed — wave speed (rendered useless).

After that I wrote functions for amplitude.

mpl2

In the example I used constant wave length, didn’t have time to play more with it. Here everything is simple. We have some x value from which wave length and amplitude is counted. Both are periodical.

mpl4

Here’s the graph.

mpl3

Now we can add one more sin which will be limited by this amplitude.

mpl5

We are getting a periodical movement but it’s too boring. Here goes the magic.

mpl6

This function generates all the randomness. Simply put, there’s some seed which grows from 0 to 1 (actually a bit more) by dseed and after it reaches 1 it goes back to almost zero and dseed (delta seed — seed change speed) changes to some other value controlled by minRand and ampRand. At the end we get new value in the last line.

That’s how we get such a jerky rhythm, and because of dseed the movement can be be fast and slow. And everything is limited by periodic amplitude.

Let’s check the result.

mpl7

This is just what I wanted. If you play with parameters a bit ou can get very interesting results.

Here’s the example. You shouldn’t stare it for a long time q: It uses much CPU so I recommend you to close the tab after you finish reading.

Maple source.

0 Response to “How Maple helps”


  • No Comments

Leave a Reply