winder / Universal-G-Code-Sender

A cross-platform G-Code sender for GRBL, Smoothieware, TinyG and G2core.
http://winder.github.io/ugs_website/
GNU General Public License v3.0
1.85k stars 758 forks source link

Improve the arc expander preprocessor #2430

Open breiler opened 5 months ago

breiler commented 5 months ago

Description

The arc expander preprocessor is used to convert arc (G2/G3) into smaller straight line segments (G1). This can be used if the controller doesn't support arcs or if there are other operations that is to difficult or impossible to compute as arc (such as autoleveling, rotating or translating a gcode model).

The way the arc is broken up into smaller line segments is done with a fixed line segment length which is default set to 0.01 mm.

Let us assume an 45 degree arc with an radius of 500mm:

G17 G21 G90 G94 G54 M0 M5 M9
G0 Z1 F5
X-500 Y0
G1 Z0
G2 X0 Y500 I500 J0.

The length of the arc would be calculated with $L = r × θ$, which becomes $L = 500mm * π/4 = 392.5mm$

When expanded into 0.01 mm line segments this would generate around 40000 lines of gcode.

Find a new scalable way to expand arcs.