Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Law Of Sines?



A friend of mine made this picture to illustrate the law of sines:



I kinda see a pattern, but not completely...and I don't know how this knowledge would be useful.



FlashKit > Flash Help > Flash General Help
Posted on: 03-24-2004, 10:21 AM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Sines
Hi

I'm trying to create a loop which generates a single series of sine results ranging from 0 to 1 based on 100 loops ( ie 0 ,0.011 ,0.1111........up to 1 in a single run)

The results I want start at 0 and increment in a series up to 1 and then stop. I suppose this would be one half of a sine wave

I have tried the following but it goes from 0 to 1 ,1 to 0 , 0 to 1 etc whereas I want a single straight run of 100 values from 0 to 1

I tried :

for(var i:Number=0;i<=100;i++){

trace((0.5*Math.sin(i)) + 0.5);

}

This does not work. Can someone correct it

Sines 2
Hi

The following code generates sine results from 0 to 1 from 100 loops

How to I change it to generate the following 4 results

a)0 to 1 to 0

and

b)-1 to 0 to 1

and

c)-1 to 0 to 1 to 0 to -1

and

d) 1 to 0

from 100 loops

Here's the code

//100 loops to produce sin results from 0 to 1;
var loopCount=0;
var desiredLoops=100;
for (var i:Number=0;i<=Math.PI/2;i+= Math.PI/(desiredLoops*2)){
trace("loopCount = "+loopCount);
trace("Sin = "+Math.sin(i));
loopCount++;
}

Angles, Sines, Cosines, Moving An Mc
Hi, I'm having some problems. I'm trying to create a function that moves a certain movieclip to a given x and y and at a given speed. It works only so that the movieclip now can move only to the right and I still haven't figured out how to stop it. I'm suspecting that it has something to do with the angles and such. Here's the function.

ActionScript Code:
MovieClip.prototype.travelTo = function(xpos, ypos, speed) {    this.moving = TRUE;    this.ang = Math.atan((ypos - this._y)/(xpos-this._x));    this.onEnterFrame = function() {        this._x += Math.cos(this.ang) * speed;        this._y += Math.sin(this.ang) * speed;    }}

See, I get the angle by using the arctan function on the difference between the given y and the current y of the movieclip and the given x and the current x of the movieclip. That's line 3. Then I just make it move in the x direction by cos * speed each frame and in the y direction by sin * speed each frame. Seems simple enough, no? It should work but as I said, it can only move to the right. If I tell it to move somewhere to its left, it moves in the direct opposite direction - thus moving to the right.
I've included a .fla file (move.fla) with the demonstration, the function is in the frame and the movieclip goes to your mouse cursor when you press space (the red button is triggered by space and it calls the function).
I've also included an angles.fla, which I've made to demonstrate how I can't get flash to display angles, sines and cosines correctly. For instance in the second quadrant, it displays a negative sine. And we all know the sine is always positive in the second quadrant.
And isn't the angle supposed to go from 0 to 2PI? Here, it goes from 0 to PI/2 and then switches over to -PI/2. Strange indeed.
I'd appreciate it if someone could take a look at these flas.
Thanks in advance!

Angles, Sines, Cosines, Moving An Mc
Hi, I'm having some problems. I'm trying to create a function that moves a certain movieclip to a given x and y and at a given speed. It works only so that the movieclip now can move only to the right and I still haven't figured out how to stop it. I'm suspecting that it has something to do with the angles and such. Here's the function.

ActionScript Code:
MovieClip.prototype.travelTo = function(xpos, ypos, speed) {    this.moving = TRUE;    this.ang = Math.atan((ypos - this._y)/(xpos-this._x));    this.onEnterFrame = function() {        this._x += Math.cos(this.ang) * speed;        this._y += Math.sin(this.ang) * speed;    }}

See, I get the angle by using the arctan function on the difference between the given y and the current y of the movieclip and the given x and the current x of the movieclip. That's line 3. Then I just make it move in the x direction by cos * speed each frame and in the y direction by sin * speed each frame. Seems simple enough, no? It should work but as I said, it can only move to the right. If I tell it to move somewhere to its left, it moves in the direct opposite direction - thus moving to the right.
I've included a .fla file (move.fla) with the demonstration, the function is in the frame and the movieclip goes to your mouse cursor when you press space (the red button is triggered by space and it calls the function).
I've also included an angles.fla, which I've made to demonstrate how I can't get flash to display angles, sines and cosines correctly. For instance in the second quadrant, it displays a negative sine. And we all know the sine is always positive in the second quadrant.
And isn't the angle supposed to go from 0 to 2PI? Here, it goes from 0 to PI/2 and then switches over to -PI/2. Strange indeed.
I'd appreciate it if someone could take a look at these flas.
Thanks in advance!

Copyright © 2005-08 www.BigResource.com, All rights reserved