# LinuxCNC G5 Cubic Spline

Instructions · `G5 Cubic Spline` · verification: source checked

G5 creates a cubic B-spline in the XY plane using only the X and Y axes. P and Q give the second control point as offsets from the end point and must both be specified. I and J give the first control point as offsets from the start point; on later G5 commands they can be omitted so the spline continues smoothly from the previous cubic.

## Specification

| Property | Value |
|---|---|
| Language | gcode |
| Code | G5 |
| Syntax | G5 X- Y- <I- J-> P- Q- |
| Dialect | LinuxCNC |

### Parameters

| Name | Data type | Description |
|---|---|---|
| X | real |  |
| Y | real |  |
| I | real | X incremental offset from start point to first control point |
| J | real | Y incremental offset from start point to first control point |
| P | real | X incremental offset from end point to second control point |
| Q | real | Y incremental offset from end point to second control point |

## Safety

- Operating limit: the active plane must be G17, and only X and Y axis words are allowed; otherwise the command is an error.

## Study notes

- For the first G5 command in a series, I and J must both be specified.
- For subsequent G5 commands, either both I and J must be specified or neither.
- If I and J are omitted on a subsequent G5 command, the starting direction matches the ending direction of the previous cubic, as if I and J are the negation of the previous P and Q.
- P and Q must both be specified for every G5 command.
- It is an error to specify an axis other than X or Y, or to use a plane other than G17.
- Example initial spline: G90 G17; G0 X0 Y0; G5 I0 J3 P0 Q-3 X1 Y1.
- Example subsequent spline: G5 P0 Q-3 X2 Y2.

## Sources

1. [G-Codes](https://linuxcnc.org/docs/html/gcode/g-code.html#gcode:g5) (accessed 2026-10-26)

---

Source page: https://machineschema.com/instruction/gcode-g05  
JSON: https://machineschema.com/instruction/gcode-g05.json  
License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Cite Machine Schema and the original sources.
