In this last example I've matched a circle made with bezier with a native circle made with arcs.
The G300 macro is changed to use K instead of F and missing last segment added.
G300 Macro code:
Code:
; create a degree 3 Bezier curve
;
; dt T #20
; p0.x A #1
; p0.y B #2
; p1.x C #3
; p1.y D #7
; p2.x E #8
; p2.y K #6
; p3.x I #4
; p3.y J #5
O1000
; local variables
; #1000 = t
; #1001 = x0
; #1002 = y0
; #1003 = x1
; #1004 = y1
#1000 = 0.0
; calc x1 & y1
G65 P1001 T#1000 A#1 B#3 C#8 D#4
#1003 = #100
G65 P1002 T#1000 A#2 B#7 C#6 D#5
#1004 = #100
; t = t + dt
#1000 = [#1000 + #20]
WHILE [#1000 LT 1] DO01
; x0 = x1
#1001 = #1003
; y0 = y1
#1002 = #1004
; calc x1 & y1
G65 P1001 T#1000 A#1 B#3 C#8 D#4
#1003 = #100
G65 P1002 T#1000 A#2 B#7 C#6 D#5
#1004 = #100
G1 X#1001 Y#1002
X#1003 Y#1004
; t = t + dt
#1000 = [#1000 + #20]
END01
; connect final point
#1000 = 1
; x0 = x1
#1001 = #1003
; y0 = y1
#1002 = #1004
; calc x1 & y1
G65 P1001 T#1000 A#1 B#3 C#8 D#4
#1003 = #100
G65 P1002 T#1000 A#2 B#7 C#6 D#5
#1004 = #100
G1 X#1001 Y#1002
X#1003 Y#1004
M99
; X function for a degree 3 Bezier curver
;
; t T #20
; x0 A #1
; x1 B #2
; x2 C #3
; x3 D #7
;
; #100 = x0 * (1 - t) ^ 3 +
; x1 * 3 * t * (1 - t) ^ 2 +
; x2 * 3 * t ^ 2 * (1 - t) +
; x3 * t ^ 3
O1001
#100 = [ 0 + [#1 * [[1 - #20] ** 3]] ]
#100 = [ #100 + [#2 * 3 * #20 * [[1 - #20] ** 2]] ]
#100 = [ #100 + [#3 * 3 * [#20 ** 2] * [1 - #20]] ]
#100 = [ #100 + [#7 * [#20 ** 3]] ]
M99
; Y function for a degree 3 Bezier curver
;
; t T #20
; y0 A #1
; y1 B #2
; y2 C #3
; y3 D #7
;
; #100 = y0 * (1 - t) ^ 3 +
; y1 * 3 * t * (1 - t) ^ 2 +
; y2 * 3 * t ^ 2 * (1 - t) +
; y3 * t ^ 3
O1002
#100 = [ 0 + [#1 * [[1 - #20] ** 3]] ]
#100 = [ #100 + [#2 * 3 * #20 * [[1 - #20] ** 2]] ]
#100 = [ #100 + [#3 * 3 * [#20 ** 2] * [1 - #20]] ]
#100 = [ #100 + [#7 * [#20 ** 3]] ]
M99
Sample code:
Code:
G17 G20 G40 G49 G80 G90
G54 F100
G52 X2 Y2
G0 X0 Y1
G64 Q.01 P.01
; select T1 color
M61 Q1
; control point for 1 inch radius
#1=0.55191502449
; circle of 1 inch with bezier curve
;
; dt p1.X p1.Y p2.X p2.Y p3.X p3.Y p4.X p4.Y
; ===== ==== ==== ==== ==== ==== ==== ==== ====
G300 T0.01 A0 B1 C#1 D1 E1 K#1 I1 J0
G300 T0.01 A1 B0 C1 D-#1 E#1 K-1 I0 J-1
G300 T0.01 A0 B-1 C-#1 D-1 E-1 K-#1 I-1 J0
G300 T0.01 A-1 B0 C-1 D#1 E-#1 K1 I0 J1
; select T2 color
M61 Q2
; circle of 1 inch with g2
G0 X0 Y1
G2 X0 Y1 I0 J-1
M2
Result:
Video:
In next days I will try to create a macro to manage cycles with NURBS control points eg:
Code:
G66 p"nurbs" Q1 L3
X0 Y1 Q1
X2 Y2 Q1
X2 Y0 Q1
X0 Y0 Q2
G67