Section:
Page
PROGRAMMING42
Chapter: 6
Parametric programming example to calculate the coordinates of the various points
forming an ellipse.
The formula defining an ellipse is:
X = P0 sine ß
Y = P1 cosine ß
Where:
P0 = Long axis
P1 = Short axis
The definition parameters are:
P0 = Long axis.
P1 = Short axis.
P2 = Angular position of the first point (A).
P3 = Angular step between consecutive points.
The parameters used by the program are:
P2 = Angular position of the new point (ß)
P4 = X coordinate of the new point.
P5 = Y coordinate of the new point.
Program:
N000 P0 K20 Setting of definition parameters (Example).
N001 P1 K10
N002 P2 K0
N003 P3 K2
N004 G25 N20 Jump to subroutine to calculate the ellipse.
N020 P4 F7 P2 Calculation of the new point of the ellipse.
N021 P5 F8 P2
N022 P4 P0 F3 P4 P4 = P0 sine ß
N023 P5 P1 F3 P5 P5 = P1 cos ß
N024 G0.5.90 XP4 YP5 G00 move to first point of ellipse
N025 P2 P2 F1 P3 Angular increment ß = ß + P3
N026 G25 N20.23 Calculation of new point of the ellipse.
N026 G1 XP4 YP5 F200 Positioning at new point.
N027 P2 F11 K360 Compare ß with 360°
N028 G28 N25 If ß < 360°, still not done, new point, jump to N25
N029 M30 If ß = 360°, End of program.
PARAMETRIC
PROGRAMMING