Monday, June 2, 2008

ABCDEFGHIJKLMNOPQRSTUVWXYZ

OKAAAAAAAAYYYY

So the four corner point thing didn't work out so well... It's basically a lot more buggy than the first version, but perhaps I messed up a corner. Who knows.

In other news I've been working with some trig and managed to make a rotating circle program. I think I might dedicate a page of my website to Flash swf's since I learned the other day that I have 300gigs of space to use (maxhardcastle.com server thing).

Here's a snippet of code from that program outlining some new stuff:

angle = Math.atan(mousex/mousey)

xval = _root.circle._x + radius*Math.cos(angle);
yval = _root.circle._y - radius*Math.sin(angle);


New terms:
Math.atan - This is the "arctan" or inverse tangent function ... returns a value in radians ...
Math.cos - cosine...
Math.sin - sine...
and later on:
Math.PI - 3.141592653584626 (That's all I can remember... might be wrong)

Here the code finds the angle that the mouse creates in relation to the center of the coordinate plane designated by the center of the movie clip that this code resides in. That might seem complicated, but it really isn't. There is a circle on the screen, the center of the circle is the origin. Imagine there is a point where the mouse is, now draw a line from that point to the origin, and then find the angle of that line in relation to the x axis.

The second part calculates the x and y coordinates where the imaginary line from the mouse crosses the circle on the screen.

As I mentioned earlier, all this would be so much easier with an example of this program because it's hard to describe exactly what I have created.

if( mousey > 0 ){
degrees = ((((Math.atan(mousex/mousey))*(180/Math.PI))+90)+180);
}
if( mousey < 0 ){
degrees = (((Math.atan(mousex/mousey))*(180/Math.PI))+90);
}


This code finds the angle the mouse creates in degrees (normally it's in radians) hence the name of the variable "degrees" ...

Flash movies coming soon! (I hope)

No comments: