FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   circular arcs
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: circular arcs  (Read 729 times)
edwardgeorge

WWW
circular arcs
« on: Dec 4th, 2002, 7:10pm »

whats the best way of drawing circular arcs from point a to point b of specific radius r.?
 
thanks,
ed
 

Ed, Suppose, Nottingham, UK
http://www.suppose.co.uk
http://ed.suppose.co.uk
REAS


WWW
Re: circular arcs
« Reply #1 on: Dec 4th, 2002, 8:50pm »

hello ed,
 
this is not the best way but it's one way and i think it is clear. in this code, you specify the beginning and end points of the arc using degree values (0-360).
 
Code:

void setup()  
{
  size(300, 300);
}
 
void loop()  
{
  arc_degrees(width/2, height/2, 0, 270, 100);
}
 
void arc_degrees(int x, int y, int begin, int end, int radius)  
{
  if (begin > end) {
    int temp = begin;
    begin = end;
    end = temp;
  }
  beginShape(LINE_STRIP);
  for(int i=begin; i<=end; i++) {
    float xval = radians(i);
    float yval = radians(i);
    vertex(x + cos(xval)*radius, y - sin(yval)*radius);
  }
  endShape();
}
« Last Edit: Dec 4th, 2002, 11:20pm by REAS »  
Pages: 1 

« Previous topic | Next topic »