Post Reply 
Circle with interior arc segments
02-12-2015, 06:00 PM (This post was last modified: 02-12-2015 06:19 PM by Thomas_Sch.)
Post: #8
RE: Circle with interior arc segments
I added temporarily printing for some variables, to see the calculated values, also temporarily made different colors for north and sourth semicircles.
The calculations are easy and should be correct. Maybe the values for the big arcs are to big? (r3 could also be calculated by tan(a)*r ).
I am currently stumped, why the semicircles are not hitting the red circle.
Maybe it's better to use the cartesian drawing functions (without _P) than the pixel drawing functions. But I'm not shure.

Code:

EXPORT Circ() 
BEGIN
 LOCAL a;
 LOCAL red:=  RGB(255,0,0);
 LOCAL blue:= RGB(0,0,255);
 LOCAL green:= RGB(0,255,0);
 LOCAL grey:= RGB(210,210,210);
 LOCAL lgrey:=RGB(210,210,00);
 LOCAL white:=RGB(255,255,255);
 LOCAL cx:=156, cy:=109, r:=105; // Center: (156,109), Radius: 105 (pixels)
 LOCAL x2, y2, r2, x3, y3, r3, str; 

 RECT_P(G0);
 //     G   x  y   r  w1  w2   Color 
 ARC_P(G0, cx, cy, r, 0, 2*pi, red); 
  // Semicircle center: (156,109), radius: 105 pixels 
 LINE_P(G0, cx-r, cy, cx+r, cy, red);    // Equator

 FOR a  FROM -pi TO pi STEP pi/12 DO
    //  x2:= cx+r*COS(a);
    //  y2:= cy-r2; 
    //  r2:= r*SIN(a); 
    //  r3:= r*SIN(a)/COS(a);
    r3:= r*TAN(a);
    x3:= cx+r;
    y3:= cy-r3; 
    IF abs(a) < ROUND(pi/2,7)  then  
      RECT_P(G0,5,220,300,240,white,white);
      str:= "a: "+STRING(a,2,3)+"  x3:"+STRING(x3,1,-1)+"  y3: "+STRING(y3,2,3)+"  r3: "+STRING(r3,2,3);  
      TEXTOUT_P(str, 5,220, 2);
      //    G   x   y    r   w1          w2    Color
      ARC_P(G0, x3, y3, r3,  2*a+1/2*pi, -pi/2, blue);   // north semicircle  
      ARC_P(G0, x3, y3, -r3, pi/2, 2*a-1/2*pi, green);   // south semicircle 
      WAIT(-1);
    END;
 END;
 DRAWMENU("");
 FREEZE;
END;

Edit:
Could it be possible, to draw a big "picture" greater than the display, and only show a part of this great picture? How big can be the GROBs?
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Circle with interior arc segments - DrD - 02-10-2015, 06:45 PM
RE: Circle with interior arc segments - Thomas_Sch - 02-12-2015 06:00 PM



User(s) browsing this thread: 1 Guest(s)