We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
0...1 (Read 908 times)
0...1
Mar 26th, 2010, 3:17pm
 
Hi,

two very dumb questions:

1: how can I produce a number, that goes between 0...1 (but not random)?  I need it to determine an angle.
Let`s say angle p = k*TWO_PI; so that I can change k to move from 0 to 360 and get a rotation.

2: how can I measure time, in seconds - millis()*100 ?
The time is for measuring the angular speed (TWO_PI*radius/time), which I can then manipulate - increase/decrease.


any help is greatly appreciated!  


emm, does this make any sense for the angle rotation :
Code:

void rotateSphere()
{
 
 for(float i=0; i<TWO_PI; i++)
 {
   float phase = radians(i/TWO_PI);
   angle += sin(phase)*TWO_PI;

}
Re: 0...1
Reply #1 - Mar 26th, 2010, 3:49pm
 
time in seconds is actually millis()/1000. just think about it Smiley

and to answer your second question, i would maybe do it that way. but there are several others i guess.


void setup() {
 size(600,400);
}
float count = 0;
void draw() {

 count = (count%1)+0.1;
 println(count);
}
Re: 0...1
Reply #2 - Mar 26th, 2010, 3:51pm
 
hm,  0.001 mills * 1000 = 1 sec ?

why divide?
Re: 0...1
Reply #3 - Mar 26th, 2010, 3:55pm
 
when youve got 1000 millis youve got one second...
so
if you divide your millis() / 1000 you get the seconds.
its just math
Re: 0...1
Reply #4 - Mar 26th, 2010, 3:57pm
 
well yes, obviously ...  no comment. ..

and what about the 0...1 number? it`s also just 1. class maths.... no idea really Sad
Re: 0...1
Reply #5 - Mar 26th, 2010, 4:00pm
 
i edited and gave the answer in one of my earlier posts.
Re: 0...1
Reply #6 - Mar 26th, 2010, 4:02pm
 
o yes, now I see it.

Danke!  I`ll try it out now ...
Re: 0...1
Reply #7 - Mar 26th, 2010, 4:07pm
 
gerne Smiley
Re: 0...1
Reply #8 - Mar 26th, 2010, 4:09pm
 
ich hoffe es sind nicht so viele wie ich.

du musst starke nerven haben...I admire you Wink

danke vielmals
Re: 0...1
Reply #9 - Mar 26th, 2010, 4:18pm
 
ach quatsch, manchmal sieht man halt den wald vor bäumen nicht Smiley
Page Index Toggle Pages: 1