Archive: Spirograph scope


26th October 2003 00:00 UTC

Spirograph scope
Hey, I'm new to AVS, and I was looking at the examples for the scopes, and stumbled across the spirograph one...would anyone be helpful enough to explain how it works?

Thanks :)


26th October 2003 02:25 UTC

The spirograph works like this.
Whe the preset starts, (on initiation(sp?), or init), the number of points being drawn(variable n) is set to 100, and the variable t is set to zero. Thats not very hard to understand if you know some basic algerbra and how AVS works.
In the frame box, the equations in there occur for every frame. So, the equation t=t+0.01 will add 0.01 to the variable t every frame.
The beat box has equations that occur on every beat. So every time AVS detects a beat, the variable n is set to a random number between 80+0 and 80+120. What that does is it allows for the different spirograph patterns.
In the per point box, equations there happen for every point, the number of points is set by the variable n. The way AVS draws the spirograph is using sine and cosine math, the reason it does this is Sine, (sin), and cosine, (cos), are trigometric functions, if you have taken a trigometry course you will know what they do for some extent, but for AVS they are useful because they will return a value from 1 to -1 and they repeat every pi. Back to the code, the first line r=i*pi*128+t sets the r value for every point. The variable r, is more frequently used in polar graphing, what it is is the distance from the r=0 line arund in a circle. In this superscope, it is used as the position around a circle. So the actual equation would do this, it would set the variable r for each point as i*pi*128+t, ibeing a variable from 0 to 1 which acts as a counter that incresas from point to point by something like 1/(n-1), pi is 3.14..., and t is the counter set in per frame. Next comes the variables x and y. These variables are used by Superscopes to give every poin an x and y value in the AVS window. If you know how to do plane graphing(I don't think this is the right term, I can't rember the right one off the top of my head, sorry), Superscopes use the same graphing format for x and y, except the y axis is inverted, meaing y=-1 is the top of your AVS window, and y=1 is the bottom, x and y both range from 1 to -1, with (0,0) being the center of your AVS window. Now, the actual equations for x and y are easy to understand if you rember how sines and cosine work. THe equation x=cos(r/64)*.7+sin(r)*.3, sets the x corodinate, cos(r/64)*.7 will give a number from -.7 to .7 based on the value of r for the point being drawn, then it adds sin(r)*.03, which would be adding a number anywere from -.3 to .3 based on r. The equation for y works the exact same way, except it switches sine and cosine around.
So, in conclusion, the Spirograph works by taking taking the sines and cosines of the variable r, then multiplying them by a fraction to reduce that number so that it fits inside the AVS window.


26th October 2003 02:54 UTC

In short, it simulates those nifty real-life spirograph makers (Ya know, a circle inside a bigger circle, put a pencil/pen in one of the holes of the smaller one, spin it around)
(Wait, do they have these kinds of things here? hmmh...)
(Google it)


26th October 2003 10:16 UTC

A little clarification for supertoast's use of the word equation. A more appropriate word is assignment or statement.

The following statement is valid in avs:
x=x+1

But in math it's invalid (x cannot equal itself plus 1). In AVS it means 'take the value of x, add one to it, and put the result back in x'.


26th October 2003 18:35 UTC

thanks :)
Thanks a lot S-uper_T-oast and UnConeD...I think I get it now :), that'll help me experiment with the scopes, while kinda knowing what I'm doing :O


26th October 2003 21:53 UTC

Your right UnConeD, I don't really think about AVS things as statements or assignments, but as "equations" so, I typed it out that way with out thinking.
Sure thing therealpw2, I look forward to seeing some of your presets!