Home > Back-end >  Delphi paintings arc problem
Delphi paintings arc problem

Time:09-16

Do is G code decoding, below is the analytical lines of code, the results can't correct drawing need arc (y coordinate of the same line connection between two pieces of arc) inquire about
Procedure TForm1. DrawFox (lineInfo: String);
Var di, a, b, r, x, y, ab2: integer;
Sub: string;
Temp: double;
The begin
Di:=pos (G02, lineInfo);
If (di=0) then
exit;
A:=strtoint (subString (lineInfo, 'Z', ' ', sub));
B:=strtoint (subString (lineInfo, 'X', ' ', sub));
R:=strtoint (subString (lineInfo, 'r', ' ', sub));

A:=a * 2;
B:=b * 2;
R:=r * 2;

Ab2: a + b=a * * b;
Temp:=SQR (b) (4 * * SQR (r) - SQR (ab2))/(4 * ab2) + SQR/4 (a);
X:=round (- SQRT (temp) + a/2);
Y:=round ((ab2-2 * a * x)/2 * b);


XSH:=paintbox1. Width - 232;
Ysh:=paintbox1. Height - 150;
X:=XSH + x;
Y:=ysh + y;

Paintbox1. Canvas. Pen. Style:=pssolid;
Paintbox1. Canvas. Pen. Width:=3;
Paintbox1. Canvas. Pen. Color:=clred;

Paintbox1. Canvas. MoveTo (x, y);

Paintbox1. Canvas. Arc (x - r, y, r, x + r, y + r, XSH, ysh, XSH + a, ysh - b).

end;

CodePudding user response:


Like this

CodePudding user response:

Know the starting point of the arc end point coordinates and radius

CodePudding user response:

The code above can only draw a semicircle, and can't appear in the correct position, y is 0

CodePudding user response:

By using the method of coordinate translation, find the origin of circular arc, the can draw arc,

CodePudding user response:

reference 4 floor lyhoo163 response:
, through the method of coordinate translation, to find the origin of circular arc, the can draw arc,

Can you say about the specific methods, baidu or no results in the coordinate translation,

CodePudding user response:

Isn't know two point and radius can draw four arc? Review the geometry,

CodePudding user response:

These are basic knowledge of plane geometry and analytic geometry,
  • Related