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.
IndexProgramming Questions & HelpPrograms › Simple math trigonometry question
Page Index Toggle Pages: 1
Simple math trigonometry question (Read 862 times)
Simple math trigonometry question
Sep 8th, 2009, 1:52am
 
Hello,

I'm actually trying to figure out what's the white magic behind curve() and curveVertex() functions' secrets.

So that i started a very simple sketch.
Basically, the sketch draw the controls points along the curve i want to draw (i.e a simple circle shape).

The point i don't get so far is why only four points are draw ? I don't really get why when i = 3 the point(0.38*offset, 0.9*offset) does not appear ?

Here's the source:

Code:

int steps = 4;
int offset = 50;

size(200, 200);
background(255);
noFill();
translate(width/2, height/2);

for (int i=0; i <= steps; i++){
 point(cos(radians((90/steps) * i)) * offset, sin(radians((90/steps) * i)) * offset);
}


I know this is pretty simple but there's something i certainly don't get.
Thx by advance


Re: Simple math trigonometry question
Reply #1 - Sep 8th, 2009, 2:13am
 
I'm running your code with P5 1.0.7 on Mac OS SL 10.6 with Java 1.5 and don't see any problem.

...

Code:

int steps = 4;
int offset = 50;

void setup(){
 size(200, 200, P2D);
}

void draw(){
background(255);
noFill();
translate(width/2, height/2);

for (int i=0; i <= steps; i++){
 point(cos(radians((90/steps) * i)) * offset, sin(radians((90/steps) * i)) * offset);
}
}
Re: Simple math trigonometry question
Reply #2 - Sep 8th, 2009, 2:21am
 
Ah thx for the answer !!!

I'm sure this must come from my workstation.
16mo video memory is kinda retro-hardcore.

Thx for the answer.
At least no mistake in my code.
Page Index Toggle Pages: 1