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
Dot Circle (Read 1286 times)
Dot Circle
May 16th, 2010, 1:29pm
 
What is the best algorithm to draw a circle with points only ?
Re: Dot Circle
Reply #1 - May 16th, 2010, 1:58pm
 
you can make it like this using rotation


Code:

void setup() {
size(600,600);
smooth();
background(255);

}

void draw() {
background(255);
translate(width/2,height/2);
for(int i= 0; i<36;i++){
rotate(TWO_PI/36);
ellipse(100,0,4,4);

}


}



Re: Dot Circle
Reply #2 - May 16th, 2010, 2:02pm
 
or like this, using sin and cos

Code:

void setup() {
size(600,600);
smooth();
background(255);

}

void draw() {
background(255);
translate(width/2,height/2);
for(int i= 0; i<36;i++){

float x = cos( i*TWO_PI/36 )*100;
float y = sin( i*TWO_PI/36 )*100;
ellipse(x,y,4,4);

}


}



Re: Dot Circle
Reply #3 - May 17th, 2010, 5:11am
 
Thanks Cedric.

I want to use this create sections of a circle.
Re: Dot Circle
Reply #4 - May 17th, 2010, 5:36am
 
good to know what you need it for.
you can use arc() to do that Smiley

http://processing.org/learning/basics/piechart.html
Re: Dot Circle
Reply #5 - May 17th, 2010, 7:13am
 
Thanks again cedric.

There is my easysphere algorithm.
How do I draw lines between the nearest points seeing that I don't draw them in sequence. How do I calculate what is the nearest three ,two or one so I can draw a rect, triangle or a line ?

http://www.openprocessing.org/visuals/?visualID=6566



//December 15th 2009
//EasySphere v1.0
//Owaun Scantlebury
Code:

import peasy.org.apache.commons.math.*;
import peasy.*;
import peasy.org.apache.commons.math.geometry.*;
PeasyCam cam;
void setup(){
size(300,300,P3D);  
background(255);  
cam= new PeasyCam (this,width);
}

void draw(){
translate(-width/2,-height/2);
background(255);  
for (float z=0;z<360;z+=0.1){ //0.01 to increase resolution
 translate(width/2,height/2,0);
 rotateX(z);
 //line(0,0,30,30); //uncomment for solid sphere
 point(30,30);
 rotateZ(z);
 point(30,30);
 //line(0,0,30,30); //uncomment for solid sphere
 translate(-width/2,-height/2,0);
 

}  
 
Page Index Toggle Pages: 1