Post Reply 
Graphics coordinates vs Pixels coordinates
03-19-2019, 11:57 AM
Post: #1
Graphics coordinates vs Pixels coordinates
To draw an ARC, the radius is given in PIXEL, not in graphical units. So when making some drawing I observe some peculiar behaviour. If the graphical units are not well defined, you always got a "visual circle" but in fact an "ellipse" in term of graphical units.
The following program try to draw a circle with ARC and the same circle with SIN&COS+LINE.
Code:
#pragma mode(separator(.,;) integer(h32))
EXPORT gl() BEGIN
 LOCAL ra:=10.0;
 LOCAL o,x,y,xx,yy,dn;
 RECT();HAngle:=1;
 Xmin:=-15.9;Xmax:=15.9;
 Ymin:=-10.9;Ymax:=11.0;
 ARC(0.0,0.0,ra*320/(Xmax-Xmin),0,360,#FF0000);
 dn:=0;x:=0.0;y:=0.0;
 FOR o FROM 0.0 TO 360.0 STEP 5.0 DO
  xx:=ra*COS(o);yy:=ra*SIN(o);
  IF dn THEN LINE(x,y,xx,yy,#000000);END;
  dn:=1;x:=xx;y:=yy;
 END;FREEZE;RETURN;
END;
I started with
Code:
Xmin:=-16.0;Xmax:=16.0;
Ymin:=-12.0;Ymax:=12.0;
in the hope to have a square graphical units, but in this case the SIN&COS circle was not corresponding to the ARC one. I finally found that using
Code:
Xmin:=-15.9;Xmax:=15.9;
Ymin:=-10.9;Ymax:=11.0;
gave a quite good overlapping circles and a quite good square graphical units .
My question is the following, are those differences explained somewhere in the manual ?
I thinks that the graphical units do not use the full vertical size of the screen (to keep some space to draw the menus ?)

It seem ok to do so, but for ARC vs ARC_P with the radius given in PIXELS and not in graphical units there is some discrepancy. In fact ARC_P should always give a perfect circle. But ARC should use a radius in graphical units and could result in drawing an ellipse if graphical units are not rectangular. This will be more consistent. (And easier to deal with as using C->PX and PX->C to deal with distance is not very friendly).

Olivier
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Graphics coordinates vs Pixels coordinates - Oulan - 03-19-2019 11:57 AM



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