You are not logged in.

- Topics: Active | Unanswered

- Index
- » Search
- »
**Posts by Paul**

Pages: **1**

**Paul**- Replies: 1

Yesterday I wrote asking the following

Hello

I have been trying to program some sine equations.

My hope has been to create a loop of 100 iterations to generate results from 0 to 1 which has been successful

I have started with i set to 0

I have incremented it by Pi/200 stopping when i gets to Pi/2

And sin(i) has produced 0 to 1 as hoped for.

The problem is how do I generate 0 to 1 to 0 again

I have tried stopping i when it gets to pi which works very well until the final loop where I get a tiny value. Can anyone help. Am i trying the impossible?

--------------------------

I was asked to supply the code. Here it is

It works great but the last value I get is

Sin = 1.12246908816338e-14

when I was hoping for 0

maybe it is just a rounding problem as suggested

---code---------------

//100 loops to produce sin results from 0 to 1;

//trace() outputs to screen

var loopCount=0;

var desiredLoops=100;

for (var i:Number=0;i<=Math.PI;i+= Math.PI/(desiredLoops*2)){

trace("loopCount = "+loopCount);

trace("Sin = "+Math.sin(i));

loopCount++;

}

------------------------

One further question

How could I modify the code to produce

-1 to 0 to 1 to 0 to -1

**Paul**- Replies: 2

Hello

I have been trying to program some sine equations.

My hope has been to create a loop of 100 iterations to generate results from 0 to 1 which has been successful

I have started with i set to 0

I have incremented it by Pi/200 stopping when i gets to Pi/2

And sin(i) has produced 0 to 1 as hoped for.

The problem is how do I generate 0 to 1 to 0 again

I have tried stopping i when it gets to pi which works very well until the final loop where I get a tiny value. Can anyone help. Am i trying the impossible?

**Paul**- Replies: 4

Hello

I am trying to generate a set of sine curve values that range from 0 to 1 to 0

I am using seed values of 1 to 100

I have got close with the following formula but it's not correct

If i ranges from 0 to 100

then

x=sin(i/30)

gets me from 0 to

0.998045198613548 to

-0.190567962875485

how do I get from

0 to

1 to

0

using i

Thanks

**Paul**- Replies: 1

Hi

I am writing a computer progrom which plots a curve

I want to be able to input the start screen co-ordinated and the destination co-ordinates.

So for example. I may wish to start at 100,100 on the screen and end at 150,150. I want to plot a sine curve between these 2 points.

The formula I use to plot a sine curve is

x=x+1;

y=y-sin(degrees)*radius;

The - is required here for the program I am using

The question I have is is it possible to create a formula which plots a sine curve which hits 2 given points.

Pages: **1**

- Index
- » Search
- »
**Posts by Paul**